mirror of
https://github.com/lukaszraczylo/kubernetes-images-sync-operator.git
synced 2026-12-06 07:14:14 +00:00
ci(pr): grant actions read and stop using the deprecated Requeue
* ci(pr): grant actions read so the shared PR checks start go-pr.yaml's CodeQL job asks for actions: read. A reusable workflow cannot ask for more than its caller grants, so the whole PR run failed at startup with no jobs. Grant the missing scope. * refactor(controller): use RequeueAfter instead of the deprecated Requeue controller-runtime deprecates Result.Requeue (SA1019), which the PR checks now report because they finally start. Requeue after 30 seconds, the interval the cluster image controller already uses for its max-parallel wait. --------- Co-authored-by: Bug Fixer <[email protected]>
This commit is contained in:
@@ -74,12 +74,12 @@ func (r *ClusterImageReconciler) Reconcile(ctx context.Context, req ctrl.Request
|
||||
if err := r.Status().Update(ctx, latest); err != nil {
|
||||
if errors.IsConflict(err) {
|
||||
// Resource was modified, requeue and try again
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to update ClusterImage status to PENDING")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
|
||||
// If we've reached the maximum number of parallel jobs, requeue
|
||||
@@ -128,7 +128,7 @@ func (r *ClusterImageReconciler) handlePendingClusterImage(ctx context.Context,
|
||||
if err := r.Status().Update(ctx, latest); err != nil {
|
||||
if errors.IsConflict(err) {
|
||||
// Resource was modified, requeue and try again
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to update ClusterImage status")
|
||||
return ctrl.Result{}, err
|
||||
@@ -161,7 +161,7 @@ func (r *ClusterImageReconciler) handlePendingClusterImage(ctx context.Context,
|
||||
r.ActiveJobs++
|
||||
r.activeJobsMu.Unlock()
|
||||
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
|
||||
func (r *ClusterImageReconciler) handleRunningClusterImage(ctx context.Context, clusterImage *raczylocomv1.ClusterImage, l logr.Logger) (ctrl.Result, error) {
|
||||
@@ -204,13 +204,13 @@ func (r *ClusterImageReconciler) handleRunningClusterImage(ctx context.Context,
|
||||
if err := r.Status().Update(ctx, latest); err != nil {
|
||||
if errors.IsConflict(err) {
|
||||
// Resource was modified, requeue and try again
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to update ClusterImage status after job not found")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to check for existing job")
|
||||
return ctrl.Result{}, err
|
||||
@@ -232,7 +232,7 @@ func (r *ClusterImageReconciler) handleRunningClusterImage(ctx context.Context,
|
||||
if err := r.Status().Update(ctx, latest); err != nil {
|
||||
if errors.IsConflict(err) {
|
||||
// Resource was modified, requeue and try again
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to update ClusterImage status to SUCCESS")
|
||||
return ctrl.Result{}, err
|
||||
@@ -264,14 +264,14 @@ func (r *ClusterImageReconciler) handleRunningClusterImage(ctx context.Context,
|
||||
if err := r.Status().Update(ctx, latest); err != nil {
|
||||
if errors.IsConflict(err) {
|
||||
// Resource was modified, requeue and try again
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to update ClusterImage status for retry")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
// Requeue immediately to create a new job
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
|
||||
// Get latest version before updating status
|
||||
@@ -285,7 +285,7 @@ func (r *ClusterImageReconciler) handleRunningClusterImage(ctx context.Context,
|
||||
if err := r.Status().Update(ctx, latest); err != nil {
|
||||
if errors.IsConflict(err) {
|
||||
// Resource was modified, requeue and try again
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
l.Error(err, "unable to update ClusterImage status to FAILED")
|
||||
return ctrl.Result{}, err
|
||||
@@ -481,7 +481,7 @@ func (r *ClusterImageReconciler) updateClusterImageExportStatus(ctx context.Cont
|
||||
|
||||
// If there are still pending or running images, requeue
|
||||
if !allCompleted {
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
|
||||
}
|
||||
|
||||
return ctrl.Result{}, nil
|
||||
|
||||
Reference in New Issue
Block a user