Skip to content

Commit e9e142d

Browse files
committed
fix restclient creation issue
1 parent 8195b82 commit e9e142d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/clustercache/cluster_accessor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import (
2727
apierrors "k8s.io/apimachinery/pkg/api/errors"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/apimachinery/pkg/runtime"
30+
"k8s.io/apimachinery/pkg/runtime/serializer"
3031
"k8s.io/apimachinery/pkg/util/sets"
32+
"k8s.io/client-go/kubernetes/scheme"
3133
"k8s.io/client-go/rest"
3234
ctrl "sigs.k8s.io/controller-runtime"
3335
"sigs.k8s.io/controller-runtime/pkg/cache"
@@ -349,7 +351,10 @@ func (ca *clusterAccessor) HealthCheck(ctx context.Context) (bool, bool) {
349351
_, err := restClient.Get().AbsPath("/").Timeout(ca.config.HealthProbe.Timeout).DoRaw(ctx)
350352
if err == nil {
351353
// Execute health probe with a new restClient (this verifies that a new connection works).
352-
restClient, err = rest.UnversionedRESTClientFor(restConfig)
354+
codec := runtime.NoopEncoder{Decoder: scheme.Codecs.UniversalDecoder()}
355+
restClientConfig := rest.CopyConfig(restConfig)
356+
restClientConfig.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec})
357+
restClient, err = rest.UnversionedRESTClientFor(restClientConfig)
353358
if err == nil {
354359
_, err = restClient.Get().AbsPath("/").Timeout(ca.config.HealthProbe.Timeout).DoRaw(ctx)
355360
}

0 commit comments

Comments
 (0)