Skip to content

Conversation

@bgilbert
Copy link
Contributor

@bgilbert bgilbert commented Nov 16, 2017

Add a new "system config dir" (defaulting to /usr/lib/ignition in the initramfs) which contains base.ign and default.ign. Both files are optional. Read base.ign instead of oem.BaseConfig() and default.ign instead of oem.DefaultUserConfig(); no longer ship those configs in oem.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.ign in the system config dir, which is lower priority than coreos.config.url but higher priority than the regular config provider. This allows tools like coreos-install to write a user config to disk without also modifying grub.cfg.

The idea is for bootengine to mount the OEM partition, copy the three Ignition config files into /usr/lib/ignition in the initramfs, unmount, and then run Ignition. That is implemented in coreos/bootengine#135.

Addresses coreos/bugs#2004.

@arithx
Copy link
Contributor

arithx commented Nov 17, 2017

@bgilbert what should happen in the event that no configuration is found? I added a test locally that calls makePreemptTest("") which still passes.

Is this something where we should bubble out a warning/error to the user saying "Ignition couldn't find any configs"?

@bgilbert
Copy link
Contributor Author

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.

@bgilbert
Copy link
Contributor Author

Updated.

@ajeddeloh
Copy link
Contributor

GH mangles commit order. Can you post the actual commit order?

@bgilbert
Copy link
Contributor Author

In this case it should be the same as in GitHub's list:

exec: move baseConfig to top of Run for clarity
internal/*: read base and default configs from initramfs
internal/*: allow putting user config in system dir
internal/oem: drop hardcoded base and default configs
tests: test system configs and preemption
doc/development: document OEMLookasideFiles and SystemDirFiles

Instead of hardcoding them in Ignition, expect the distro to put them
in /usr/lib/ignition (by default).
@bgilbert
Copy link
Contributor Author

bgilbert commented Dec 4, 2017

This is ready for review.

Copy link
Contributor

@arithx arithx left a 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 {
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@bgilbert
Copy link
Contributor Author

bgilbert commented Dec 5, 2017

Added comment and rebased.

Copy link
Contributor

@ajeddeloh ajeddeloh left a 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

@bgilbert
Copy link
Contributor Author

bgilbert commented Dec 6, 2017

Good to merge.

@cgonyeo cgonyeo merged commit 6f7aceb into coreos:master Dec 6, 2017
@bgilbert bgilbert deleted the external-oem-configs branch December 6, 2017 23:17
prestist pushed a commit to prestist/ignition that referenced this pull request Jan 12, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants