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
Handle namespace deletion more gracefully in built-in controllers #84123
Changes from all commits
a62c5b2
937ef77
dc0c21c
2e8ace8
8f74c89
c6e34e5
bd92607
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 |
---|---|---|
|
@@ -523,15 +523,22 @@ func (rsc *ReplicaSetController) manageReplicas(filteredPods []*v1.Pod, rs *apps | |
// event spam that those failures would generate. | ||
successfulCreations, err := slowStartBatch(diff, controller.SlowStartInitialBatchSize, func() error { | ||
err := rsc.podControl.CreatePodsWithControllerRef(rs.Namespace, &rs.Spec.Template, rs, metav1.NewControllerRef(rs, rsc.GroupVersionKind)) | ||
if err != nil && errors.IsTimeout(err) { | ||
// Pod is created but its initialization has timed out. | ||
// If the initialization is successful eventually, the | ||
// controller will observe the creation via the informer. | ||
// If the initialization fails, or if the pod keeps | ||
// uninitialized for a long time, the informer will not | ||
// receive any update, and the controller will create a new | ||
// pod when the expectation expires. | ||
return nil | ||
if err != nil { | ||
if errors.HasStatusCause(err, v1.NamespaceTerminatingCause) { | ||
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. Nit: not sure why you need to have two ifs if both return the same, comment for both handled in one should be sufficient. |
||
// if the namespace is being terminated, we don't have to do | ||
// anything because any creation will fail | ||
return nil | ||
} | ||
if errors.IsTimeout(err) { | ||
// Pod is created but its initialization has timed out. | ||
// If the initialization is successful eventually, the | ||
// controller will observe the creation via the informer. | ||
// If the initialization fails, or if the pod keeps | ||
// uninitialized for a long time, the informer will not | ||
// receive any update, and the controller will create a new | ||
// pod when the expectation expires. | ||
return nil | ||
} | ||
} | ||
return err | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,7 +213,10 @@ func (c *ServiceAccountsController) syncNamespace(key string) error { | |
sa.Namespace = ns.Name | ||
|
||
if _, err := c.client.CoreV1().ServiceAccounts(ns.Name).Create(&sa); err != nil && !apierrs.IsAlreadyExists(err) { | ||
createFailures = append(createFailures, err) | ||
// we can safely ignore terminating namespace errors | ||
if !apierrs.HasStatusCause(err, v1.NamespaceTerminatingCause) { | ||
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. Nit: this could be placed next to |
||
createFailures = append(createFailures, err) | ||
} | ||
} | ||
} | ||
|
||
|
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.
Will work only for unwrapped errors, but we might make it better when we get golang 1.13
I don't see the calls there wrapping the errors with context so this should be good for now