-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Do not cleanup already deleted replica sets and add more logging around it #41145
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,15 +547,17 @@ func (dc *DeploymentController) cleanupDeployment(oldRSs []*extensions.ReplicaSe | |
} | ||
|
||
sort.Sort(controller.ReplicaSetsByCreationTimestamp(oldRSs)) | ||
glog.V(2).Infof("Looking to cleanup old replica sets for deployment %q", deployment.Name) | ||
|
||
var errList []error | ||
// TODO: This should be parallelized. | ||
for i := int32(0); i < diff; i++ { | ||
rs := oldRSs[i] | ||
// Avoid delete replica set with non-zero replica counts | ||
if rs.Status.Replicas != 0 || *(rs.Spec.Replicas) != 0 || rs.Generation > rs.Status.ObservedGeneration { | ||
if rs.Status.Replicas != 0 || *(rs.Spec.Replicas) != 0 || rs.Generation > rs.Status.ObservedGeneration || rs.DeletionTimestamp != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we do this before the for loop so that we get accurate |
||
continue | ||
} | ||
glog.V(2).Infof("Trying to cleanup replica set %q for deployment %q", rs.Name, deployment.Name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V(2) looks like pretty low. With which level are e2e tests run? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't expect it be high :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From AWS I can get back V(2) - I will open an issue to bump these once I get a clean run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lgtm |
||
if err := dc.client.Extensions().ReplicaSets(rs.Namespace).Delete(rs.Name, nil); err != nil && !errors.IsNotFound(err) { | ||
glog.V(2).Infof("Failed deleting old replica set %v for deployment %v: %v", rs.Name, deployment.Name, err) | ||
errList = append(errList, err) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3422,17 +3422,27 @@ func WaitForPodsReady(c clientset.Interface, ns, name string, minReadySeconds in | |
|
||
// Waits for the deployment to clean up old rcs. | ||
func WaitForDeploymentOldRSsNum(c clientset.Interface, ns, deploymentName string, desiredRSNum int) error { | ||
return wait.Poll(Poll, 5*time.Minute, func() (bool, error) { | ||
var oldRSs []*extensions.ReplicaSet | ||
var d *extensions.Deployment | ||
|
||
pollErr := wait.PollImmediate(Poll, 5*time.Minute, func() (bool, error) { | ||
deployment, err := c.Extensions().Deployments(ns).Get(deploymentName, metav1.GetOptions{}) | ||
if err != nil { | ||
return false, err | ||
} | ||
_, oldRSs, err := deploymentutil.GetOldReplicaSets(deployment, c) | ||
d = deployment | ||
|
||
_, oldRSs, err = deploymentutil.GetOldReplicaSets(deployment, c) | ||
if err != nil { | ||
return false, err | ||
} | ||
return len(oldRSs) == desiredRSNum, nil | ||
}) | ||
if pollErr == wait.ErrWaitTimeout { | ||
pollErr = fmt.Errorf("%d old replica sets were not cleaned up for deployment %q", len(oldRSs)-desiredRSNum, deploymentName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we not want to print the namespace for the deployment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed here, the ns is available via other means (events for example) |
||
logReplicaSetsOfDeployment(d, oldRSs, nil) | ||
} | ||
return pollErr | ||
} | ||
|
||
func logReplicaSetsOfDeployment(deployment *extensions.Deployment, allOldRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not about logging, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, but it seems like a possible source of the problem for the flaky test - see #41163 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move it to its own commit? And mention it in the PR. Otherwise, it looks like this only changes some logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be accompanying unit test update to cover this case as well?