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

[OCPCLOUD-1350] Implement machine pre-drain and pre-terminate deletion hooks #945

Merged

Conversation

JoelSpeed
Copy link
Contributor

@JoelSpeed JoelSpeed commented Nov 4, 2021

This PR implements the feature part of openshift/enhancements#862.

This does not include the conditions part of the enhancement which will follow up in a later PR.

This will ensure that when Machine Deletion Hooks are in play, that the machine controller behaves as described in the enhancement by either blocking the drain or blocking the termination of the Machine.

Something I realised while implementing this is that we should only honour the pre-drain hooks when we are actually attempting a drain. There are certain scenarios where pre-drain hooks wouldn't make sense, eg, when a node doesn't actually exist. So that is included within this PR and can be seen in the unit tests included.

This is blocked on the API PR being merged and the api dependency commit being updated

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2021
@JoelSpeed JoelSpeed force-pushed the machine-deletion-hooks branch from 47fd6e9 to c23a2e7 Compare November 5, 2021 11:53
Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

/approve
Looks fine, we can work on merging it after api PR is done

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 8, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demichev

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 Nov 8, 2021
@JoelSpeed JoelSpeed force-pushed the machine-deletion-hooks branch 2 times, most recently from e6f4449 to ce1a6cc Compare November 18, 2021 11:26
@@ -39,6 +40,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
)

const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Copy link
Contributor

Choose a reason for hiding this comment

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

just out of curiosity, are we limited by an English alphabet here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validation on the field I had down as [a-zA-Z]+, do you think that is too restrictive? The proposal suggests a CamelCase string and something easily computer readable, hence sticking to basic ascii.

},
updateAfterDelete: true,
updateMachine: func(m *machinev1.Machine) {
m.Annotations = map[string]string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

does this update remove the lifecycle hook?

@JoelSpeed JoelSpeed force-pushed the machine-deletion-hooks branch 3 times, most recently from 3b945d4 to 5428012 Compare November 22, 2021 14:53
@JoelSpeed JoelSpeed changed the title [WIP][OCPCLOUD-1350] Implement machine pre-drain and pre-terminate deletion hooks [OCPCLOUD-1350] Implement machine pre-drain and pre-terminate deletion hooks Nov 22, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 22, 2021
@JoelSpeed JoelSpeed force-pushed the machine-deletion-hooks branch from 5428012 to 73cbce6 Compare November 22, 2021 15:07
Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

thanks Joel, makes sense to me. i think it might be nice to have a unit test for GetChangedLifecycleHooks, but it's not a blocker for me (i know we are testing it transitively).
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2021
@JoelSpeed JoelSpeed force-pushed the machine-deletion-hooks branch from 73cbce6 to 45c1e52 Compare November 22, 2021 16:09
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2021
@elmiko
Copy link
Contributor

elmiko commented Nov 22, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 22, 2021

@JoelSpeed: 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-vsphere 45c1e52 link false /test e2e-vsphere
ci/prow/e2e-gcp 45c1e52 link false /test e2e-gcp

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.

4 participants