Skip to content

systemd enable/disable - #17

Merged
openshift-merge-robot merged 2 commits into
openshift:masterfrom
ashcrow:systemd
Sep 4, 2018
Merged

openshift-merge-robot merged 2 commits into
openshift:masterfrom
ashcrow:systemd

Conversation

@ashcrow

@ashcrow ashcrow commented Aug 20, 2018

Copy link
Copy Markdown
Member

This is pre-work for enabling/disabling units intelligently via incoming config.

  • enableUnit: Takes a ignv2_2types.Unit and attempts to link into the enabled path on the system. If it is already linked the function returns early.
  • disableUnit: Takes a ignv2_2types.Unit and attempts to remove the link from the enabled path. If the link does not exist the function returns early.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 20, 2018
@ashcrow

ashcrow commented Aug 20, 2018

Copy link
Copy Markdown
Member Author

/cc @sdemos

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ashcrow: GitHub didn't allow me to request PR reviews from the following users: sdemos.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @sdemos

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ashcrow

ashcrow commented Aug 20, 2018

Copy link
Copy Markdown
Member Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 20, 2018

@sdemos sdemos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than a small comment on logging, everything here lgtm.

now to just figure out how to convince the bot I mean it...

Comment thread pkg/daemon/update.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if these should be warnings. Once the MCD decides it wants to apply the config, it just lays down all the files, systemd units, etc, exactly how they are defined in the new config without really checking the old one, which means that this warning will get spit out for every enabled unit every time a new config is applied, if that makes sense. same with the other function below.

maybe just do Info?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm cool with it being an Info instead. I'll amend :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@ashcrow

ashcrow commented Aug 20, 2018

Copy link
Copy Markdown
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 20, 2018
@abhinavdahiya

Copy link
Copy Markdown
Contributor

@sdemos can you try /lgtm now.

@sdemos

sdemos commented Aug 21, 2018

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@sdemos: changing LGTM is restricted to assignees, and only openshift/machine-config-operator repo collaborators may be assigned issues.

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@abhinavdahiya

Copy link
Copy Markdown
Contributor

@sdemos try /lgtm now. fingers crossed

@ashcrow

ashcrow commented Aug 22, 2018

Copy link
Copy Markdown
Member Author

Come on robot!

@ashcrow

ashcrow commented Aug 22, 2018

Copy link
Copy Markdown
Member Author

/cc @sdemos

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ashcrow: GitHub didn't allow me to request PR reviews from the following users: sdemos.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @sdemos

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ashcrow

ashcrow commented Aug 22, 2018

Copy link
Copy Markdown
Member Author

@abhinavdahiya based on the cc attempt I have a bad feeling about lgtm :-/

Comment thread pkg/daemon/update.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stat follows the link target, but an absolute link target does not contain the prefix for the rootfs bind-mount. Depending on the link content, the result that you get here may (or may not) be incorrect.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Good point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end it might be most reliable to talk to pid 1 via DBus to do this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgwalters for this specific case, likely yes. But in general all files/dirs manipulation that may traverse a symlink will be subject to the de-sync above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. See coreos/rpm-ostree#1481 for a related issue in rpm-ostree that we fixed by resolving the symlinks inside a container via bwrap. Since this container is privileged, it should work fine to spawn e.g. a bwrap container targeting the host and run code there if we need to.

It might work best if we created a pattern where just /etc and /var from the host are bind mounted into such a container, but the /usr comes from the container?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also https://lwn.net/Articles/723057/ for a not-yet-upstream kernel API that would help here.

@lucab

lucab commented Aug 22, 2018

Copy link
Copy Markdown

Please beware that if you do link manipulation and de-referencing over a bind-mount prefix, the targets you get/set will be out-of-sync/wrong compared to the rootfs.

@ashcrow

ashcrow commented Aug 22, 2018

Copy link
Copy Markdown
Member Author

It was pointed out by @lucab that this functionality will be run via a container and, thus, we can't trust the literal paths. See https://github.com/openshift/machine-config-operator/blob/master/docs/MachineConfigDaemon.md#overview.

@ashcrow

ashcrow commented Aug 22, 2018

Copy link
Copy Markdown
Member Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 22, 2018
@cgwalters

Copy link
Copy Markdown
Member

One thing I don't quite understand from context is - do we want to affect the current state of the system (booted), or the next state (the next boot)?

I find most commonly when I'm doing things like this to a live system I want the equivalent of systemctl enable --now to also start the unit. That's something to consider.

@ashcrow

ashcrow commented Aug 22, 2018

Copy link
Copy Markdown
Member Author

I find most commonly when I'm doing things like this to a live system I want the equivalent of systemctl enable --now to also start the unit. That's something to consider.

Also a great point. The set of functionality being targeted by this is enabling/disabling a service based on ignition portion of an MachineConfig. However, if ignition treats enabled as enable and start I will need to add said functionality here as well.

@sdemos

sdemos commented Aug 22, 2018

Copy link
Copy Markdown
Contributor

One thing I don't quite understand from context is - do we want to affect the current state of the system (booted), or the next state (the next boot)?

in general the daemon is making changes for the next boot. It explicitly doesn't try to daemon-reload systemd units or restart them when their config files change, since that gets into a world of complex semantics and dependency chains that we don't want to represent. instead, we just always reboot the machine at the end of the update and rely on that reboot to pick up changes we made to the machine.

more concretely, I think we should just enable the unit and let systemd start it on reboot.

@ashcrow

ashcrow commented Aug 23, 2018

Copy link
Copy Markdown
Member Author

Keeping this on hold until I've worked through the early chroot work for the containerized MCD.

@ashcrow

ashcrow commented Aug 29, 2018

Copy link
Copy Markdown
Member Author

Updated based on #26

@ashcrow

ashcrow commented Aug 30, 2018

Copy link
Copy Markdown
Member Author

/cc @sdemos

@ashcrow

ashcrow commented Sep 4, 2018

Copy link
Copy Markdown
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 4, 2018
@ashcrow

ashcrow commented Sep 4, 2018

Copy link
Copy Markdown
Member Author

Blocking PR has merged.

Comment thread Dockerfile.machine-config-daemon Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be added to the dockerfile? shouldn't it be enough that it's in the deployment manifest? this should only be run as a pod and not directly anyway. at the very least, it's odd to me to only have this one and none of the other volume mounts.

@ashcrow ashcrow Sep 4, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be. I had added it as it felt it clarified that it was a required mount. I'm happy to remove it if you think that would be better :-)

wantsPathSystemd houses the systems path where enable units should
be linked.

Signed-off-by: Steve Milner <[email protected]>
- enableUnit links a given unit into the enabled path
- disableUnit removes a link from the enabled path

Signed-off-by: Steve Milner <[email protected]>
@ashcrow

ashcrow commented Sep 4, 2018

Copy link
Copy Markdown
Member Author

@sdemos updated

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 4, 2018
@sdemos

sdemos commented Sep 4, 2018

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 4, 2018
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashcrow, sdemos

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot
openshift-merge-robot merged commit 2f7bc7a into openshift:master Sep 4, 2018
osherdp pushed a commit to osherdp/machine-config-operator that referenced this pull request Apr 13, 2021
ptalgulk01 pushed a commit to ptalgulk01/machine-config-operator that referenced this pull request May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants