Skip to content

Commit

Permalink
Check CRD creation error instead of doing return directly (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
life1347 committed Sep 18, 2018
1 parent 6f60f3e commit a86c943
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crd/crd.go
Expand Up @@ -38,17 +38,14 @@ func ensureCRD(clientset *apiextensionsclient.Clientset, crd *apiextensionsv1bet
maxRetries := 5

for i := 0; i < maxRetries; i++ {
_, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Get(crd.ObjectMeta.Name, metav1.GetOptions{})
_, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
if err == nil {
return nil
}

if errors.IsNotFound(err) {
// crd resource not found error
_, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
if err != nil {
return err
}
// return if the resource already exists
if errors.IsAlreadyExists(err) {
return nil
} else {
// The requests fail to connect to k8s api server before
// istio-prxoy is ready to serve traffic. Retry again.
Expand Down

0 comments on commit a86c943

Please sign in to comment.