Skip to content

Commit

Permalink
Fix excessive runnerreplicaset update issue since 0.25.0 (#1651)
Browse files Browse the repository at this point in the history
Fixes #1643
  • Loading branch information
mumoshu authored Jul 14, 2022
1 parent fea1457 commit 6762c5c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion controllers/runnerdeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ func (r *RunnerDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, err
}

log.V(1).Info("Updated runnerreplicaset due to selector change")

// At this point, we are already sure that there's no need to create a new replicaset
// as the runner template hash is not changed.
//
Expand All @@ -182,7 +184,14 @@ func (r *RunnerDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
//
// If we missed taking the EffectiveTime diff into account, you might end up experiencing scale-ups being delayed scale-down.
// See https://github.com/actions-runner-controller/actions-runner-controller/pull/1477#issuecomment-1164154496
if currentDesiredReplicas != newDesiredReplicas || newestSet.Spec.EffectiveTime != rd.Spec.EffectiveTime {
var et1, et2 time.Time
if newestSet.Spec.EffectiveTime != nil {
et1 = newestSet.Spec.EffectiveTime.Time
}
if rd.Spec.EffectiveTime != nil {
et2 = rd.Spec.EffectiveTime.Time
}
if currentDesiredReplicas != newDesiredReplicas || et1 != et2 {
newestSet.Spec.Replicas = &newDesiredReplicas
newestSet.Spec.EffectiveTime = rd.Spec.EffectiveTime

Expand All @@ -192,6 +201,13 @@ func (r *RunnerDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, err
}

log.V(1).Info("Updated runnerreplicaset due to spec change",
"currentDesiredReplicas", currentDesiredReplicas,
"newDesiredReplicas", newDesiredReplicas,
"currentEffectiveTime", newestSet.Spec.EffectiveTime,
"newEffectiveTime", rd.Spec.EffectiveTime,
)

return ctrl.Result{}, err
}

Expand Down

0 comments on commit 6762c5c

Please sign in to comment.