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

Make zone spread only apply within a given revision #1724

Merged
merged 1 commit into from Sep 9, 2022

Conversation

alvaroaleman
Copy link
Contributor

@alvaroaleman alvaroaleman commented Sep 2, 2022

We currently apply zone spread for all revisions for a given workload.
This means that a new revision can only be rolled out after a replica of
the old revision was removed.

This PR fixes that by:

  • Moving the calculation of the zone spread affinity into the ApplyTo
    funcs
  • Calculating a hash of the podTemplate there
  • Applying a label to the pod with that hash
  • Using all pod labels including the one with the hash in the
    AntiAffinity rule

As a sideeffect, this removes the requirement to know the pods labels by
the time DeploymentConfig.SetDefaults() is called. In many cases, they
weren't known by that time so it was called with a nil labelmap, which
resulted in the Zone spread code being short-circuited. With this
change, everything that calls SetDefaults and has more than one replica
will get the zone spread, as it is makes sense for all components.

I manually verified that with this change and a
sufficiently-sized management cluster, a HA controlplane upgrade results
in zero failed scheduling events.

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, use fixes #<issue_number>(, fixes #<issue_number>, ...) format, where issue_number might be a GitHub issue, or a Jira story:
ref https://issues.redhat.com/browse/HOSTEDCP-518

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2022
@csrwng
Copy link
Contributor

csrwng commented Sep 3, 2022

Looks like you need to run unit tests with UPDATE=1, other than that, it looks good to me.
Something that occurred to me is that maybe it would be a good idea to extract this code into its own module (not necessarily a separate repo) so that it can be reused by other operators that will place pods into the control plane namespace like CNO and storage. Otherwise we need to keep making the same changes there as well.

1 similar comment
@csrwng
Copy link
Contributor

csrwng commented Sep 3, 2022

Looks like you need to run unit tests with UPDATE=1, other than that, it looks good to me.
Something that occurred to me is that maybe it would be a good idea to extract this code into its own module (not necessarily a separate repo) so that it can be reused by other operators that will place pods into the control plane namespace like CNO and storage. Otherwise we need to keep making the same changes there as well.

@eranco74
Copy link
Contributor

eranco74 commented Sep 4, 2022

/test capi-provider-agent-sanity

1 similar comment
@eranco74
Copy link
Contributor

eranco74 commented Sep 4, 2022

/test capi-provider-agent-sanity

@eranco74
Copy link
Contributor

eranco74 commented Sep 4, 2022

Prow issue, the test never started
/test capi-provider-agent-sanity

func (c *DeploymentConfig) setMultizoneSpread(labels map[string]string) {
if labels == nil {
func (c *DeploymentConfig) setMultizoneSpread(pod *corev1.PodTemplateSpec) {
if !c.setDefaults || c.Replicas <= 1 {
return
Copy link
Member

@enxebre enxebre Sep 5, 2022

Choose a reason for hiding this comment

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

do we really need any check? since we are using a unique hash per Deployment I think could simplify and apply this unconditionally now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just keeps the previous behavior

Copy link
Member

Choose a reason for hiding this comment

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

I consider current behaviour and implementation suboptimal. Using the hash enables us to apply always a consistent set of labels and affinity unconditionally. That simplifies code but also reduce the number of different config combinations and divergence on the clusters we create.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@alvaroaleman
Copy link
Contributor Author

alvaroaleman commented Sep 5, 2022

Btw, this change shaves a good 25% of the runtime of our e2e tests off. Without this, we always need more than 2h, with this, we need around 1h30m.

We likely need openshift/release#31897 to make it stable though.

@alvaroaleman
Copy link
Contributor Author

@enxebre removed the setDefaults, ptal. Could you also have a look at openshift/release#31897 which is likely required to merge this?

@enxebre
Copy link
Member

enxebre commented Sep 7, 2022

lgtm, unit and e2e fails though

We currently apply zone spread for all revisions for a given workload.
This means that a new revision can only be rolled out after a replica of
the old revision was removed.

This PR fixes that by:
* Moving the calculation of the zone spread affinity into the ApplyTo
  funcs
* Calculating a hash of the podTemplate there
* Applying a label to the pod with that hash
* Using all pod labels including the one with the hash in the
  AntiAffinity rule

As a sideeffect, this removes the requirement to know the pods labels by
the time DeploymentConfig.SetDefaults() is called. In many cases, they
weren't known by that time so it was called with a nil labelmap, which
resulted in the Zone spread code being short-circuited. With this
change, everything that calls SetDefaults and has more than one replica
will get the zone spread, as it is makes sense for all components.

I manually verified that with this change and a
sufficiently-sized management cluster, a HA controlplane upgrade results
in zero failed scheduling events.
@alvaroaleman
Copy link
Contributor Author

/retest-required

2 similar comments
@alvaroaleman
Copy link
Contributor Author

/retest-required

@alvaroaleman
Copy link
Contributor Author

/retest-required

@alvaroaleman
Copy link
Contributor Author

@enxebre the presubmit finally passed without any failed scheduling event. The upgrade failure is due to OCPBUGS-990, until we have a fix for that promoted into an N-1 release, it won't pass but that is unrelated to this change

@enxebre
Copy link
Member

enxebre commented Sep 9, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 9, 2022
@alvaroaleman
Copy link
Contributor Author

The upgrade job is known broken and everything else passed
/override ci/prow/e2e-aws

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2022

@alvaroaleman: Overrode contexts on behalf of alvaroaleman: ci/prow/e2e-aws

In response to this:

The upgrade job is known broken and everything else passed
/override ci/prow/e2e-aws

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2022

@alvaroaleman: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-kubevirt-gcp-ovn 3c60cb9 link false /test e2e-kubevirt-gcp-ovn
ci/prow/capi-provider-agent-sanity 3c60cb9 link false /test capi-provider-agent-sanity

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants