Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-6911: Allow concurrent builds #109

Merged
merged 1 commit into from
Jul 6, 2023
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
36 changes: 20 additions & 16 deletions pkg/buildkit/buildkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ var clientCheckBackoff = wait.Backoff{ // retries after 500ms 1s 2s 4s 8s 16s 32
}

type ClientBuilder struct {
addr string
dockerAuthConfig string
log logr.Logger
bkOpts []bkclient.ClientOpt
addr string
dockerConfigDir string
log logr.Logger
bkOpts []bkclient.ClientOpt
}

func NewClientBuilder(addr string) *ClientBuilder {
return &ClientBuilder{addr: addr, log: logr.Discard()}
}

func (b *ClientBuilder) WithDockerAuthConfig(configDir string) *ClientBuilder {
b.dockerAuthConfig = configDir
func (b *ClientBuilder) WithDockerConfigDir(configDir string) *ClientBuilder {
b.dockerConfigDir = configDir
return b
}

Expand Down Expand Up @@ -89,9 +89,9 @@ func (b *ClientBuilder) Build(ctx context.Context) (*Client, error) {
b.log.Info("Buildkitd connectivity established")

return &Client{
bk: bk,
log: b.log,
dockerAuthConfig: b.dockerAuthConfig,
bk: bk,
log: b.log,
dockerConfigDir: b.dockerConfigDir,
}, nil
}

Expand All @@ -114,9 +114,9 @@ type Buildkit interface {
}

type Client struct {
bk *bkclient.Client
log logr.Logger
dockerAuthConfig string
bk *bkclient.Client
log logr.Logger
dockerConfigDir string
}

func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
Expand All @@ -132,8 +132,10 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
}
}(buildDir)

config.SetDir(c.dockerAuthConfig)
dockerConfig := config.LoadDefaultConfigFile(os.Stderr)
dockerConfig, err := config.Load(c.dockerConfigDir)
if err != nil {
c.log.Error(err, "Error loading config file")
}

// process build context
var contentsDir string
Expand Down Expand Up @@ -293,8 +295,10 @@ func (c *Client) solveWith(ctx context.Context, modify func(buildDir string, sol
}
}(buildDir)

config.SetDir(c.dockerAuthConfig)
dockerConfig := config.LoadDefaultConfigFile(os.Stderr)
dockerConfig, err := config.Load(c.dockerConfigDir)
if err != nil {
c.log.Error(err, "Error loading config file")
}
solveOpt := bkclient.SolveOpt{
Frontend: "dockerfile.v0",
FrontendAttrs: map[string]string{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/imagebuild/component/builddispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (c *BuildDispatcherComponent) Reconcile(ctx *core.Context) (ctrl.Result, er
bldr := buildkit.
NewClientBuilder(addr).
WithLogger(ctx.Log.WithName("buildkit").WithValues("addr", addr, "logKey", obj.Spec.LogKey)).
WithDockerAuthConfig(configDir)
WithDockerConfigDir(configDir)
if mtls := c.cfg.MTLS; mtls != nil {
bldr.WithMTLSAuth(mtls.CACertPath, mtls.CertPath, mtls.KeyPath)
}
Expand Down