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

Remove CRI Alpha API #1175

Merged
merged 1 commit into from
Mar 28, 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
13 changes: 1 addition & 12 deletions cmd/containerd-stargz-grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ import (
"github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/sys"
runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
dbmetadata "github.com/containerd/stargz-snapshotter/cmd/containerd-stargz-grpc/db"
ipfs "github.com/containerd/stargz-snapshotter/cmd/containerd-stargz-grpc/ipfs"
"github.com/containerd/stargz-snapshotter/fs"
"github.com/containerd/stargz-snapshotter/metadata"
memorymetadata "github.com/containerd/stargz-snapshotter/metadata/memory"
"github.com/containerd/stargz-snapshotter/service"
"github.com/containerd/stargz-snapshotter/service/keychain/cri"
"github.com/containerd/stargz-snapshotter/service/keychain/crialpha"
"github.com/containerd/stargz-snapshotter/service/keychain/dockerconfig"
"github.com/containerd/stargz-snapshotter/service/keychain/kubeconfig"
"github.com/containerd/stargz-snapshotter/service/resolver"
Expand Down Expand Up @@ -160,18 +158,9 @@ func main() {
}
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)
runtime_alpha.RegisterImageServiceServer(rpc, criAlphaServer)
credsFuncs = append(credsFuncs, f, fAlpha)
credsFuncs = append(credsFuncs, f)
}
fsOpts := []fs.Option{fs.WithMetricsLogLevel(logrus.InfoLevel)}
if config.IPFS {
Expand Down
155 changes: 0 additions & 155 deletions service/keychain/crialpha/crialpha.go

This file was deleted.

48 changes: 2 additions & 46 deletions service/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,8 @@

package plugin

import (
"context"
"time"

"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/pkg/dialer"
grpc "google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials/insecure"

runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
"github.com/containerd/stargz-snapshotter/service/keychain/crialpha"
"github.com/containerd/stargz-snapshotter/service/plugincore"
"github.com/containerd/stargz-snapshotter/service/resolver"
)
import "github.com/containerd/stargz-snapshotter/service/plugincore"

func init() {
plugincore.RegisterPlugin(registerCRIAlphaServer)
}

func registerCRIAlphaServer(ctx context.Context, criAddr string, rpc *grpc.Server) resolver.Credential {
connectAlphaCRI := func() (runtime_alpha.ImageServiceClient, error) {
conn, err := newCRIConn(criAddr)
if err != nil {
return nil, err
}
return runtime_alpha.NewImageServiceClient(conn), nil
}
criAlphaCreds, criAlphaServer := crialpha.NewCRIAlphaKeychain(ctx, connectAlphaCRI)
runtime_alpha.RegisterImageServiceServer(rpc, criAlphaServer)
return criAlphaCreds
}

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...)
plugincore.RegisterPlugin()
}
6 changes: 2 additions & 4 deletions service/plugincore/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package plugincore

import (
"context"
"errors"
"fmt"
"net"
Expand Down Expand Up @@ -55,7 +54,7 @@ type Config struct {
Registry resolver.Registry `toml:"registry"`
}

func RegisterPlugin(registerCRIAlphaServer func(ctx context.Context, criAddr string, rpc *grpc.Server) resolver.Credential) {
func RegisterPlugin() {
ctdplugin.Register(&ctdplugin.Registration{
Type: ctdplugin.SnapshotPlugin,
ID: "stargz",
Expand Down Expand Up @@ -104,7 +103,6 @@ func RegisterPlugin(registerCRIAlphaServer func(ctx context.Context, criAddr str
// Create a gRPC server
rpc := grpc.NewServer()
runtime.RegisterImageServiceServer(rpc, criServer)
criAlphaCreds := registerCRIAlphaServer(ctx, criAddr, rpc)
// Prepare the directory for the socket
if err := os.MkdirAll(filepath.Dir(addr), 0700); err != nil {
return nil, fmt.Errorf("failed to create directory %q: %w", filepath.Dir(addr), err)
Expand All @@ -123,7 +121,7 @@ func RegisterPlugin(registerCRIAlphaServer func(ctx context.Context, criAddr str
log.G(ctx).WithError(err).Warnf("error on serving via socket %q", addr)
}
}()
credsFuncs = append(credsFuncs, criAlphaCreds, criCreds)
credsFuncs = append(credsFuncs, criCreds)
}

// TODO(ktock): print warn if old configuration is specified.
Expand Down