fixup! fixup! fixup! fixup! fixup! fixup! Improve helm chart allowing for lock of the worker image

This commit is contained in:
2025-01-14 01:25:42 +00:00
parent 03214c8a47
commit 067a51c9c7
5 changed files with 103 additions and 93 deletions
+2 -2
View File
@@ -10,9 +10,9 @@ description: |
type: application
version: 0.5.52
version: 0.5.53
appVersion: "0.5.52"
appVersion: "0.5.53"
home: https://github.com/lukaszraczylo/kubernetes-images-sync-operator
+2 -2
View File
@@ -11,10 +11,10 @@ sa:
drop:
- ALL
env:
workerImage: ghcr.io/lukaszraczylo/kubernetes-images-sync-worker:0.5.52
workerImage: ghcr.io/lukaszraczylo/kubernetes-images-sync-worker:0.5.53
image:
repository: ghcr.io/lukaszraczylo/kubernetes-images-sync-operator
tag: 0.5.52
tag: 0.5.53
resources:
limits:
cpu: 500m
+68 -67
View File
@@ -4,70 +4,71 @@ kind: ClusterRole
metadata:
name: impex-mgr
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- daemonsets
- deployments
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- cronjobs
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- raczylo.com
resources:
- '*'
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- raczylo.com
resources:
- '*/finalizers'
verbs:
- update
- apiGroups:
- raczylo.com
resources:
- '*/status'
verbs:
- get
- patch
- update
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- daemonsets
- deployments
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- cronjobs
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- raczylo.com
resources:
- "*"
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- raczylo.com
resources:
- "*/finalizers"
verbs:
- update
- apiGroups:
- raczylo.com
resources:
- "*/status"
verbs:
- get
- patch
- update
@@ -36,7 +36,7 @@ type ClusterImageReconciler struct {
// +kubebuilder:rbac:groups=raczylo.com,resources=*/finalizers,verbs=update
// # additional RBAC rules - create and manage jobs
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch;create;update;patch;delete;deletecollection
// add access to secrets
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
func (r *ClusterImageReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
@@ -181,7 +181,9 @@ func (r *ClusterImageExportReconciler) Reconcile(ctx context.Context, req ctrl.R
}
// Check completion status and update counts
completedCount := 0
successCount := 0
failedCount := 0
pendingCount := 0
clusterImageList := &raczylocomv1.ClusterImageList{}
if err := r.List(ctx, clusterImageList, client.InNamespace(clusterImageExport.Namespace),
client.MatchingFields{"spec.exportName": clusterImageExport.Name}); err != nil {
@@ -190,30 +192,37 @@ func (r *ClusterImageExportReconciler) Reconcile(ctx context.Context, req ctrl.R
}
for _, ci := range clusterImageList.Items {
if ci.Status.Progress == shared.STATUS_SUCCESS || ci.Status.Progress == shared.STATUS_PRESENT {
completedCount++
switch ci.Status.Progress {
case shared.STATUS_SUCCESS, shared.STATUS_PRESENT:
successCount++
case shared.STATUS_FAILED:
failedCount++
case shared.STATUS_PENDING, shared.STATUS_RUNNING, shared.STATUS_RETRYING:
pendingCount++
}
}
completedCount := successCount + failedCount
// Update status with completion info
if completedCount == totalImages && totalImages > 0 {
if err := r.updateStatusWithRetry(ctx, clusterImageExport, func(export *raczylocomv1.ClusterImageExport) error {
export.Status.Progress = shared.STATUS_SUCCESS
export.Status.CompletedImages = completedCount
return nil
}); err != nil {
l.Error(err, "unable to update ClusterImageExport status")
return ctrl.Result{}, err
}
return ctrl.Result{}, nil
} else {
if err := r.updateStatusWithRetry(ctx, clusterImageExport, func(export *raczylocomv1.ClusterImageExport) error {
export.Status.CompletedImages = completedCount
return nil
}); err != nil {
l.Error(err, "unable to update ClusterImageExport status")
return ctrl.Result{}, err
if err := r.updateStatusWithRetry(ctx, clusterImageExport, func(export *raczylocomv1.ClusterImageExport) error {
export.Status.CompletedImages = completedCount
if completedCount == totalImages && totalImages > 0 {
if failedCount > 0 {
export.Status.Progress = shared.STATUS_FAILED
} else {
export.Status.Progress = shared.STATUS_SUCCESS
}
}
return nil
}); err != nil {
l.Error(err, "unable to update ClusterImageExport status")
return ctrl.Result{}, err
}
// If there are still pending images, requeue
if pendingCount > 0 {
return ctrl.Result{Requeue: true}, nil
}
return ctrl.Result{Requeue: true}, nil
@@ -401,7 +410,7 @@ func (r *ClusterImageExportReconciler) runCleanupJob(ctx context.Context, cluste
// Set up the cleanup job with retry limits and TTL
backoffLimit := int32(2) // 3 total attempts (initial + 2 retries)
ttlSecondsAfterFinished := int32(30) // Delete job 30 seconds after completion
ttlSecondsAfterFinished := int32(300) // Delete job 5 minutes after completion
// Merge annotations from different sources
mergedAnnotations := make(map[string]string)