@@ -104,6 +104,53 @@ func verifyOperatorStatusCondition(client *certmanoperatorclient.Clientset, cont
104104 return errors .NewAggregate (errs )
105105}
106106
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+
107154// resetCertManagerState is used to revert back to the default cert-manager operands' state
108155func resetCertManagerState (ctx context.Context , client * certmanoperatorclient.Clientset , loader library.DynamicResourceLoader ) error {
109156 // update operator spec to empty *Config and set operatorSpec to default values
0 commit comments