Skip to content

Commit

Permalink
[Upstream] Update Namespace deletion during uninstall
Browse files Browse the repository at this point in the history
During uninstall, serially delete namespaces instead of parallel deletion.
This ensures that the operator reconciles and wait for all resources to be
completely cleaned up before csv is deleted
  • Loading branch information
VaishnaviHire authored and anishasthana committed Aug 6, 2021
1 parent 63b2ea5 commit 55ce6bd
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions pkg/controller/kfdef/kfdef_controller.go
Expand Up @@ -610,16 +610,28 @@ func (r *ReconcileKfDef) operatorUninstall(request reconcile.Request) error {
return fmt.Errorf("error getting generated namespaces : %v", err)
}
}

// Return if any one of the namespaces is Terminating due to resources that are in process of deletion. (e.g CRDs)
if len(generatedNamespaces.Items) != 0 {
for _, namespace := range generatedNamespaces.Items {
if namespace.Status.Phase == v1.NamespaceActive {
if err := r.client.Delete(context.TODO(), &namespace, []client.DeleteOption{}...); err != nil {
return fmt.Errorf("error deleting namespace %v: %v", namespace.Name, err)
}
log.Infof("Namespace %s deleted as a part of uninstall.", namespace.Name)
if namespace.Status.Phase == v1.NamespaceTerminating{
return fmt.Errorf("waiting for namespace %v to be deleted", namespace.Name)
}
}
}

// Delete all the active namespaces
for _, namespace := range generatedNamespaces.Items {
if namespace.Status.Phase == v1.NamespaceActive{
if err := r.client.Delete(context.TODO(), &namespace, []client.DeleteOption{}...); err != nil {
return fmt.Errorf("error deleting namespace %v: %v", namespace.Name, err)
}
log.Infof("Namespace %s deleted as a part of uninstall.", namespace.Name)
}
}



return removeCsv(r.client, r.restConfig)
}

Expand Down

0 comments on commit 55ce6bd

Please sign in to comment.