Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Commit

Permalink
Don't hang when cert request gets deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Apr 3, 2021
1 parent 365138c commit 0a91509
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions certreq.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"io/ioutil"
certificates "k8s.io/api/certificates/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"log"
Expand Down Expand Up @@ -103,6 +104,10 @@ func requestCertificate(client kubernetes.Interface, labels map[string]string, d

for {
csr, err := client.CertificatesV1beta1().CertificateSigningRequests().Get(context.TODO(), certificateSigningRequestName, metaV1.GetOptions{})
if errors.IsNotFound(err) {
// If the request got deleted, waiting won't help.
log.Fatalf("certificate signing request (%s) not found", certificateSigningRequestName)
}
if err != nil {
log.Printf("unable to retrieve certificate signing request (%s): %s", certificateSigningRequestName, err)
time.Sleep(5 * time.Second)
Expand Down

0 comments on commit 0a91509

Please sign in to comment.