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

Check for all errors in CRI connection validation #115102

Merged
merged 1 commit into from Jan 24, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions pkg/kubelet/cri/remote/remote_image.go
Expand Up @@ -25,9 +25,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
utilfeature "k8s.io/apiserver/pkg/util/feature"
tracing "k8s.io/component-base/tracing"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -93,13 +91,11 @@ func (r *remoteImageService) validateServiceConnection(ctx context.Context, conn
klog.V(4).InfoS("Validating the CRI v1 API image version")
r.imageClient = runtimeapi.NewImageServiceClient(conn)

if _, err := r.imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{}); err == nil {
klog.V(2).InfoS("Validated CRI v1 image API")

} else if status.Code(err) == codes.Unimplemented {
return fmt.Errorf("CRI v1 image API is not implemented for endpoint %q: %w", endpoint, err)
if _, err := r.imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{}); err != nil {
return fmt.Errorf("validate CRI v1 image API for endpoint %q: %w", endpoint, err)
}

klog.V(2).InfoS("Validated CRI v1 image API")
return nil
}

Expand Down
8 changes: 3 additions & 5 deletions pkg/kubelet/cri/remote/remote_runtime.go
Expand Up @@ -117,13 +117,11 @@ func (r *remoteRuntimeService) validateServiceConnection(ctx context.Context, co
klog.V(4).InfoS("Validating the CRI v1 API runtime version")
r.runtimeClient = runtimeapi.NewRuntimeServiceClient(conn)

if _, err := r.runtimeClient.Version(ctx, &runtimeapi.VersionRequest{}); err == nil {
klog.V(2).InfoS("Validated CRI v1 runtime API")

} else if status.Code(err) == codes.Unimplemented {
return fmt.Errorf("CRI v1 runtime API is not implemented for endpoint %q: %w", endpoint, err)
if _, err := r.runtimeClient.Version(ctx, &runtimeapi.VersionRequest{}); err != nil {
return fmt.Errorf("validate CRI v1 runtime API for endpoint %q: %w", endpoint, err)
}

klog.V(2).InfoS("Validated CRI v1 runtime API")
return nil
}

Expand Down