mirror of
https://github.com/clastix/kamaji.git
synced 2026-04-15 06:56:47 +00:00
feat: logging resource deletion
This commit is contained in:
@@ -45,10 +45,10 @@ func GetResources(config GroupResourceBuilderConfiguration) []resources.Resource
|
||||
return getDefaultResources(config)
|
||||
}
|
||||
|
||||
// GetDeleteableResources returns a list of resources that have to be deleted when tenant control planes are deleted
|
||||
// GetDeletableResources returns a list of resources that have to be deleted when tenant control planes are deleted
|
||||
// Currently there is only a default approach
|
||||
// TODO: the idea of this function is to become a factory to return the group of deleteable resources according to the given configuration.
|
||||
func GetDeleteableResources(config GroupDeleteableResourceBuilderConfiguration) []resources.DeleteableResource {
|
||||
func GetDeletableResources(config GroupDeleteableResourceBuilderConfiguration) []resources.DeleteableResource {
|
||||
return getDefaultDeleteableResources(config)
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ func (r *TenantControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
|
||||
}()
|
||||
|
||||
if markedToBeDeleted {
|
||||
log.Info("marked for deletion, performing clean-up")
|
||||
|
||||
groupDeleteableResourceBuilderConfiguration := GroupDeleteableResourceBuilderConfiguration{
|
||||
client: r.Client,
|
||||
log: log,
|
||||
@@ -101,20 +103,24 @@ func (r *TenantControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
|
||||
tenantControlPlane: *tenantControlPlane,
|
||||
DBConnection: dbConnection,
|
||||
}
|
||||
registeredDeleteableResources := GetDeleteableResources(groupDeleteableResourceBuilderConfiguration)
|
||||
registeredDeletableResources := GetDeletableResources(groupDeleteableResourceBuilderConfiguration)
|
||||
|
||||
for _, resource := range registeredDeleteableResources {
|
||||
for _, resource := range registeredDeletableResources {
|
||||
if err := resources.HandleDeletion(ctx, resource, tenantControlPlane); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
|
||||
if hasFinalizer {
|
||||
log.Info("removing finalizer")
|
||||
|
||||
if err := r.RemoveFinalizer(ctx, tenantControlPlane); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("resource deletion has been completed")
|
||||
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user