fixup! fixup! fixup! fixup! fixup! fixup! General improvements

This commit is contained in:
2025-01-10 12:42:55 +00:00
parent cfaa6918a7
commit 71170a5a4a
3 changed files with 25 additions and 5 deletions
+2 -2
View File
@@ -10,9 +10,9 @@ description: |
type: application type: application
version: 0.2.30 version: 0.2.31
appVersion: "0.2.30" appVersion: "0.2.31"
home: https://github.com/lukaszraczylo/kubernetes-images-sync-operator home: https://github.com/lukaszraczylo/kubernetes-images-sync-operator
+1 -1
View File
@@ -12,7 +12,7 @@ sa:
- ALL - ALL
image: image:
repository: ghcr.io/lukaszraczylo/kubernetes-images-sync-operator repository: ghcr.io/lukaszraczylo/kubernetes-images-sync-operator
tag: 0.2.30 tag: 0.2.31
resources: resources:
limits: limits:
cpu: 500m cpu: 500m
@@ -268,12 +268,32 @@ func (r *ClusterImageExportReconciler) handleDeletion(ctx context.Context, clust
// Continue with deletion even if cleanup fails // Continue with deletion even if cleanup fails
} }
// Attempt to run cleanup job but don't block on errors // Check if cleanup job already exists
r.runCleanupJob(ctx, clusterImageExport) jobName := "cleanup-" + shared.NormalizeImageName(clusterImageExport.Name)
existingJob := &batchv1.Job{}
err := r.Get(ctx, client.ObjectKey{
Namespace: clusterImageExport.Namespace,
Name: jobName,
}, existingJob)
if err == nil {
// Job exists, don't create a new one
l.Info("Cleanup job already exists, skipping creation", "job", jobName)
} else if errors.IsNotFound(err) {
// Job doesn't exist, create it
r.runCleanupJob(ctx, clusterImageExport)
} else {
// Unexpected error, log but continue
l.Error(err, "Error checking for existing cleanup job")
}
// Remove the finalizer regardless of cleanup job status // Remove the finalizer regardless of cleanup job status
controllerutil.RemoveFinalizer(clusterImageExport, clusterImageExportFinalizer) controllerutil.RemoveFinalizer(clusterImageExport, clusterImageExportFinalizer)
if err := r.Update(ctx, clusterImageExport); err != nil { if err := r.Update(ctx, clusterImageExport); err != nil {
if errors.IsNotFound(err) {
// CRD is already gone, which is fine
return ctrl.Result{}, nil
}
return ctrl.Result{}, err return ctrl.Result{}, err
} }
} }