Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the issue of equality check between initialRevs and targetRevs #207

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion pkg/reconciler/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,30 @@ func getDeltaReplicasTraffic(currentReplicas int32, currentTraffic int64, ratio
return int32(stageReplicas), int64(stageTrafficDelta)
}

func targetsCloneWithoutURL(revs []v1.TargetRevision) []v1.TargetRevision {
revsCopies := make([]v1.TargetRevision, len(revs))
for i := 0; i < len(revs); i++ {
revsCopies[i] = *revs[i].DeepCopy()
// Remove the fields URL and Tag.
revsCopies[i].URL = nil
revsCopies[i].Tag = ""
}
return revsCopies
}

func targetsEqual(initialRevs, targetRevs []v1.TargetRevision) bool {
return reflect.DeepEqual(initialRevs, targetRevs) || reflect.DeepEqual(targetsCloneWithoutURL(initialRevs),
targetsCloneWithoutURL(targetRevs))
}

// updateStageTargetRevisions updates the StageTargetRevisions based on the existing StageTargetRevisions,
// Initial target Revisions, Final target revisions, and the current PodAutoscaler.
func updateStageTargetRevisions(ro *v1.RolloutOrchestrator, config *RolloutConfig,
podAutoscalerLister palisters.PodAutoscalerNamespaceLister, spaLister listers.StagePodAutoscalerNamespaceLister) error {
// The length of the TargetRevisions is always one here, meaning that there is
// only one revision as the target revision when the rollout is over.
var stageRevisionTarget []v1.TargetRevision
if !reflect.DeepEqual(ro.Spec.InitialRevisions, ro.Spec.TargetRevisions) {
if !targetsEqual(ro.Spec.InitialRevisions, ro.Spec.TargetRevisions) {
startRevisions := getStartRevisions(ro)
if len(startRevisions) == 0 || config.OverConsumptionRatio >= common.HundredPercent {
// If the index is out of bound, assign the StageTargetRevisions to the final TargetRevisions.
Expand Down
Loading