-
Notifications
You must be signed in to change notification settings - Fork 881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect runtime file locations #4820
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of fixes needed for this approach to work I think. I'd like to avoid the bootstrap of config, but I don't see how given that we'd need to source all applicable config sources first with ConfigMerger to account for any overrides before trying to re-process that content.
Ideally if we've bootstrapped config we wouldn't need to re-merge, but since run_dir can change, that'd potentially affect what sources for <run_dir>.cloud.cfg we pull in or ignore as well.
cloudinit/stages.py
Outdated
# distro-specific rund_dir locations. Once we have the run_dir | ||
# we re-read our config with a valid Paths() object. This code has to | ||
# assume the location of /etc/cloud/cloud.cfg && /etc/cloud/cloud.cfg.d | ||
bootstrapped_config = self._read_bootstrap_cfg(extra_fns, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm understanding the reason you are bootstrapping config here is to obtain the fully merged system_info.paths
defined in any of the default config sources including the filesystem in /etc/, extra_fns and the datasource config.
If so, this bootstrapped_config is a dict that won't actually surface the top-level config path keys you are trying to re-pass into Paths initialization, so the bootstrap isn't honoring the merged system_info.paths
configuration obtained because you are passing the full config dictionary instead of the specific bootstrapped_config["system_info"]["paths"] if present. This would be where we'd obtain the FreeBSD customized config from the file-system.
So I think what we probably want here is _read__boostrap_cfg(extra_fns, bootstrapped_config,get("system_info", {}).get("paths", {})
to ensure the processed mergedsystem_info.paths
is being honored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think what we probably want here is _read__boostrap_cfg(extra_fns, bootstrapped_config,get("system_info", {}).get("paths", {}) to ensure the processed mergedsystem_info.paths is being honored.
+1 thanks for the fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request changes on a couple of bugs in the approach at the moment. This bootstrapping is potentially painful for configurations that are overriding path defaults via /etc/cloud/cloud.cfg and forces a full re-merge of all content on all runs of cloud-init even when only a small percentage of images are changing those cloud_dir/run_dir defaults in system config. I wonder if it's worth instead just checking post ConfigMerger if merged._cfg["system_info"]["paths"]["run_dir"] != self.paths.run_dir and only re-run read_bootstrap_cfg
if we've detected a change in run_dir.
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.) |
This actually causes infinite recursion, since this code path is where self.paths gets defined, however we can check for change in run_dir as the trigger for re-reading config. |
78cbbcb
to
c698672
Compare
@blackboxsw I addressed your comments and fixed the tests, ready for re-review now. |
@blackboxsw thanks for the review, I think I've addressed everything |
The issue I'm seeing, and neglected to think about before this effort, is that our generator time-frame remains unaware of any system config run_path. This then leaves cloud-init in a split-brain scenario where our systemd generator time-frame or any early boot script invocation of ds-identify (BSD/Alpine) will store ds-identify artifacts in the default Without aligning generator timeframe run_dir artifacts and python-based boot stages with the system config overrides, cloud-init python boot stages will be unable to source the ds-identify output which determines whether cloud-init is enabled or disabled and the filtered datasource_list values. Some thoughts, not certain how viable, but I think the generator time-frame functionality may need to be sorted in a separate prior to the python-based solution because, with the split-brain scenario, cloud-init boot stages will be looking in the wrong /run/cloud-init directory and not see the Ideas for fixes needed:
Here's a running diff that looks almost functional (though it as a direct cut-n-paste of the check_config/read_uname_info functions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs fixing as I think we need to sort generator time-frame functionality first to avoid split-brain issues w/ python boot stages and ds-identify behavior.
@blackboxsw great thoughts, thanks for the review.
True. Although I don't think the path issue affects Alpine. And on BSD, ds-identify can independently behave as required due to set_run_path.
Since ds-identify now uses Multiple sources of truth is not great, but I think that with the current approach it will now at least be possible to make both use
I hadn't thought about this one. However, I'd be surprised if this one works on non-Linux, because udev is very Linux-specific. Searching about FreeBSD + udev I see that maybe xorg is using udev api with devd as a backend circa 2020, but I haven't found any official details about it.
Using check_config for this scares me a little, but that could work. I'd be concerned about this because false positives would break all of ds-identify. Currently false positives will (I think) only result in possibly adding unwanted datasources to the list, and cloud-init's Python code has ds_detect() and a failover path which means that when this happens, cloud-init should usually still behave as intended. Maybe we limit the splash zone of this failure by checking for the existence of directories set by run_dir before using this directory? However this would mean that run_dir would also have to be a single-line k/v pair in order to work, so I'm not sure how much more we want to add reliance on our broken yaml parser.
+1 nice, thanks for putting that together It is up to you whether we go forward with the current approach (given the points raised above), or try for a more complete run_dir-everywhere approach which depends on check_config. I think I'd lean towards moving forward with this and possibly iterating on the generator scripts separate from this PR, but I don't feel strongly about that. |
finally got around to testing this, and the main issue I'm seeing is:
Which, according to
cleanvar instead. (Unlike the comment that claims var_run should suffice)
|
that seems to be my fault, tho: cloud-init/config/cloud.cfg.tmpl Line 334 in f7c1c76
|
@holmanb here's a PR addressing my complaints: holmanb#50 |
great feedback, and thanks for the PR against this branch - I just merged it into this branch |
n.b.: I've tested this on FreeBSD and it works as expected. |
Yes, I think we can move forward with this PR. I think this PR you have fixes the the highest-impact gaps to align run-time python config based on overrides provided in Let's file 3 issues for the following related to run_dir config overrides:
We may be able to avoid the incomplete cloud-init status issue in this PR by also checking the for Given that overriding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@holmanb If you agree to create and defer the couple of remaining issues with this approach I think we can go ahead and land this PR as-is.
Thanks for the review @blackboxsw.
All of these are systemd-specific code-paths, and systemd explicitly requires an ephemeral /run directory, so I don't think there is anything to fix related to these three points. |
Good point. Though some image could set |
80ab7f1
to
4cf8743
Compare
Force pushed to resolve merge conflicts. |
Update various hard-coded filepaths. Also make sure we bootstrap our Paths() config correctly so that we read from the configured rundir. Co-authored-by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Fixes canonicalGH-4766
Update various hard-coded filepaths. Also make sure we bootstrap our Paths() config correctly so that we read from the configured rundir. Co-authored-by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Fixes canonicalGH-4766
Update various hard-coded filepaths. Also make sure we bootstrap our Paths() config correctly so that we read from the configured rundir. Co-authored-by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Fixes canonicalGH-4766
Update various hard-coded filepaths. Also make sure we bootstrap our Paths() config correctly so that we read from the configured rundir. Co-authored-by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Fixes GH-4766
Update various hard-coded filepaths. Also make sure we bootstrap our Paths() config correctly so that we read from the configured rundir. Co-authored-by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Fixes GH-4766
Update various hard-coded filepaths. Also make sure we bootstrap our Paths() config correctly so that we read from the configured rundir. Co-authored-by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Fixes GH-4766
Proposed Commit Message
Additional Context
Fixes #4766
This doesn't fix the /etc file location issue, but it also shouldn't make it any worse than it already is.
That should be fixed in a follow-up PR.
Merge type