Skip to content

Recover from default bridge init failure#49292

Merged
thaJeztah merged 1 commit intomoby:masterfrom
robmry:bridge_startup_error
Jan 18, 2025
Merged

Recover from default bridge init failure#49292
thaJeztah merged 1 commit intomoby:masterfrom
robmry:bridge_startup_error

Conversation

@robmry
Copy link
Copy Markdown
Contributor

@robmry robmry commented Jan 17, 2025

- What I did

If a bridge network can't be restored from the store on startup, then it's deleted, the daemon and bridge driver get out of step. If that happens to the default bridge, the daemon can't recover, it won't start again.

See the issue for more detailed description/analysis.

The ipvlan/macvlan/overlay network drivers don't seem to be affected by an equivalent issue.

This is a very long standing issue, but perhaps provoked by the checks on kernel module loading added in 27.x. (The version label on the PR is arbitrary, just something-old.)

- How I did it

When deleting a network the bridge driver doesn't know about, make sure it's not still lurking in the data store.

- How to verify it

New tests.

- Description for the changelog

- Fixed an issue that could persistently prevent daemon startup after failure to initialize the default bridge.

@robmry robmry force-pushed the bridge_startup_error branch from 3aac22d to 22c0221 Compare January 17, 2025 21:56
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread testutil/daemon/daemon.go
Comment on lines +846 to +855
// SetEnvVar updates the set of extra env variables for the daemon, to take
// effect on the next start/restart.
func (d *Daemon) SetEnvVar(name, val string) {
prefix := name + "="
if idx := slices.IndexFunc(d.extraEnv, func(ev string) bool { return strings.HasPrefix(ev, prefix) }); idx > 0 {
d.extraEnv[idx] = prefix + val
return
}
d.extraEnv = append(d.extraEnv, prefix+val)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sane for now, but I went looking "didn't we already have an options for this?", but that can only be used on daemon.New();

d := daemon.New(t, daemon.WithEnvVars(...)

and daemon.Start() doesn't take options as argument; perhaps we should consider making it accept Options, so that we can customise (some at least) daemon settings between restarts without having to create a new daemon.

Or perhaps a StartWithOptions() if we don't want to replace the existing one (which takes command-line arguments only)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error initializing Docker network controller: Conflict with existing bridge network docker0

2 participants