@@ -12,7 +12,7 @@ import (
12
12
13
13
"github.com/go-logr/logr"
14
14
v1 "k8s.io/api/core/v1"
15
- "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1 "
15
+ v1extensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 "
16
16
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
17
17
apierr "k8s.io/apimachinery/pkg/api/errors"
18
18
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -831,16 +831,16 @@ func (sc *syncContext) setOperationPhase(phase common.OperationPhase, message st
831
831
sc .message = message
832
832
}
833
833
834
- // ensureCRDReady waits until specified CRD is ready (established condition is true). Method is best effort - it does not fail even if CRD is not ready without timeout.
835
- func (sc * syncContext ) ensureCRDReady (name string ) {
836
- _ = wait .PollImmediate (time .Duration (100 )* time .Millisecond , crdReadinessTimeout , func () (bool , error ) {
837
- crd , err := sc .extensionsclientset .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Get (context .TODO (), name , metav1.GetOptions {})
834
+ // ensureCRDReady waits until specified CRD is ready (established condition is true).
835
+ func (sc * syncContext ) ensureCRDReady (name string ) error {
836
+ return wait .PollImmediate (time .Duration (100 )* time .Millisecond , crdReadinessTimeout , func () (bool , error ) {
837
+ crd , err := sc .extensionsclientset .ApiextensionsV1 ().CustomResourceDefinitions ().Get (context .TODO (), name , metav1.GetOptions {})
838
838
if err != nil {
839
839
return false , err
840
840
}
841
841
for _ , condition := range crd .Status .Conditions {
842
- if condition .Type == v1beta1 .Established {
843
- return condition .Status == v1beta1 .ConditionTrue , nil
842
+ if condition .Type == v1extensions .Established {
843
+ return condition .Status == v1extensions .ConditionTrue , nil
844
844
}
845
845
}
846
846
return false , nil
@@ -881,7 +881,10 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun bool, force bool, validat
881
881
return common .ResultCodeSyncFailed , err .Error ()
882
882
}
883
883
if kube .IsCRD (t .targetObj ) && ! dryRun {
884
- sc .ensureCRDReady (t .targetObj .GetName ())
884
+ crdName := t .targetObj .GetName ()
885
+ if err = sc .ensureCRDReady (crdName ); err != nil {
886
+ sc .log .Error (err , fmt .Sprintf ("failed to ensure that CRD %s is ready" , crdName ))
887
+ }
885
888
}
886
889
return common .ResultCodeSynced , message
887
890
}
0 commit comments