Skip to content

Commit

Permalink
engine: fix provider config precedence
Browse files Browse the repository at this point in the history
Regression from coreos#958. We switched the list of providers from an array to
a map. But iteration order through a map is undefined, so we lost the
precedence of providers.

I think this is the cause behind a lot of the FCOS installer test
timeouts, such as:

coreos/coreos-assembler#1597

There, we pass the Ignition config for the PXE boot via
`ignition.config.url`, but if the metal (no-op) fetcher appears earlier
than the `cmdline` fetcher, we get no config. And similarly for the
installed system when the no-op fetcher appears before the `system`
fetcher (which coreos-installer's `--ignition-file` leverages).

The likelihood of this happening increased in the v2.4.0 release due to
coreos#1002, which only gave us one try
to iterate over the correct provider first (at the `fetch` stage),
rather than every stage having a go at it.

Closes: coreos/coreos-assembler#1597
  • Loading branch information
jlebon committed Jul 16, 2020
1 parent 61565b0 commit d6eabed
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/exec/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,25 @@ func (e *Engine) acquireProviderConfig() (cfg types.Config, err error) {
// is unavailable. This will also render the config (see renderConfig) before
// returning.
func (e *Engine) fetchProviderConfig() (types.Config, error) {
fetchers := map[string]providers.FuncFetchConfig{
"cmdline": cmdline.FetchConfig,
"system": system.FetchConfig,
e.PlatformConfig.Name(): e.PlatformConfig.FetchFunc(),
// note this is an array because iteration order is important; see comment
// block just above
fetchers := []struct {
name string
fetchFunc providers.FuncFetchConfig
}{
{"cmdline", cmdline.FetchConfig},
{"system", system.FetchConfig},
{e.PlatformConfig.Name(), e.PlatformConfig.FetchFunc()},
}
var cfg types.Config
var r report.Report
var err error
var providerKey string
for key, fetcher := range fetchers {
cfg, r, err = fetcher(e.Fetcher)
for _, fetcher := range fetchers {
cfg, r, err = fetcher.fetchFunc(e.Fetcher)
if err != providers.ErrNoProvider {
// successful, or failed on another error
providerKey = key
providerKey = fetcher.name
break
}
}
Expand Down

0 comments on commit d6eabed

Please sign in to comment.