Merge pull request #115102 from saschagrunert/cri-unavailable

Check for all errors in CRI connection validation
This commit is contained in:
Kubernetes Prow Robot 2023-01-24 02:24:17 -08:00 committed by GitHub
commit a12dd4189e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 12 deletions

View File

@ -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"
@ -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
}

View File

@ -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
}