Skip to content

Commit

Permalink
Fix taking a crd that is not yet installed (#601)
Browse files Browse the repository at this point in the history
Signed-off-by: dmitry.koba <[email protected]>
Co-authored-by: dmitry.koba <[email protected]>
Co-authored-by: Yuriy Losev <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent 4e47873 commit 32dddd8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/webhook/conversion/crd_client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package conversion

import (
"context"
"fmt"
"time"

log "github.com/sirupsen/logrus"
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand All @@ -24,8 +24,12 @@ type CrdClientConfig struct {
var SupportedConversionReviewVersions = []string{"v1", "v1beta1"}

func (c *CrdClientConfig) Update() error {
client := c.KubeClient
var (
retryTimeout = 15 * time.Second
client = c.KubeClient
)

tryToGetCRD:
listOpts := metav1.ListOptions{
FieldSelector: "metadata.name=" + c.CrdName,
}
Expand All @@ -36,7 +40,9 @@ func (c *CrdClientConfig) Update() error {
}

if len(crdList.Items) == 0 {
return fmt.Errorf("crd/%s not found", c.CrdName)
log.Warnf("crd/%s not found. Will try to find it later", c.CrdName)
time.Sleep(retryTimeout)
goto tryToGetCRD
}

crd := crdList.Items[0]
Expand Down

0 comments on commit 32dddd8

Please sign in to comment.