Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease CRD setup API calls when starting cilium-agent #10676

Merged
merged 2 commits into from Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions pkg/k8s/apis/cilium.io/v2/register.go
Expand Up @@ -533,7 +533,9 @@ func createUpdateCRD(clientset apiextensionsclient.Interface, CRDName string, cr
}

scopedLog.Debug("Checking if CRD (CustomResourceDefinition) needs update...")
if needsUpdate(clusterCRD) {
if crd.Spec.Validation != nil &&
clusterCRD.Labels[CustomResourceDefinitionSchemaVersionKey] != "" &&
needsUpdate(clusterCRD) {
scopedLog.Info("Updating CRD (CustomResourceDefinition)...")
// Update the CRD with the validation schema.
err = wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) {
Expand Down Expand Up @@ -570,11 +572,7 @@ func createUpdateCRD(clientset apiextensionsclient.Interface, CRDName string, cr
// wait for the CRD to be established
scopedLog.Debug("Waiting for CRD (CustomResourceDefinition) to be available...")
err = wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) {
crd, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Get(context.TODO(), crd.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
for _, cond := range crd.Status.Conditions {
for _, cond := range clusterCRD.Status.Conditions {
switch cond.Type {
case apiextensionsv1beta1.Established:
if cond.Status == apiextensionsv1beta1.ConditionTrue {
Expand All @@ -587,6 +585,10 @@ func createUpdateCRD(clientset apiextensionsclient.Interface, CRDName string, cr
}
}
}
clusterCRD, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Get(context.TODO(), crd.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
return false, err
})
if err != nil {
Expand Down