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

Support CRI v1 API #1011

Merged
merged 1 commit into from
Dec 6, 2022
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
47 changes: 31 additions & 16 deletions cmd/containerd-stargz-grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials/insecure"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/stargz-snapshotter/service/keychain/crialpha"
)

const (
Expand Down Expand Up @@ -152,28 +154,24 @@ func main() {
criAddr = cp
}
connectCRI := func() (runtime.ImageServiceClient, error) {
// TODO: make gRPC options configurable from config.toml
backoffConfig := backoff.DefaultConfig
backoffConfig.MaxDelay = 3 * time.Second
connParams := grpc.ConnectParams{
Backoff: backoffConfig,
}
gopts := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithConnectParams(connParams),
grpc.WithContextDialer(dialer.ContextDialer),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize)),
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)),
}
conn, err := grpc.Dial(dialer.DialAddress(criAddr), gopts...)
conn, err := newCRIConn(criAddr)
if err != nil {
return nil, err
}
return runtime.NewImageServiceClient(conn), nil
}
connectAlphaCRI := func() (runtime_alpha.ImageServiceClient, error) {
conn, err := newCRIConn(criAddr)
if err != nil {
return nil, err
}
return runtime_alpha.NewImageServiceClient(conn), nil
}
f, criServer := cri.NewCRIKeychain(ctx, connectCRI)
fAlpha, criAlphaServer := crialpha.NewCRIAlphaKeychain(ctx, connectAlphaCRI)
runtime.RegisterImageServiceServer(rpc, criServer)
credsFuncs = append(credsFuncs, f)
runtime_alpha.RegisterImageServiceServer(rpc, criAlphaServer)
credsFuncs = append(credsFuncs, f, fAlpha)
}
fsOpts := []fs.Option{fs.WithMetricsLogLevel(logrus.InfoLevel)}
if config.IPFS {
Expand Down Expand Up @@ -313,3 +311,20 @@ func getMetadataStore(rootDir string, config snapshotterConfig) (metadata.Store,
config.MetadataStore, memoryMetadataType, dbMetadataType)
}
}

func newCRIConn(criAddr string) (*grpc.ClientConn, error) {
// TODO: make gRPC options configurable from config.toml
backoffConfig := backoff.DefaultConfig
backoffConfig.MaxDelay = 3 * time.Second
connParams := grpc.ConnectParams{
Backoff: backoffConfig,
}
gopts := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithConnectParams(connParams),
grpc.WithContextDialer(dialer.ContextDialer),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize)),
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)),
}
return grpc.Dial(dialer.DialAddress(criAddr), gopts...)
}
10 changes: 5 additions & 5 deletions cmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/containerd/stargz-snapshotter/cmd
go 1.16

require (
github.com/containerd/containerd v1.6.10
github.com/containerd/containerd v1.7.0-beta.0.0.20221118211334-792294ce06bf
github.com/containerd/go-cni v1.1.7
github.com/containerd/stargz-snapshotter v0.13.0
github.com/containerd/stargz-snapshotter/estargz v0.13.0
Expand All @@ -16,17 +16,17 @@ require (
github.com/ipfs/interface-go-ipfs-core v0.7.0
github.com/klauspost/compress v1.15.12
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/pelletier/go-toml v1.9.5
github.com/rs/xid v1.4.0
github.com/sirupsen/logrus v1.9.0
github.com/urfave/cli v1.22.5
github.com/urfave/cli v1.22.9
go.etcd.io/bbolt v1.3.6
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sync v0.1.0
golang.org/x/sys v0.2.0
google.golang.org/grpc v1.50.1
k8s.io/cri-api v0.26.0-alpha.3
k8s.io/cri-api v0.27.0-alpha.0
)

replace (
Expand Down
600 changes: 567 additions & 33 deletions cmd/go.sum

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ go 1.16

require (
github.com/containerd/console v1.0.3
github.com/containerd/containerd v1.6.10
github.com/containerd/containerd v1.7.0-beta.0.0.20221118211334-792294ce06bf
github.com/containerd/continuity v0.3.0
github.com/containerd/stargz-snapshotter/estargz v0.13.0
github.com/docker/cli v20.10.21+incompatible
github.com/docker/docker v20.10.7+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/go-metrics v0.0.1
github.com/gogo/protobuf v1.3.2
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
github.com/hanwen/go-fuse/v2 v2.1.1-0.20220112183258-f57e95bda82d
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/klauspost/compress v1.15.12
github.com/moby/sys/mountinfo v0.6.2
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/prometheus/client_golang v1.14.0
github.com/rs/xid v1.4.0
github.com/sirupsen/logrus v1.9.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sync v0.1.0
golang.org/x/sys v0.2.0
google.golang.org/grpc v1.50.1
k8s.io/api v0.25.4
k8s.io/apimachinery v0.25.4
k8s.io/client-go v0.25.4
k8s.io/cri-api v0.26.0-alpha.3
k8s.io/cri-api v0.27.0-alpha.0
)

replace (
Expand Down
Loading