@@ -81,15 +81,20 @@ func verifyOperatorStatusCondition(client *certmanoperatorclient.Clientset, cont
8181 return false , nil
8282 }
8383
84+ var condMatchCount int
8485 for _ , cond := range operator .Status .Conditions {
8586 if status , exists := expectedConditionMap [strings .TrimPrefix (cond .Type , controllerNames [index ])]; exists {
87+ condMatchCount += 1
88+
8689 if cond .Status != status {
8790 return false , nil
8891 }
8992 }
9093 }
9194
92- return true , nil
95+ // [retry] false: when NOT all expected conditions were found
96+ // [no-retry] true: when all expected conditions were found
97+ return condMatchCount == len (expectedConditionMap ), nil
9398 })
9499 errs [index ] = err
95100 }(index )
@@ -99,6 +104,53 @@ func verifyOperatorStatusCondition(client *certmanoperatorclient.Clientset, cont
99104 return errors .NewAggregate (errs )
100105}
101106
107+ func verifyDeploymentGenerationIsNotEmpty (client * certmanoperatorclient.Clientset , deployments []metav1.ObjectMeta ) error {
108+ var wg sync.WaitGroup
109+ errs := make ([]error , len (deployments ))
110+ for index , deployMeta := range deployments {
111+ wg .Add (1 )
112+
113+ go func (idx int , nameAndNs * metav1.ObjectMeta ) {
114+ defer wg .Done ()
115+
116+ err := wait .PollUntilContextTimeout (context .TODO (), time .Second * 1 , time .Minute * 5 , true , func (context.Context ) (bool , error ) {
117+ operator , err := client .OperatorV1alpha1 ().CertManagers ().Get (context .TODO (), "cluster" , metav1.GetOptions {})
118+ if err != nil {
119+ if apierrors .IsNotFound (err ) {
120+ return false , nil
121+ }
122+ return false , err
123+ }
124+
125+ if operator .DeletionTimestamp != nil {
126+ return false , nil
127+ }
128+
129+ var exists bool
130+ for _ , gen := range operator .Status .Generations {
131+ // match deployment: name and namespace, group, resource
132+ if gen .Name != nameAndNs .Name || gen .Namespace != nameAndNs .Namespace ||
133+ gen .Group != "apps" || gen .Resource != "deployments" {
134+ continue
135+ }
136+ exists = true
137+
138+ if gen .LastGeneration <= 0 {
139+ return false , nil
140+ }
141+ }
142+
143+ return exists , nil
144+ })
145+
146+ errs [idx ] = err
147+ }(index , & deployMeta )
148+ }
149+ wg .Wait ()
150+
151+ return errors .NewAggregate (errs )
152+ }
153+
102154// resetCertManagerState is used to revert back to the default cert-manager operands' state
103155func resetCertManagerState (ctx context.Context , client * certmanoperatorclient.Clientset , loader library.DynamicResourceLoader ) error {
104156 // update operator spec to empty *Config and set operatorSpec to default values
0 commit comments