@@ -150,7 +150,7 @@ func (a *ApplicationManager) Reconcile(ctx context.Context, req ctrl.Request) (_
150
150
151
151
// Handle deletion reconciliation loop.
152
152
if app .DeletionTimestamp != nil {
153
- return a .reconcileDelete (ctx , app , fleet )
153
+ return a .reconcileDelete (ctx , app )
154
154
}
155
155
156
156
// Handle normal loop.
@@ -315,21 +315,24 @@ func (a *ApplicationManager) reconcileSyncStatus(ctx context.Context, app *appli
315
315
return nil
316
316
}
317
317
318
- func (a * ApplicationManager ) reconcileDelete (ctx context.Context , app * applicationapi.Application , fleet * fleetapi.Fleet ) (ctrl.Result , error ) {
318
+ // Handling Application Deletion Based on Fleet Availability
319
+ // When deleting an application, the approach taken depends on whether the managing fleet can be retrieved.
320
+ // If the fleet is available:
321
+ // Application will be removed
322
+ // Resources related to the application will then be deleted from fleet clusters
323
+ // If the fleet cannot be retrieved:
324
+ // Only the application object itself will be removed
325
+ // Related resources in any cluster will be left intact
326
+ func (a * ApplicationManager ) reconcileDelete (ctx context.Context , app * applicationapi.Application ) (ctrl.Result , error ) {
319
327
log := ctrl .LoggerFrom (ctx )
320
-
321
328
fleetKey := generateFleetKey (app )
329
+ fleet := & fleetapi.Fleet {}
322
330
if err := a .Client .Get (ctx , fleetKey , fleet ); err != nil {
323
- if apierrors .IsNotFound (err ) {
324
- log .Info ("delete failed, fleet does not exist" , "fleet" , fleetKey )
325
- return ctrl.Result {RequeueAfter : fleetmanager .RequeueAfter }, nil
331
+ log .Error (err , "failed to find fleet" , "fleet" , fleetKey )
332
+ } else {
333
+ if deleteErr := a .deleteResourcesInMemberClusters (ctx , app , fleet ); deleteErr != nil {
334
+ return ctrl.Result {}, errors .Wrapf (deleteErr , "failed to delete rollout resource in member clusters" )
326
335
}
327
- log .Error (err , "delete failed, fleet does not found" , "fleet" , fleetKey )
328
- return ctrl.Result {}, err
329
- }
330
-
331
- if deleteErr := a .deleteResourcesInMemberClusters (ctx , app , fleet ); deleteErr != nil {
332
- return ctrl.Result {}, errors .Wrapf (deleteErr , "failed to delete rollout resource in cluster" )
333
336
}
334
337
335
338
controllerutil .RemoveFinalizer (app , ApplicationFinalizer )
0 commit comments