Skip to content

Commit

Permalink
commands: update for logging
Browse files Browse the repository at this point in the history
Signed-off-by: Javier <[email protected]>
  • Loading branch information
Javier committed Dec 12, 2023
1 parent cc40f4c commit ccc7962
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/crds/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func DeleteCustomResources(ctx context.Context, clientsets k8sutil.ClientsetsInt
logging.Fatal(err)
}
k8sutil.DeleteDeployment(ctx, k8sClientSet, clusterNamespace, toolBoxDeployment)
ensureClusterIsEmpty(ctx, k8sClientSet, clusterNamespace)
ensureClusterIsEmpty(ctx, k8sClientSet, clientsets, clusterNamespace)
logging.Info("done")
}

Expand Down Expand Up @@ -145,7 +145,7 @@ func deleteCustomResources(ctx context.Context, clientsets k8sutil.ClientsetsInt
logging.Info(fmt.Sprintf("error the resource cannot be found due %s", err.Error()))
return err
} else {
logging.Error(fmt.Errorf("resource was deleted succesfully %+v", item.GetName()))
logging.Error(fmt.Errorf("resource was deleted successfully %+v", item.GetName()))
}
} else {
logging.Error(fmt.Errorf("error resource was NOT deleted %+v", itemResource))
Expand Down Expand Up @@ -173,7 +173,7 @@ func updatingFinalizers(ctx context.Context, clientsets k8sutil.ClientsetsInterf
return nil
}

func ensureClusterIsEmpty(ctx context.Context, k8sClientSet kubernetes.Interface, clusterNamespace string) {
func ensureClusterIsEmpty(ctx context.Context, k8sClientSet kubernetes.Interface, clientsets k8sutil.ClientsetsInterface, clusterNamespace string) {
logging.Info("waiting to clean up resources")
for {
pods, err := k8sClientSet.CoreV1().Pods(clusterNamespace).List(ctx, v1.ListOptions{LabelSelector: "rook_cluster=" + clusterNamespace})
Expand All @@ -188,6 +188,10 @@ func ensureClusterIsEmpty(ctx context.Context, k8sClientSet kubernetes.Interface
for _, pod := range pods.Items {
logging.Info(fmt.Sprintf("pod alive name:%s namespace: %s kind: %s finalizers: %+v", pod.Name, pod.Namespace, pod.Kind, pod.Finalizers))
}
err := deleteCustomResources(ctx, clientsets, clusterNamespace)
if err != nil {
logging.Fatal(err)
}
}
}
}

0 comments on commit ccc7962

Please sign in to comment.