@@ -975,15 +975,15 @@ func convertIntoTrafficTarget(name string, ro *v1.RolloutOrchestrator, rc *Rollo
975
975
976
976
spa , err := spaLister .Get (spaTargetRevName )
977
977
// 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 &&
979
979
minScale != nil && * targetNumberReplicas <= * minScale && * spa .Status .ActualScale < * targetNumberReplicas ) {
980
980
// If we have issues getting the spa, or the number of the replicas has reached the target number of
981
981
// the revision to scale up, we set the revisionTarget to ro.Spec.StageTargetRevisions.
982
982
983
983
// However, if there is no issue getting yhe spa, and the actual number of replicas is less than
984
984
// the target number of replicas, we need to use ro.Status.StageRevisionStatus or route.Status.Traffic
985
985
// 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" {
987
987
// Comment out the following lines for further consideration with resourceUtil mode
988
988
// || (strings.EqualFold(rc.ProgressiveRolloutStrategy, strategies.ResourceUtilStrategy) && !trafficDriven && !lastStage) {
989
989
if len (ro .Status .StageRevisionStatus ) > 0 {
@@ -997,47 +997,17 @@ func convertIntoTrafficTarget(name string, ro *v1.RolloutOrchestrator, rc *Rollo
997
997
}
998
998
revisionTarget [index ].LatestRevision = ptr .Bool (false )
999
999
}
1000
- if ! found {
1000
+
1001
+ if ! found && spa != nil && spa .Status .ActualScale != nil && * spa .Status .ActualScale > 0 {
1001
1002
// We must assign the traffic to the new revision, even of it is 0%. Otherwise, the PA will
1002
1003
// sometimes report the error of "No traffic. The target is not receiving traffic", which
1003
1004
// will kill the pods of the new revision during the progressive rollout.
1004
1005
// The last one of ro.Spec.StageTargetRevisions is certainly the RevisionTarget for the
1005
- // new revision,
1006
+ // new revision.
1006
1007
newRevisionTarget := ro .Spec .StageTargetRevisions [len (ro .Spec .StageTargetRevisions )- 1 ]
1007
1008
newRevisionTarget .Percent = ptr .Int64 (int64 (0 ))
1008
1009
revisionTarget = append (revisionTarget , newRevisionTarget )
1009
1010
}
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
- }
1041
1011
}
1042
1012
}
1043
1013
}
0 commit comments