Skip to content

Commit 00c9785

Browse files
committed
fix "host-gateway-ip" label not set for builder workers
Commit 21e50b8 added a label on the buildkit worker to advertise the host-gateway-ip. This option can be either set by the user in the daemon config, or otherwise defaults to the gateway-ip. If no value is set by the user, discovery of the gateway-ip happens when initializing the network-controller (`NewDaemon`, `daemon.restore()`). However d222bf0 changed how we handle the daemon config. As a result, the `cli.Config` used when initializing the builder only holds configuration information form the daemon config (user-specified or defaults), but is not updated with information set by `NewDaemon`. This patch adds an accessor on the daemon to get the current daemon config. An alternative could be to return the config by `NewDaemon` (which should likely be a _copy_ of the config). Before this patch: docker buildx inspect default Name: default Driver: docker Nodes: Name: default Endpoint: default Status: running Buildkit: v0.12.4+3b6880d2a00f Platforms: linux/arm64, linux/amd64, linux/amd64/v2, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6 Labels: org.mobyproject.buildkit.worker.moby.host-gateway-ip: <nil> After this patch: docker buildx inspect default Name: default Driver: docker Nodes: Name: default Endpoint: default Status: running Buildkit: v0.12.4+3b6880d2a00f Platforms: linux/arm64, linux/amd64, linux/amd64/v2, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6 Labels: org.mobyproject.buildkit.worker.moby.host-gateway-ip: 172.18.0.1 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 1786517 commit 00c9785

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

cmd/dockerd/daemon.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,13 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
301301
routerCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
302302
defer cancel()
303303

304-
routerOptions, err := newRouterOptions(routerCtx, cli.Config, d)
304+
// Get a the current daemon config, because the daemon sets up config
305+
// during initialization. We cannot user the cli.Config for that reason,
306+
// as that only holds the config that was set by the user.
307+
//
308+
// FIXME(thaJeztah): better separate runtime and config data?
309+
daemonCfg := d.Config()
310+
routerOptions, err := newRouterOptions(routerCtx, &daemonCfg, d)
305311
if err != nil {
306312
return err
307313
}

daemon/daemon.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ func (daemon *Daemon) config() *configStore {
180180
return cfg
181181
}
182182

183+
// Config returns daemon's config.
184+
func (daemon *Daemon) Config() config.Config {
185+
return daemon.config().Config
186+
}
187+
183188
// HasExperimental returns whether the experimental features of the daemon are enabled or not
184189
func (daemon *Daemon) HasExperimental() bool {
185190
return daemon.config().Experimental

0 commit comments

Comments
 (0)