clean rs by revision instead of creat timestamp
This commit is contained in:
parent
b749a3a421
commit
ab1be93809
@ -448,7 +448,7 @@ func (dc *DeploymentController) cleanupDeployment(oldRSs []*apps.ReplicaSet, dep
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(controller.ReplicaSetsByCreationTimestamp(cleanableRSes))
|
sort.Sort(deploymentutil.ReplicaSetsByRevision(cleanableRSes))
|
||||||
klog.V(4).Infof("Looking to cleanup old replica sets for deployment %q", deployment.Name)
|
klog.V(4).Infof("Looking to cleanup old replica sets for deployment %q", deployment.Name)
|
||||||
|
|
||||||
for i := int32(0); i < diff; i++ {
|
for i := int32(0); i < diff; i++ {
|
||||||
|
@ -949,3 +949,18 @@ func GetDeploymentsForReplicaSet(deploymentLister appslisters.DeploymentLister,
|
|||||||
|
|
||||||
return deployments, nil
|
return deployments, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReplicaSetsByRevision sorts a list of ReplicaSet by revision, using their creation timestamp or name as a tie breaker.
|
||||||
|
// By using the creation timestamp, this sorts from old to new replica sets.
|
||||||
|
type ReplicaSetsByRevision []*apps.ReplicaSet
|
||||||
|
|
||||||
|
func (o ReplicaSetsByRevision) Len() int { return len(o) }
|
||||||
|
func (o ReplicaSetsByRevision) Swap(i, j int) { o[i], o[j] = o[j], o[i] }
|
||||||
|
func (o ReplicaSetsByRevision) Less(i, j int) bool {
|
||||||
|
revision1, err1 := Revision(o[i])
|
||||||
|
revision2, err2 := Revision(o[j])
|
||||||
|
if err1 != nil || err2 != nil || revision1 == revision2 {
|
||||||
|
return controller.ReplicaSetsByCreationTimestamp(o).Less(i, j)
|
||||||
|
}
|
||||||
|
return revision1 < revision2
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user