Skip to content

Commit

Permalink
Merge pull request #45791 from crazy-max/23.0_backport_fix-host-gateway
Browse files Browse the repository at this point in the history
[23.0 backport] builder: pass host-gateway IP as worker label
  • Loading branch information
neersighted committed Jun 23, 2023
2 parents 17219db + 40dbcd6 commit f00569b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions builder/builder-next/controller.go
Expand Up @@ -17,6 +17,7 @@ import (
containerimageexp "github.com/docker/docker/builder/builder-next/exporter"
"github.com/docker/docker/builder/builder-next/imagerefchecker"
mobyworker "github.com/docker/docker/builder/builder-next/worker"
wlabel "github.com/docker/docker/builder/builder-next/worker/label"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/daemon/graphdriver"
units "github.com/docker/go-units"
Expand Down Expand Up @@ -204,6 +205,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
Transport: rt,
Layers: layers,
Platforms: archutil.SupportedPlatforms(true),
Labels: getLabels(opt, nil),
}

wc := &worker.Controller{}
Expand Down Expand Up @@ -286,3 +288,11 @@ func getEntitlements(conf config.BuilderConfig) []string {
}
return ents
}

func getLabels(opt Opt, labels map[string]string) map[string]string {
if labels == nil {
labels = make(map[string]string)
}
labels[wlabel.HostGatewayIP] = opt.DNSConfig.HostGatewayIP.String()
return labels
}
9 changes: 9 additions & 0 deletions builder/builder-next/worker/label/label.go
@@ -0,0 +1,9 @@
package label

// Pre-defined label keys similar to BuildKit ones
// https://github.com/moby/buildkit/blob/v0.11.6/worker/label/label.go#L3-L16
const (
prefix = "org.mobyproject.buildkit.worker.moby."

HostGatewayIP = prefix + "host-gateway-ip"
)

0 comments on commit f00569b

Please sign in to comment.