Check for all errors in CRI connection validation

We only have one CRI API (v1) to validate during the initial connection
of the kubelet with the container runtime. Therefore we can now verify
all kind of GRPC related issues.

Fixes: https://github.com/kubernetes/kubernetes/issues/114956

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
Sascha Grunert 2023-01-16 10:21:08 +01:00
parent 4c4d4ad0a4
commit e89547d308
No known key found for this signature in database
GPG Key ID: 09D97D153EF94D93
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
}