Add a pod disruption budget for ingress controllers#272
Add a pod disruption budget for ingress controllers#272openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Conversation
| func RouterPodDisruptionBudgetName(ic *operatorv1.IngressController) types.NamespacedName { | ||
| return types.NamespacedName{ | ||
| Namespace: "openshift-ingress", | ||
| Name: "router-" + ic.Name, |
There was a problem hiding this comment.
using the word "router" in any of our resources was a mistake from the start — could we avoid propagating it further?
There was a problem hiding this comment.
We could, but this would be the odd resource out till we renamed other resources, and I am not aware of plans to rename other resources. What name do you propose? Just use the ingresscontroller's name, or prefix "ingress-" or "ingresscontroller-" or similar to the name?
There was a problem hiding this comment.
I like "ingress-", but if you want to just stay consistent with router I'm fine with that too at this point
|
Any value in trying to devise an e2e test for this? |
Probably. Should it be anything more sophisticated than checking that a pod disruption budget exists for the default ingress controller? |
f97ff92 to
03f16d6
Compare
|
/retest |
Would that be much more useful than a unit test? At the end of the day I think we can trust the disruption budget feature in k8s itself works, so if we know we're setting the right fields on the deployment, maybe that's enough? |
|
| // Boolean indicating whether the PDB was created, and an error value. | ||
| func (r *reconciler) createRouterPodDisruptionBudget(pdb *policyv1beta1.PodDisruptionBudget) (bool, error) { | ||
| if err := r.client.Create(context.TODO(), pdb); err != nil { | ||
| return false, err |
There was a problem hiding this comment.
What if the error is because the resource already exists?
There was a problem hiding this comment.
ensureRouterPodDisruptionBudget should call createRouterPodDisruptionBudget only if the resource did not already exist. Morever, returning a non-nil error value should just cause a retry of the reconciliation, which should be reasonably innocuous. We've been removing similar IsAlreadyExists checks in PRs such as #151 and #184.
| } | ||
| return false, err | ||
| } | ||
| log.Info("created pod disruption budget", "namespace", pdb.Namespace, "name", pdb.Name) |
There was a problem hiding this comment.
Says created when it means deleted, and the logging is already happening on the calling side anyway
| if err := r.client.Update(context.TODO(), updated); err != nil { | ||
| return false, err | ||
| } | ||
| log.Info("updated pod disruption budget", "namespace", updated.Namespace, "name", updated.Name) |
There was a problem hiding this comment.
Logging is happening on the calling side already
| if err := r.client.Create(context.TODO(), pdb); err != nil { | ||
| return false, err | ||
| } | ||
| log.Info("created pod disruption budget", "namespace", pdb.Namespace, "name", pdb.Name) |
There was a problem hiding this comment.
Logging is happening on the calling side already
For each ingress controller, create a pod disruption budget with a maximum of 25% unavailable pods. * manifests/00-cluster-role.yaml: Allow the operator to manage PodDisruptionBudget resources. * pkg/operator/controller/ingress/controller.go (ensureIngressController): Call ensureRouterPodDisruptionBudget. * pkg/operator/controller/ingress/poddisruptionbudget.go: New file. (ensureRouterPodDisruptionBudget): New method. Ensure the appropriate pod disruption budget exists for the given ingress controller. Get the current one using currentRouterPodDisruptionBudget. If none exists, create one using the desiredRouterPodDisruptionBudget function and createRouterPodDisruptionBudget method. If one already exists, update it if necessary using updateRouterPodDisruptionBudget, or delete it using deleteRouterPodDisruptionBudget if none is desired. (desiredRouterPodDisruptionBudget): New function. (currentRouterPodDisruptionBudget): New method. (createRouterPodDisruptionBudget): New method. (deleteRouterPodDisruptionBudget): New method. (updateRouterPodDisruptionBudget): New method. Use podDisruptionBudgetChanged to determine whether an update is needed. (podDisruptionBudgetChanged): New function. * pkg/operator/controller/names.go (RouterPodDisruptionBudgetName): New function. * test/e2e/operator_test.go (TestPodDisruptionBudgetExists): New test. Verify that a PodDisruptionBudget resource exists for the default ingresscontroller.
03f16d6 to
35d4f4f
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ironcladlou, Miciah The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
For each ingress controller, create a pod disruption budget with a maximum of 25% unavailable pods.
manifests/00-cluster-role.yaml: Allow the operator to managePodDisruptionBudgetresources.pkg/operator/controller/ingress/controller.go(ensureIngressController): CallensureRouterPodDisruptionBudget.pkg/operator/controller/ingress/poddisruptionbudget.go: New file.(
ensureRouterPodDisruptionBudget): New method. Ensure the appropriate pod disruption budget exists for the given ingress controller. Get the current one usingcurrentRouterPodDisruptionBudget. If none exists, create one using thedesiredRouterPodDisruptionBudgetfunction andcreateRouterPodDisruptionBudgetmethod. If one already exists, update it if necessary usingupdateRouterPodDisruptionBudget, or delete it usingdeleteRouterPodDisruptionBudgetif none is desired.(
desiredRouterPodDisruptionBudget): New function.(
currentRouterPodDisruptionBudget): New method.(
createRouterPodDisruptionBudget): New method.(
deleteRouterPodDisruptionBudget): New method.(
updateRouterPodDisruptionBudget): New method. UsepodDisruptionBudgetChangedto determine whether an update is needed.(
podDisruptionBudgetChanged): New function.pkg/operator/controller/names.go(RouterPodDisruptionBudgetName): New function.test/e2e/operator_test.go(TestPodDisruptionBudgetExists): New test. Verify that aPodDisruptionBudgetresource exists for the default ingresscontroller.This PR is a spin-off from #240.