diff --git a/util/certificate/csr/csr.go b/util/certificate/csr/csr.go index 1cd996c02..6f99dcd24 100644 --- a/util/certificate/csr/csr.go +++ b/util/certificate/csr/csr.go @@ -178,14 +178,14 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName fieldSelector := fields.OneTermEqualSelector("metadata.name", reqName).String() logger := klog.FromContext(ctx) - var lw *cache.ListWatch + var lw cache.ListerWatcher var obj runtime.Object for { // see if the v1 API is available if _, err := client.CertificatesV1().CertificateSigningRequests().List(ctx, metav1.ListOptions{FieldSelector: fieldSelector}); err == nil { // watch v1 objects obj = &certificatesv1.CertificateSigningRequest{} - lw = &cache.ListWatch{ + lw = cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { options.FieldSelector = fieldSelector return client.CertificatesV1().CertificateSigningRequests().List(ctx, options) @@ -194,7 +194,7 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName options.FieldSelector = fieldSelector return client.CertificatesV1().CertificateSigningRequests().Watch(ctx, options) }, - } + }, client) break } else { logger.V(2).Info("Error fetching v1 certificate signing request", "err", err) @@ -209,7 +209,7 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName if _, err := client.CertificatesV1beta1().CertificateSigningRequests().List(ctx, metav1.ListOptions{FieldSelector: fieldSelector}); err == nil { // watch v1beta1 objects obj = &certificatesv1beta1.CertificateSigningRequest{} - lw = &cache.ListWatch{ + lw = cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { options.FieldSelector = fieldSelector return client.CertificatesV1beta1().CertificateSigningRequests().List(ctx, options) @@ -218,7 +218,7 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName options.FieldSelector = fieldSelector return client.CertificatesV1beta1().CertificateSigningRequests().Watch(ctx, options) }, - } + }, client) break } else { logger.V(2).Info("Error fetching v1beta1 certificate signing request", "err", err)