Skip to content

Commit

Permalink
Updates for containerd 2.0 interface changes
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
dmcgowan committed Feb 7, 2024
1 parent eb88ea9 commit d3986e5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
8 changes: 4 additions & 4 deletions cmd/buildkitd/main_containerd_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/containerd/containerd/v2/defaults"
runtimeoptions "github.com/containerd/containerd/v2/pkg/runtimeoptions/v1"
"github.com/containerd/containerd/v2/pkg/userns"
"github.com/containerd/plugin"
"github.com/containerd/containerd/v2/plugins"
"github.com/moby/buildkit/cmd/buildkitd/config"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/network/cniprovider"
Expand Down Expand Up @@ -122,7 +122,7 @@ func init() {
cli.StringFlag{
Name: "containerd-worker-snapshotter",
Usage: "snapshotter name to use",
Value: ctd.DefaultSnapshotter,
Value: defaults.DefaultSnapshotter,
},
cli.StringFlag{
Name: "containerd-worker-apparmor-profile",
Expand Down Expand Up @@ -304,7 +304,7 @@ func containerdWorkerInitializer(c *cli.Context, common workerInitializerOpt) ([
parallelismSem = semaphore.NewWeighted(int64(cfg.MaxParallelism))
}

snapshotter := ctd.DefaultSnapshotter
snapshotter := defaults.DefaultSnapshotter
if cfg.Snapshotter != "" {
snapshotter = cfg.Snapshotter
}
Expand Down Expand Up @@ -377,7 +377,7 @@ func validContainerdSocket(cfg config.ContainerdConfig) bool {
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
func getRuntimeOptionsType(t string) interface{} {
switch t {
case plugin.RuntimeRuncV2:
case plugins.RuntimeRuncV2:
return &runcoptions.Options{}
case runtimeRunhcsV1:
return &runhcsoptions.Options{}
Expand Down
6 changes: 3 additions & 3 deletions session/auth/authprovider/authprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ func (ap *authProvider) FetchToken(ctx context.Context, req *auth.FetchTokenRequ
if err != nil {
return nil, err
}
return toTokenResponse(resp.Token, resp.IssuedAt, resp.ExpiresIn), nil
return toTokenResponse(resp.Token, resp.IssuedAt, resp.ExpiresInSeconds), nil
}
}
return nil, err
}
return toTokenResponse(resp.AccessToken, resp.IssuedAt, resp.ExpiresIn), nil
return toTokenResponse(resp.AccessToken, resp.IssuedAt, resp.ExpiresInSeconds), nil
}
// do request anonymously
resp, err := authutil.FetchToken(ctx, httpClient, nil, to)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch anonymous token")
}
return toTokenResponse(resp.Token, resp.IssuedAt, resp.ExpiresIn), nil
return toTokenResponse(resp.Token, resp.IssuedAt, resp.ExpiresInSeconds), nil
}

func (ap *authProvider) tlsConfig(host string) (*tls.Config, error) {
Expand Down
4 changes: 1 addition & 3 deletions util/overlay/overlay_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"strings"
"sync"
"syscall"
"time"

"github.com/containerd/containerd/v2/core/mount"
"github.com/containerd/containerd/v2/pkg/archive"
Expand Down Expand Up @@ -127,8 +126,7 @@ func WriteUpperdir(ctx context.Context, w io.Writer, upperdir string, lower []mo
}
return mount.WithTempMount(ctx, lower, func(lowerRoot string) error {
return mount.WithTempMount(ctx, upperView, func(upperViewRoot string) error {
// WithWhiteoutTime(0) will no longer need to be specified when https://github.com/containerd/containerd/pull/8764 gets merged
cw := archive.NewChangeWriter(&cancellableWriter{ctx, w}, upperViewRoot, archive.WithWhiteoutTime(time.Unix(0, 0).UTC()))
cw := archive.NewChangeWriter(&cancellableWriter{ctx, w}, upperViewRoot)
if err := Changes(ctx, cw.HandleChange, upperdir, upperViewRoot, lowerRoot); err != nil {
if err2 := cw.Close(); err2 != nil {
return errors.Wrapf(err, "failed to record upperdir changes (close error: %v)", err2)
Expand Down
18 changes: 9 additions & 9 deletions util/resolver/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ func (ah *authHandler) fetchToken(ctx context.Context, sm *session.Manager, g se
if err != nil {
return nil, err
}
if resp.ExpiresIn == 0 {
resp.ExpiresIn = defaultExpiration
if resp.ExpiresInSeconds == 0 {
resp.ExpiresInSeconds = defaultExpiration
}
issuedAt, expires = resp.IssuedAt, resp.ExpiresIn
issuedAt, expires = resp.IssuedAt, resp.ExpiresInSeconds
token = resp.AccessToken
return nil, nil
}
Expand All @@ -400,10 +400,10 @@ func (ah *authHandler) fetchToken(ctx context.Context, sm *session.Manager, g se
}
return nil, err
}
if resp.ExpiresIn == 0 {
resp.ExpiresIn = defaultExpiration
if resp.ExpiresInSeconds == 0 {
resp.ExpiresInSeconds = defaultExpiration
}
issuedAt, expires = resp.IssuedAt, resp.ExpiresIn
issuedAt, expires = resp.IssuedAt, resp.ExpiresInSeconds
token = resp.Token
return nil, nil
}
Expand All @@ -412,10 +412,10 @@ func (ah *authHandler) fetchToken(ctx context.Context, sm *session.Manager, g se
if err != nil {
return nil, errors.Wrap(err, "failed to fetch anonymous token")
}
if resp.ExpiresIn == 0 {
resp.ExpiresIn = defaultExpiration
if resp.ExpiresInSeconds == 0 {
resp.ExpiresInSeconds = defaultExpiration
}
issuedAt, expires = resp.IssuedAt, resp.ExpiresIn
issuedAt, expires = resp.IssuedAt, resp.ExpiresInSeconds

token = resp.Token
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion worker/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewWorkerOpt(
parallelismSem *semaphore.Weighted,
traceSocket string,
runtime *RuntimeInfo,
opts ...containerd.ClientOpt,
opts ...containerd.Opt,
) (base.WorkerOpt, error) {
opts = append(opts, containerd.WithDefaultNamespace(ns))

Expand Down

0 comments on commit d3986e5

Please sign in to comment.