Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controller: decouple cleanup policy from deployment strategies #40081

Merged
merged 1 commit into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion pkg/controller/deployment/deployment_controller.go
Expand Up @@ -543,7 +543,26 @@ func (dc *DeploymentController) syncDeployment(key string) error {
return dc.syncStatusOnly(d)
}

err = dc.classifyReplicaSets(deployment)
// Why run the cleanup policy only when there is no rollback request?
// The thing with the cleanup policy currently is that it is far from smart because it takes into account
// the latest replica sets while it should instead retain the latest *working* replica sets. This means that
// you can have a cleanup policy of 1 but your last known working replica set may be 2 or 3 versions back
// in the history.
// Eventually we will want to find a way to recognize replica sets that have worked at some point in time
// (and chances are higher that they will work again as opposed to others that didn't) for candidates to
// automatically roll back to (#23211) and the cleanup policy should help.
if d.Spec.RollbackTo == nil {
_, oldRSs, err := dc.getAllReplicaSetsAndSyncRevision(d, false)
if err != nil {
return err
}
// So far the cleanup policy was executed once a deployment was paused, scaled up/down, or it
// succesfully completed deploying a replica set. Decouple it from the strategies and have it
// run almost unconditionally - cleanupDeployment is safe by default.
dc.cleanupDeployment(oldRSs, d)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this happen when RollbackTo != nil?

}

err = dc.classifyReplicaSets(d)
if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/deployment/recreate.go
Expand Up @@ -73,8 +73,6 @@ func (dc *DeploymentController) rolloutRecreate(deployment *extensions.Deploymen
return dc.syncRolloutStatus(allRSs, newRS, deployment)
}

dc.cleanupDeployment(oldRSs, deployment)

// Sync deployment status
return dc.syncRolloutStatus(allRSs, newRS, deployment)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/deployment/rolling.go
Expand Up @@ -55,8 +55,6 @@ func (dc *DeploymentController) rolloutRolling(deployment *extensions.Deployment
return dc.syncRolloutStatus(allRSs, newRS, deployment)
}

dc.cleanupDeployment(oldRSs, deployment)

// Sync deployment status
return dc.syncRolloutStatus(allRSs, newRS, deployment)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/deployment/sync.go
Expand Up @@ -58,7 +58,6 @@ func (dc *DeploymentController) sync(deployment *extensions.Deployment) error {
// so we can abort this resync
return err
}
dc.cleanupDeployment(oldRSs, deployment)

allRSs := append(oldRSs, newRS)
return dc.syncDeploymentStatus(allRSs, newRS, deployment)
Expand Down