SetNewReplicaSetAnnotations() should compare revisions as numbers than strings

This commit is contained in:
dhilipkumars 2017-07-21 10:42:02 +05:30
parent 04df1f562b
commit f17a572ece

View File

@ -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
// 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.
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
annotationChanged = true
glog.V(4).Infof("Updating replica set %q revision to %s", newRS.Name, newRevision)