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

Bug 1687940: deployment: fix scope of pod anti-affinity #167

Merged
merged 1 commit into from Mar 21, 2019

Conversation

ironcladlou
Copy link
Contributor

Before, the anti-affinity rule for ingress controller deployment pods was such
that no controller pods could colocate on a node, even if they were for
different ingress controllers. Now, pods for different ingress controllers can
be colocated on a node.

Fixes bug https://bugzilla.redhat.com/show_bug.cgi?id=1687940.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 13, 2019
@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 13, 2019
@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou ironcladlou changed the title WIP: Bug 1687940: deployment: fix scope of pod anti-affinity Bug 1687940: deployment: fix scope of pod anti-affinity Mar 14, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 14, 2019
@ironcladlou
Copy link
Contributor Author

Not seeing anything suspicious about the router in the logs, the flakes are concerning...

/retest

@ironcladlou
Copy link
Contributor Author

/retest

@danehans
Copy link
Contributor

/test e2e-aws-operator
/test e2e-aws

@ironcladlou
Copy link
Contributor Author

/retest

1 similar comment
@ironcladlou
Copy link
Contributor Author

/retest

@Miciah
Copy link
Contributor

Miciah commented Mar 15, 2019

Need to fix the label selectors in RouterServiceInternal and desiredLoadBalancerService.

@ironcladlou
Copy link
Contributor Author

Good catch — there might be a gap here in how we construct the selector if it must be shared

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 15, 2019
@ironcladlou
Copy link
Contributor Author

Well, turns out that the YAML/manifestfactory business was hiding an entanglement of the deployment pod selector (i.e. in addition to the deployment itself, the internal service also needs to match the deployment pods). So I gave the internal service the usual refactoring treatment and extracted the naming and deployment pod selector stuff into names.go.

A rotten cluster has stymied my testing, so might have to continue this one on Monday (unless it happens that the CI tests pass and there are no issues during code review).

}

s.Spec.Selector = map[string]string{
s.Spec.Selector[controllerDeploymentLabel]: IngressControllerDeploymentLabel(ic),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is already an improvement, but another possibility I see is to use the selector from the deployment itself here (perhaps by extracting a function into names.go which returns the deployment selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and did this refactor too

@ironcladlou
Copy link
Contributor Author

So here's my post-hoc justification for increasing the complexity of the PR:

The affinity setup in the manifest YAML is already pretty complex, and at the time I introduced it I thought the value would be static. However, as the bug shows, some of the affinity definition is actually dynamic as a function of the ingress controller. One option would have been to leave the static parts in YAML and mutate just the dynamic piece at runtime, and there's precedent within the codebase for that. However, based on previous conversations, I thought it would be easier to comprehend if we kept the whole affinity piece defined in code closer to the mutation. I also cleaned up the deployment selector names as part of that, which I thought would be trivial.

But, during the course of the refactor, it became clear that the deployment pod selector is used in many contexts, and the as a result I ended up having to touch the related pieces.

I'm hoping the improved clarity of coupling between these parts will justify the expanded scope of the changes. Thoughts?

Copy link
Contributor

@Miciah Miciah left a comment

Choose a reason for hiding this comment

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

Should delete ServingCertSecretAnnotation in manifests.go.

)

// ensureInternalRouterServiceForIngress ensures that an internal service exists
// for a given ClusterIngress.
Copy link
Contributor

Choose a reason for hiding this comment

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

"ClusterIngress"→"IngressController"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -5,12 +5,8 @@ apiVersion: v1
metadata:
# Name and Annotations are set at runtime.
namespace: openshift-ingress
Copy link
Contributor

Choose a reason for hiding this comment

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

Specifying namespace in the asset is redundant now that desiredInternalIngressControllerService sets it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
deployment.Spec.Selector = IngressControllerDeploymentPodSelector(ci)

deployment.Spec.Template.Labels = IngressControllerDeploymentPodSelector(ci).MatchLabels
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you could even simplify this to deployment.Spec.Template.Labels = deployment.Spec.Selector.MatchLabels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@Miciah
Copy link
Contributor

Miciah commented Mar 15, 2019

test/e2e/operator_test.go is full of references to the old router-... names.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 18, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 18, 2019
@ironcladlou
Copy link
Contributor Author

Updated test/e2e/operator_test.go to use naming functions for the most part (and removed a redundant test).

Ready for review again.

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

/retest while I look at the failures...

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

Looks like CI account issues.

/retest

@@ -175,69 +175,6 @@ func TestClusterIngressControllerCreateDelete(t *testing.T) {
}
}

func TestRouterServiceInternalEndpoints(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious to know why this test is being removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO the test isn't buying us much other than asserting the service exists, which is covered implicitly elsewhere. It did check the endpoints, but that's such a specific test you could cover with a unit (e.g. do the selectors match) and there's origin e2e coverage for metrics which actually uses the service (currently broken).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke offline and decided to do a followup which introduces a new test variant which exercises the metrics endpoint through the service (which will both implicitly test the endpoints and also the actual functional area around the internal service, which is enabling metrics integration)

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

Still trying to get a cluster to try and reproduce any issues. Operator logs and router logs look fine...

/retest

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

Okay, finally reproduced some of these in a local cluster.

@ironcladlou
Copy link
Contributor Author

ironcladlou commented Mar 20, 2019

Before, the anti-affinity rule for ingress controller deployment pods was such
that no controller pods could colocate on a node, even if they were for
different ingress controllers. Now, pods for different ingress controllers can
be colocated on a node.

Fixes bug https://bugzilla.redhat.com/show_bug.cgi?id=1687940.
Copy link

@pravisankar pravisankar left a comment

Choose a reason for hiding this comment

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

Minor nit, otherwise LGTM

spec:
type: ClusterIP
selector:
app: router

Choose a reason for hiding this comment

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

Recent changes are hinting us that we don't have much value in creating assets anymore.
Probably we should ditch assets and create objects internally in the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we keep the assets, maybe we could at least use more abstract names, such as ClusterIPService, similar to how we have LoadBalancerService. I wouldn't object to removing the assets entirely though.

// ensureInternalRouterServiceForIngress ensures that an internal service exists
// for a given IngressController.
func (r *reconciler) ensureInternalIngressControllerService(ic *operatorv1.IngressController, deploymentRef metav1.OwnerReference) (*corev1.Service, error) {
desired := desiredInternalIngressControllerService(ic, deploymentRef)

Choose a reason for hiding this comment

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

This line can be moved to line 33 where we use this desired object.

Copy link
Contributor

@Miciah Miciah left a comment

Choose a reason for hiding this comment

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

manifests.go still has an unused definition for ServingCertSecretAnnotation.

deployment.Labels = map[string]string{}
deployment.Labels = map[string]string{
// associate the deployment with the ingresscontroller
manifests.OwningClusterIngressLabel: ci.Name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be using IngressControllerDeploymentLabel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, this is the same as before, and deploymentLabel is for ingress.operator.openshift.io/ingress-controller-deployment — we might need to audit our labels generallly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Meant for this comment to apply to controller_internal_service.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And no, this was to associate the deployment with the ingresscontroller, which is the intent of the label... IngressControllerDeploymentLabel was meant to be a way to associate other stuff with the deployment itself. The naming is probably poor

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the intended use of IngressControllerDeploymentLabel? I was assuming it was, "I have an ingresscontroller and need the label I would use to identify it."

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, just saw your last comment (GitHub didn't show it when I submitted mine last comment). I see now, IngressControllerDeploymentLabel identifies the deployment, and we need a label that identifies the ingresscontroller (for which we do not yet have a function). Please disregard my preceding comments.

s.Name = name.Name

s.Labels = map[string]string{
manifests.OwningClusterIngressLabel: ic.Name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be using IngressControllerDeploymentLabel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if it matters since there's an owner ref to the deployment already

@ironcladlou
Copy link
Contributor Author

/retest

@Miciah
Copy link
Contributor

Miciah commented Mar 20, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2019
Copy link

@pravisankar pravisankar left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ironcladlou, Miciah, pravisankar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Miciah,ironcladlou,pravisankar]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Miciah
Copy link
Contributor

Miciah commented Mar 20, 2019

level=error msg="4 errors occurred:"
level=error msg="\t* module.vpc.aws_route_table_association.private_routing[2]: 1 error occurred:"
level=error msg="\t* aws_route_table_association.private_routing.2: timeout while waiting for state to become 'success' (timeout: 5m0s)"
level=error
level=error
level=error msg="\t* module.vpc.aws_route_table_association.route_net[0]: 1 error occurred:"
level=error msg="\t* aws_route_table_association.route_net.0: timeout while waiting for state to become 'success' (timeout: 5m0s)"
level=error
level=error
level=error msg="\t* module.vpc.aws_route_table_association.route_net[2]: 1 error occurred:"
level=error msg="\t* aws_route_table_association.route_net.2: timeout while waiting for state to become 'success' (timeout: 5m0s)"
level=error
level=error
level=error msg="\t* module.vpc.aws_route_table_association.route_net[3]: 1 error occurred:"
level=error msg="\t* aws_route_table_association.route_net.3: timeout while waiting for state to become 'success' (timeout: 5m0s)"

/test e2e-aws-operator

@Miciah
Copy link
Contributor

Miciah commented Mar 20, 2019

level=info msg="Waiting up to 30m0s for the cluster at https://api.ci-op-qdt49y5z-43abb.origin-ci-int-aws.dev.rhcloud.com:6443 to initialize..."
level=fatal msg="failed to initialize the cluster: timed out waiting for the condition"

/test e2e-aws-operator

@openshift-merge-robot openshift-merge-robot merged commit 3f228cf into openshift:master Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants