@@ -168,9 +168,12 @@ func (r *AtlasProjectReconciler) Reconcile(context context.Context, req ctrl.Req
168168 ctx .SetConditionTrue (status .ProjectReadyType )
169169 r .EventRecorder .Event (project , "Normal" , string (status .ProjectReadyType ), "" )
170170
171- if result := r .ensureProjectResources (ctx , projectID , project , context ); ! result .IsOk () {
172- logIfWarning (ctx , result )
173- return result .ReconcileResult (), nil
171+ results := r .ensureProjectResources (ctx , projectID , project , context )
172+ for i := range results {
173+ if ! results [i ].IsOk () {
174+ logIfWarning (ctx , result )
175+ return results [i ].ReconcileResult (), nil
176+ }
174177 }
175178
176179 ctx .SetConditionTrue (status .ReadyType )
@@ -221,72 +224,69 @@ func (r *AtlasProjectReconciler) ensureDeletionFinalizer(ctx *workflow.Context,
221224}
222225
223226// ensureProjectResources ensures IP Access List, Private Endpoints, Integrations, Maintenance Window and Encryption at Rest
224- func (r * AtlasProjectReconciler ) ensureProjectResources (ctx * workflow.Context , projectID string , project * mdbv1.AtlasProject , context context.Context ) (result workflow.Result ) {
225- if result = ensureIPAccessList (ctx , projectID , project ); ! result .IsOk () {
226- return result
227+ func (r * AtlasProjectReconciler ) ensureProjectResources (ctx * workflow.Context , projectID string , project * mdbv1.AtlasProject , context context.Context ) (results []workflow.Result ) {
228+ var result workflow.Result
229+ if result = ensureIPAccessList (ctx , projectID , project ); result .IsOk () {
230+ r .EventRecorder .Event (project , "Normal" , string (status .IPAccessListReadyType ), "" )
227231 }
228- r . EventRecorder . Event ( project , "Normal" , string ( status . IPAccessListReadyType ), "" )
232+ results = append ( results , result )
229233
230- if result = ensurePrivateEndpoint (ctx , projectID , project ); ! result .IsOk () {
231- return result
234+ if result = ensurePrivateEndpoint (ctx , projectID , project ); result .IsOk () {
235+ r . EventRecorder . Event ( project , "Normal" , string ( status . PrivateEndpointReadyType ), "" )
232236 }
233- r . EventRecorder . Event ( project , "Normal" , string ( status . PrivateEndpointReadyType ), "" )
237+ results = append ( results , result )
234238
235- if result = ensureProviderAccessStatus (context , ctx , project , projectID ); ! result .IsOk () {
236- logIfWarning (ctx , result )
237- return result
239+ if result = ensureProviderAccessStatus (context , ctx , project , projectID ); result .IsOk () {
240+ r .EventRecorder .Event (project , "Normal" , string (status .CloudProviderAccessReadyType ), "" )
238241 }
239- r . EventRecorder . Event ( project , "Normal" , string ( status . CloudProviderAccessReadyType ), "" )
242+ results = append ( results , result )
240243
241- if result = ensureNetworkPeers (ctx , projectID , project ); ! result .IsOk () {
242- logIfWarning (ctx , result )
243- return result
244+ if result = ensureNetworkPeers (ctx , projectID , project ); result .IsOk () {
245+ r .EventRecorder .Event (project , "Normal" , string (status .NetworkPeerReadyType ), "" )
244246 }
245- r . EventRecorder . Event ( project , "Normal" , string ( status . NetworkPeerReadyType ), "" )
247+ results = append ( results , result )
246248
247- if result = ensureAlertConfigurations (ctx , project , projectID ); ! result .IsOk () {
248- logIfWarning (ctx , result )
249- return result
249+ if result = ensureAlertConfigurations (ctx , project , projectID ); result .IsOk () {
250+ r .EventRecorder .Event (project , "Normal" , string (status .AlertConfigurationReadyType ), "" )
250251 }
252+ results = append (results , result )
251253
252- r .EventRecorder .Event (project , "Normal" , string (status .AlertConfigurationReadyType ), "" )
253-
254- if result = r .ensureIntegration (ctx , projectID , project ); ! result .IsOk () {
255- return result
254+ if result = r .ensureIntegration (ctx , projectID , project ); result .IsOk () {
255+ r .EventRecorder .Event (project , "Normal" , string (status .IntegrationReadyType ), "" )
256256 }
257- r . EventRecorder . Event ( project , "Normal" , string ( status . IntegrationReadyType ), "" )
257+ results = append ( results , result )
258258
259- if result = ensureMaintenanceWindow (ctx , projectID , project ); ! result .IsOk () {
260- return result
259+ if result = ensureMaintenanceWindow (ctx , projectID , project ); result .IsOk () {
260+ r . EventRecorder . Event ( project , "Normal" , string ( status . MaintenanceWindowReadyType ), "" )
261261 }
262- r . EventRecorder . Event ( project , "Normal" , string ( status . MaintenanceWindowReadyType ), "" )
262+ results = append ( results , result )
263263
264- if result = ensureEncryptionAtRest (ctx , projectID , project ); ! result .IsOk () {
265- return result
264+ if result = ensureEncryptionAtRest (ctx , projectID , project ); result .IsOk () {
265+ r . EventRecorder . Event ( project , "Normal" , string ( status . EncryptionAtRestReadyType ), "" )
266266 }
267- r . EventRecorder . Event ( project , "Normal" , string ( status . EncryptionAtRestReadyType ), "" )
267+ results = append ( results , result )
268268
269- if result = ensureAuditing (ctx , projectID , project ); ! result .IsOk () {
270- return result
269+ if result = ensureAuditing (ctx , projectID , project ); result .IsOk () {
270+ r . EventRecorder . Event ( project , "Normal" , string ( status . AuditingReadyType ), "" )
271271 }
272- r . EventRecorder . Event ( project , "Normal" , string ( status . AuditingReadyType ), "" )
272+ results = append ( results , result )
273273
274- if result = ensureProjectSettings (ctx , projectID , project ); ! result .IsOk () {
275- return result
274+ if result = ensureProjectSettings (ctx , projectID , project ); result .IsOk () {
275+ r . EventRecorder . Event ( project , "Normal" , string ( status . ProjectSettingsReadyType ), "" )
276276 }
277- r . EventRecorder . Event ( project , "Normal" , string ( status . ProjectSettingsReadyType ), "" )
277+ results = append ( results , result )
278278
279- if result = ensureCustomRoles (ctx , projectID , project ); ! result .IsOk () {
280- return result
279+ if result = ensureCustomRoles (ctx , projectID , project ); result .IsOk () {
280+ r . EventRecorder . Event ( project , "Normal" , string ( status . ProjectCustomRolesReadyType ), "" )
281281 }
282- r . EventRecorder . Event ( project , "Normal" , string ( status . ProjectCustomRolesReadyType ), "" )
282+ results = append ( results , result )
283283
284- if result = r .ensureAssignedTeams (ctx , projectID , project ); ! result .IsOk () {
285- return result
284+ if result = r .ensureAssignedTeams (ctx , projectID , project ); result .IsOk () {
285+ r . EventRecorder . Event ( project , "Normal" , string ( status . ProjectTeamsReadyType ), "" )
286286 }
287- r . EventRecorder . Event ( project , "Normal" , string ( status . ProjectTeamsReadyType ), "" )
287+ results = append ( results , result )
288288
289- return workflow . OK ()
289+ return results
290290}
291291
292292func (r * AtlasProjectReconciler ) deleteAtlasProject (ctx context.Context , atlasClient mongodbatlas.Client , project * mdbv1.AtlasProject ) (err error ) {
0 commit comments