-
Notifications
You must be signed in to change notification settings - Fork 270
Stop hardcoding base and default configs in Ignition binary #475
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
Conversation
|
@bgilbert what should happen in the event that no configuration is found? I added a test locally that calls Is this something where we should bubble out a warning/error to the user saying "Ignition couldn't find any configs"? |
|
No configs is a valid state: the distro didn't provide any base or default configs (e.g. CL on bare metal) and the user didn't provide a config either. I'll add a test though. |
|
Updated. |
|
GH mangles commit order. Can you post the actual commit order? |
|
In this case it should be the same as in GitHub's list: |
Instead of hardcoding them in Ignition, expect the distro to put them in /usr/lib/ignition (by default).
|
This is ready for review. |
arithx
left a comment
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.
Tests LGTM, thanks for updating the doc/development blurb about the Test struct.
| var err error | ||
| for _, fetcher := range fetchers { | ||
| cfg, r, err = fetcher(f) | ||
| if err != providers.ErrNoProvider { |
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.
It's non-obvious that this is true when err == nil. I'd either explicitly do an if err == nil || err !=n providers.ErrNoProvider or leave a comment.
| cfg, r, err = e.OEMConfig.FetchFunc()(f) | ||
| fetchers := []providers.FuncFetchConfig{ | ||
| cmdline.FetchConfig, | ||
| system.FetchConfig, |
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.
Should this and e.OEMConfig.FetchFunc() be swapped? Wouldn't this always override use supplied configs when there is a default config in the system dir?
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.
Erm, I think I got confused there.
The old way Ignition worked was to take the base config, append the given provider's base config, then append the user config (one of cmdline, a thing fetched by the provider, or a default config, prioritized in that order).
This now takes the base config, appends the provider's base config, then appends the user config (one of cmdline, user.ign from the initramfs, a provider fetched config, or a default config, prioritized in that order).
Is that correct or am I reading it incorrectly? Is there a reason to prioritize a oem partition user.ign over a provider fetched one?
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.
Looking at this further, it might be possible to refactor the no supplied config case into this.
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.
This logic is looking for the first "online" provider, meaning that it will happily accept an empty file, or a script, or a cloud-config. The no-supplied-config case is the opposite: we successfully read zero or more bytes of data from some provider, but they weren't an Ignition config. It seems cleaner to keep the two code paths separate.
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.
And your latter reading is correct. My thinking was that if a user writes a user.ign, they are specifically asking for it to be used, so it should be a higher priority.
Read user Ignition config from the command line first, otherwise the system dir, otherwise the OEM's provider.
|
Added comment and rebased. |
ajeddeloh
left a comment
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.
LGTM, pending bootengine support
|
Good to merge. |
…b.com/coreos/ignition/v2-2.16.0 build(deps): bump github.com/coreos/ignition/v2 from 2.15.1-0.20230510033844-8b6e7f111ca5 to 2.16.0
Add a new "system config dir" (defaulting to
/usr/lib/ignitionin the initramfs) which containsbase.ignanddefault.ign. Both files are optional. Readbase.igninstead ofoem.BaseConfig()anddefault.igninstead ofoem.DefaultUserConfig(); no longer ship those configs inoem.go. This improves the distro-independence of the codebase and allows the OEM configs to be updated independently of an Ignition release.Also add an optional
user.ignin the system config dir, which is lower priority thancoreos.config.urlbut higher priority than the regular config provider. This allows tools likecoreos-installto write a user config to disk without also modifyinggrub.cfg.The idea is for bootengine to mount the OEM partition, copy the three Ignition config files into
/usr/lib/ignitionin the initramfs, unmount, and then run Ignition. That is implemented in coreos/bootengine#135.Addresses coreos/bugs#2004.