Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions internal/providers/cloudstack/cloudstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ const (
)

func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
// The fetch-offline approach doesn't work well here because of the "split
// personality" of this provider. See:
// https://github.com/coreos/ignition/issues/1081
if f.Offline {
return types.Config{}, report.Report{}, resource.ErrNeedNet
}

var data []byte
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)

sawErrNeedNet := false

dispatch := func(name string, fn func() ([]byte, error)) {
raw, err := fn()
if err != nil {
switch err {
case context.Canceled:
case context.DeadlineExceeded:
f.Logger.Err("timed out while fetching config from %s", name)
case resource.ErrNeedNet:
sawErrNeedNet = true
fallthrough
default:
f.Logger.Err("failed to fetch config from %s: %v", name, err)
}
Expand All @@ -86,11 +88,6 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {

<-ctx.Done()
if ctx.Err() == context.DeadlineExceeded {
// Did we hit neednet? If so, propagate that up instead. The OS should
// retry fetching again once networking is up.
if sawErrNeedNet {
return types.Config{}, report.Report{}, resource.ErrNeedNet
}
f.Logger.Info("neither config drive nor metadata service were available in time. Continuing without a config...")
}

Expand Down
17 changes: 7 additions & 10 deletions internal/providers/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,23 @@ var (
)

func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
// The fetch-offline approach doesn't work well here because of the "split
// personality" of this provider. See:
// https://github.com/coreos/ignition/issues/1081
if f.Offline {
return types.Config{}, report.Report{}, resource.ErrNeedNet
}

var data []byte
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)

sawErrNeedNet := false

dispatch := func(name string, fn func() ([]byte, error)) {
raw, err := fn()
if err != nil {
switch err {
case context.Canceled:
case context.DeadlineExceeded:
f.Logger.Err("timed out while fetching config from %s", name)
case resource.ErrNeedNet:
sawErrNeedNet = true
fallthrough
default:
f.Logger.Err("failed to fetch config from %s: %v", name, err)
}
Expand All @@ -91,11 +93,6 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {

<-ctx.Done()
if ctx.Err() == context.DeadlineExceeded {
// Did we hit neednet? If so, propagate that up instead. The OS should
// retry fetching again once networking is up.
if sawErrNeedNet {
return types.Config{}, report.Report{}, resource.ErrNeedNet
}
f.Logger.Info("neither config drive nor metadata service were available in time. Continuing without a config...")
}

Expand Down