Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
britaniar committed Jul 26, 2024
1 parent b54290a commit 68922b8
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pkg/controllers/rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package rollout
import (
"context"
"fmt"
"math"
"strconv"
"time"

Expand Down Expand Up @@ -335,7 +334,6 @@ func (r *Reconciler) pickBindingsToRoll(ctx context.Context, allBindings []*flee

// classify the bindings into different categories
// TODO: calculate the time we need to wait for the first applied but not ready binding to be ready.
//waitTime := waitForFirstAppliedButNotReadyBinding(allBindings, readyTimeCutOff)
// return wait time longer if the rollout is stuck on failed apply/available bindings
crpKObj := klog.KObj(crp)
for idx := range allBindings {
Expand Down Expand Up @@ -512,18 +510,21 @@ func (r *Reconciler) calculateRealTarget(crp *fleetv1beta1.ClusterResourcePlacem
// waitForFirstAppliedButNotReadyBinding returns the minimum amount of time that needs to elapse before the first
// binding that has been applied but not yet marked as ready becomes ready.
func waitForFirstAppliedButNotReadyBinding(bindings []*fleetv1beta1.ClusterResourceBinding, readyTimeCutOff time.Time, unavailablePeriod time.Duration) time.Duration {
minWaitTime := time.Duration(math.MaxInt64)
minWaitTime := unavailablePeriod
for _, binding := range bindings {
appliedCondition := binding.GetCondition(string(fleetv1beta1.ResourceBindingApplied))
if condition.IsConditionStatusTrue(appliedCondition, binding.Generation) {
waitTime, bindingReady := isBindingReady(binding, readyTimeCutOff)
if !bindingReady && waitTime < minWaitTime && waitTime >= 0 {
minWaitTime = waitTime
}
if !condition.IsConditionStatusTrue(appliedCondition, binding.Generation) {
continue
}

waitTime, bindingReady := isBindingReady(binding, readyTimeCutOff)
if waitTime < 0 {
// we don't know when the current spec is available yet, skip this binding
continue
}
if !bindingReady && waitTime < minWaitTime {
minWaitTime = waitTime
}
}
if minWaitTime == time.Duration(math.MaxInt64) {
return unavailablePeriod
}
klog.V(2).InfoS("Selected the first applied but not ready binding", "waitTime", minWaitTime)
return minWaitTime
Expand Down

0 comments on commit 68922b8

Please sign in to comment.