Commit f17a572e authored by dhilipkumars's avatar dhilipkumars

SetNewReplicaSetAnnotations() should compare revisions as numbers than strings

parent 04df1f56
...@@ -253,7 +253,23 @@ func SetNewReplicaSetAnnotations(deployment *extensions.Deployment, newRS *exten ...@@ -253,7 +253,23 @@ func SetNewReplicaSetAnnotations(deployment *extensions.Deployment, newRS *exten
// The newRS's revision should be the greatest among all RSes. Usually, its revision number is newRevision (the max revision number // The newRS's revision should be the greatest among all RSes. Usually, its revision number is newRevision (the max revision number
// of all old RSes + 1). However, it's possible that some of the old RSes are deleted after the newRS revision being updated, and // of all old RSes + 1). However, it's possible that some of the old RSes are deleted after the newRS revision being updated, and
// newRevision becomes smaller than newRS's revision. We should only update newRS revision when it's smaller than newRevision. // newRevision becomes smaller than newRS's revision. We should only update newRS revision when it's smaller than newRevision.
if oldRevision < newRevision {
oldRevisionInt, err := strconv.ParseInt(oldRevision, 10, 64)
if err != nil {
if oldRevision != "" {
glog.Warningf("Updating replica set revision OldRevision not int %s", err)
return false
}
//If the RS annotation is empty then initialise it to 0
oldRevisionInt = 0
}
newRevisionInt, err := strconv.ParseInt(newRevision, 10, 64)
if err != nil {
glog.Warningf("Updating replica set revision NewRevision not int %s", err)
return false
}
glog.Warningf("OldRevision=%d Newrevsion=%d\n", oldRevisionInt, newRevisionInt)
if oldRevisionInt < newRevisionInt {
newRS.Annotations[RevisionAnnotation] = newRevision newRS.Annotations[RevisionAnnotation] = newRevision
annotationChanged = true annotationChanged = true
glog.V(4).Infof("Updating replica set %q revision to %s", newRS.Name, newRevision) glog.V(4).Infof("Updating replica set %q revision to %s", newRS.Name, newRevision)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment