Skip to content

Commit

Permalink
Fix max creation
Browse files Browse the repository at this point in the history
  • Loading branch information
AliDatadog committed Mar 3, 2025
1 parent 2f4a97b commit 683364e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func ManageDeployment(client runtimeclient.Client, daemonset *datadoghqv1alpha1.
}

rollingUpdateStartTime := getRollingUpdateStartTime(&params.Replicaset.Status, now)
maxCreation, err := calculateMaxCreation(&params.Strategy.RollingUpdate, nbNodes, rollingUpdateStartTime, now)
maxCreation, err := calculateMaxCreation(&params.Strategy.RollingUpdate, nbNodes, len(allPodToDelete), rollingUpdateStartTime, now)
if err != nil {
params.Logger.Error(err, "error during calculateMaxCreation execution")

Expand Down Expand Up @@ -220,14 +220,17 @@ func getRollingUpdateStartTime(status *datadoghqv1alpha1.ExtendedDaemonSetReplic
return now
}

func calculateMaxCreation(params *datadoghqv1alpha1.ExtendedDaemonSetSpecStrategyRollingUpdate, nbNodes int, rsStartTime, now time.Time) (int, error) {
func calculateMaxCreation(params *datadoghqv1alpha1.ExtendedDaemonSetSpecStrategyRollingUpdate, nbNodes, podsToDelete int, rsStartTime, now time.Time) (int, error) {
startValue, err := intstrutil.GetValueFromIntOrPercent(params.SlowStartAdditiveIncrease, nbNodes, true)
if err != nil {
return 0, err
}
rollingUpdateDuration := now.Sub(rsStartTime)
nbSlowStartSlot := int(rollingUpdateDuration / params.SlowStartIntervalDuration.Duration)
result := (1 + nbSlowStartSlot) * startValue
if result < podsToDelete {
result = podsToDelete
}
if result > int(*params.MaxParallelPodCreation) {
result = int(*params.MaxParallelPodCreation)
}
Expand Down

0 comments on commit 683364e

Please sign in to comment.