Skip to content

Commit abc2ee2

Browse files
authored
[release-1.17] Assign 0% when there is at least one pod running (#358)
* [release-1.17] Assign 0% when there is at least one pod running * Removed reading the traffic from route * Skip the case for RolloutDuration != 0
1 parent c219b41 commit abc2ee2

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed

pkg/reconciler/service/service.go

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -975,15 +975,15 @@ func convertIntoTrafficTarget(name string, ro *v1.RolloutOrchestrator, rc *Rollo
975975

976976
spa, err := spaLister.Get(spaTargetRevName)
977977
// Check the number of replicas has reached the target number of replicas for the revision scaling up
978-
if apierrs.IsNotFound(err) || spa.Status.ActualScale == nil || (err == nil && targetNumberReplicas != nil && spa.Status.ActualScale != nil &&
978+
if err != nil || spa.Status.ActualScale == nil || (err == nil && targetNumberReplicas != nil && spa.Status.ActualScale != nil &&
979979
minScale != nil && *targetNumberReplicas <= *minScale && *spa.Status.ActualScale < *targetNumberReplicas) {
980980
// If we have issues getting the spa, or the number of the replicas has reached the target number of
981981
// the revision to scale up, we set the revisionTarget to ro.Spec.StageTargetRevisions.
982982

983983
// However, if there is no issue getting yhe spa, and the actual number of replicas is less than
984984
// the target number of replicas, we need to use ro.Status.StageRevisionStatus or route.Status.Traffic
985985
// as the traffic information for the route.
986-
if strings.EqualFold(rc.ProgressiveRolloutStrategy, strategies.AvailabilityStrategy) {
986+
if strings.EqualFold(rc.ProgressiveRolloutStrategy, strategies.AvailabilityStrategy) && rc.RolloutDuration == "0" {
987987
// Comment out the following lines for further consideration with resourceUtil mode
988988
// || (strings.EqualFold(rc.ProgressiveRolloutStrategy, strategies.ResourceUtilStrategy) && !trafficDriven && !lastStage) {
989989
if len(ro.Status.StageRevisionStatus) > 0 {
@@ -997,47 +997,17 @@ func convertIntoTrafficTarget(name string, ro *v1.RolloutOrchestrator, rc *Rollo
997997
}
998998
revisionTarget[index].LatestRevision = ptr.Bool(false)
999999
}
1000-
if !found {
1000+
1001+
if !found && spa != nil && spa.Status.ActualScale != nil && *spa.Status.ActualScale > 0 {
10011002
// We must assign the traffic to the new revision, even of it is 0%. Otherwise, the PA will
10021003
// sometimes report the error of "No traffic. The target is not receiving traffic", which
10031004
// will kill the pods of the new revision during the progressive rollout.
10041005
// The last one of ro.Spec.StageTargetRevisions is certainly the RevisionTarget for the
1005-
// new revision,
1006+
// new revision.
10061007
newRevisionTarget := ro.Spec.StageTargetRevisions[len(ro.Spec.StageTargetRevisions)-1]
10071008
newRevisionTarget.Percent = ptr.Int64(int64(0))
10081009
revisionTarget = append(revisionTarget, newRevisionTarget)
10091010
}
1010-
} else {
1011-
// If the ro does not have the StageRevisionStatus in the status, use the existing one in route.
1012-
route, errRoute := routeLister.Get(ro.Name)
1013-
if errRoute == nil && len(route.Status.Traffic) > 0 {
1014-
traffics := route.Status.Traffic
1015-
//found := false
1016-
for index := range traffics {
1017-
if traffics[index].RevisionName == spaTargetRevName {
1018-
//found = true
1019-
continue
1020-
}
1021-
traffics[index].LatestRevision = ptr.Bool(false)
1022-
}
1023-
//if !found {
1024-
// // We must assign the traffic to the new revision, even of it is 0%. Otherwise, the PA will
1025-
// // sometimes report the error of "No traffic. The target is not receiving traffic", which
1026-
// // will kill the pods of the new revision during the progressive rollout.
1027-
// newRevisionTarget := ro.Spec.StageTargetRevisions[len(ro.Spec.StageTargetRevisions)-1]
1028-
// newRevisionTarget.Percent = ptr.Int64(int64(0))
1029-
//
1030-
// newRevisionTraffic := servingv1.TrafficTarget{
1031-
// ConfigurationName: name,
1032-
// LatestRevision: newRevisionTarget.LatestRevision,
1033-
// Percent: newRevisionTarget.Percent,
1034-
// Tag: newRevisionTarget.Tag,
1035-
// URL: newRevisionTarget.URL,
1036-
// }
1037-
// traffics = append(traffics, newRevisionTraffic)
1038-
//}
1039-
return traffics
1040-
}
10411011
}
10421012
}
10431013
}

pkg/reconciler/service/service_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ func TestTransformService(t *testing.T) {
956956
rc: &RolloutConfig{
957957
ProgressiveRolloutEnabled: true,
958958
ProgressiveRolloutStrategy: strategies.AvailabilityStrategy,
959+
RolloutDuration: "0",
959960
},
960961
service: &servingv1.Service{
961962
ObjectMeta: metav1.ObjectMeta{
@@ -1016,7 +1017,12 @@ func TestTransformService(t *testing.T) {
10161017
{
10171018
RevisionName: "rev-001",
10181019
LatestRevision: ptr.Bool(false),
1019-
Percent: ptr.Int64(100),
1020+
Percent: ptr.Int64(80),
1021+
},
1022+
{
1023+
ConfigurationName: "test-name",
1024+
Percent: ptr.Int64(20),
1025+
LatestRevision: ptr.Bool(true),
10201026
},
10211027
},
10221028
},
@@ -1051,13 +1057,13 @@ func TestTransformService(t *testing.T) {
10511057
Traffic: []servingv1.TrafficTarget{
10521058
{
10531059
RevisionName: "rev-001",
1054-
Percent: ptr.Int64(90),
1060+
Percent: ptr.Int64(80),
10551061
LatestRevision: ptr.Bool(false),
10561062
},
10571063
{
1058-
RevisionName: "rev-002",
1059-
Percent: ptr.Int64(10),
1060-
LatestRevision: ptr.Bool(true),
1064+
ConfigurationName: "test-name",
1065+
Percent: ptr.Int64(20),
1066+
LatestRevision: ptr.Bool(true),
10611067
},
10621068
},
10631069
},

0 commit comments

Comments
 (0)