Skip to content

Add MachineSet ControlPlane webhooks #617

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

Closed

Conversation

michaelgugino
Copy link
Contributor

@michaelgugino michaelgugino commented Jun 18, 2020

Add webhooks for Delete and Update operations
on MachineSets that are identified to be
Control Plane members. These webhooks prevent
deleting these MachineSets or updating them
to become non-CP MachineSets (in order to
further prevent them from being deleted or
misconfigured)

@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 Jun 18, 2020
apiVersions:
- v1beta1
operations:
- UPDATE
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 unit tests don't seem to like this being here.

@mtnbikenc
Copy link
Member

FYI, this PR caused a failure when running oc delete machinesets:

failed: [localhost] (item=ci-op-0c4z64fq-bbd80-28ds4-worker-us-east-1a) => changed=true 
  ansible_loop_var: item
  cmd:
  - oc
  - delete
  - machinesets
  - ci-op-0c4z64fq-bbd80-28ds4-worker-us-east-1a
  - --kubeconfig=/tmp/artifacts/installer/auth/kubeconfig
  - --namespace=openshift-machine-api
  delta: '0:00:00.652124'
  end: '2020-06-18 06:23:01.170022'
  invocation:
    module_args:
      _raw_params: |-
        oc delete machinesets ci-op-0c4z64fq-bbd80-28ds4-worker-us-east-1a --kubeconfig=/tmp/artifacts/installer/auth/kubeconfig --namespace=openshift-machine-api
      _uses_shell: false
      argv: null
      chdir: null
      creates: null
      executable: null
      removes: null
      stdin: null
      stdin_add_newline: true
      strip_empty_ends: true
      warn: true
  item: ci-op-0c4z64fq-bbd80-28ds4-worker-us-east-1a
  msg: non-zero return code
  rc: 1
  start: '2020-06-18 06:23:00.517898'
  stderr: 'Error from server (InternalError): Internal error occurred: failed calling webhook "delete.cp.validation.machineset.machine.openshift.io": the server could not find the requested resource'
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

@michaelgugino michaelgugino changed the title WIP: Machineset cp vwh Add MachineSet ControlPlane webhooks Jun 18, 2020
@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 Jun 18, 2020
@@ -39,3 +39,5 @@ replace sigs.k8s.io/cluster-api-provider-aws => github.com/openshift/cluster-api
replace sigs.k8s.io/cluster-api-provider-azure => github.com/openshift/cluster-api-provider-azure v0.1.0-alpha.3.0.20200529030741-17d4edc5142f

replace sigs.k8s.io/cluster-api-provider-gcp => github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200528175251-4f2fdeb49fe1

replace sigs.k8s.io/controller-runtime => github.com/mgugino-upstream-stage/controller-runtime v0.6.1-0.20200618201807-9d82bf2a7266
Copy link
Contributor Author

Choose a reason for hiding this comment

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

kubernetes-sigs/controller-runtime#1005

This is an outstanding issue from controller-runtime. If we want to test webhooks dynamically like this, we need this patch or some other alternative.


// TODO(michaelgugino): Ensure we account for MachineDeployment ownership
// of a CP machineset in the future if we use them.
return admission.Denied(fmt.Sprintf("Requested %v of Control Plane MachineSet Not Allowed.", req.Operation))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a better error on this, as in, more descriptive of the actual reason why we are rejecting it, I wonder if we could break the logic up so we have a the update and delete handled separately?


}

func isCPMS(ms *MachineSet) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of acronyms in code, any reason not to call this isControlPlaneMachineSet so that you don't need context to understand it?


// If the user is updating a CP MachineSet, as long as machine role is
// unchanged, we're ok.
if newMS != nil && isCPMS(newMS) && isCPMS(oldMS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

newMS is never nil since you initialise it on line 46, so this will always check newMS for the annotations

close(done)
<-stopped
}()

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth checking the server has started with

gs.Eventually(func() (bool, error) {
	resp, err := insecureHTTPClient.Get(fmt.Sprintf("https://127.0.0.1:%d", testEnv.WebhookInstallOptions.LocalServingPort))
	if err != nil {
		return false, err
	}
	return resp.StatusCode == 404, nil
}).Should(BeTrue())	

close(done)
<-stopped
}()

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth checking the server has started with

gs.Eventually(func() (bool, error) {
	resp, err := insecureHTTPClient.Get(fmt.Sprintf("https://127.0.0.1:%d", testEnv.WebhookInstallOptions.LocalServingPort))
	if err != nil {
		return false, err
	}
	return resp.StatusCode == 404, nil
}).Should(BeTrue())	

@michaelgugino michaelgugino force-pushed the machineset-cp-vwh branch 2 times, most recently from c4f2c30 to 3fdfdb6 Compare June 23, 2020 17:40
Add webhooks for Delete and Update operations
on MachineSets that are identified to be
Control Plane members.  These webhooks prevent
deleting these MachineSets or updating them
to become non-CP MachineSets (in order to
further prevent them from being deleted or
misconfigured)
@openshift-ci-robot
Copy link
Contributor

@michaelgugino: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-scaleup-rhel7 0942080 link /test e2e-aws-scaleup-rhel7
ci/prow/e2e-azure-operator 0942080 link /test e2e-azure-operator

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@openshift-ci-robot
Copy link
Contributor

@michaelgugino: PR needs rebase.

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-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 26, 2020
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 23, 2020
@openshift-merge-robot
Copy link
Contributor

@michaelgugino: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/generate 0942080 link /test generate

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.

@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci-robot openshift-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 6, 2020
@openshift-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

@michaelgugino
Copy link
Contributor Author

/reopen

@openshift-ci-robot
Copy link
Contributor

@michaelgugino: Reopened this PR.

In response to this:

/reopen

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-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign michaelgugino after the PR has been reviewed.
You can assign the PR to them by writing /assign @michaelgugino in a comment when ready.

The full list of commands accepted by this bot can be found 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-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

@michaelgugino
Copy link
Contributor Author

/reopen

@openshift-ci openshift-ci bot reopened this Aug 6, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 6, 2021

@michaelgugino: Reopened this PR.

In response to this:

/reopen

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 Aug 6, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from michaelgugino after the PR has been reviewed.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

openshift-ci bot commented Aug 17, 2021

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

Test name Commit Details Rerun command
ci/prow/e2e-aws-workers-rhel7 0942080 link /test e2e-aws-workers-rhel7
ci/prow/e2e-vsphere 0942080 link /test e2e-vsphere
ci/prow/e2e-vsphere-upgrade 0942080 link /test e2e-vsphere-upgrade
ci/prow/e2e-libvirt 0942080 link /test e2e-libvirt
ci/prow/goimports 0942080 link /test goimports
ci/prow/golint 0942080 link /test golint
ci/prow/e2e-gcp 0942080 link /test e2e-gcp
ci/prow/generate 0942080 link /test generate
ci/prow/e2e-azure 0942080 link /test e2e-azure
ci/prow/yaml-lint 0942080 link /test yaml-lint
ci/prow/e2e-aws-disruptive 0942080 link /test e2e-aws-disruptive
ci/prow/e2e-gcp-operator 0942080 link /test e2e-gcp-operator
ci/prow/e2e-metal-ipi-ovn-ipv6 0942080 link /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-azure-operator 0942080 link /test e2e-azure-operator
ci/prow/images 0942080 link /test images
ci/prow/unit 0942080 link /test unit
ci/prow/govet 0942080 link /test govet
ci/prow/e2e-aws 0942080 link /test e2e-aws
ci/prow/e2e-aws-operator 0942080 link /test e2e-aws-operator
ci/prow/e2e-aws-upgrade 0942080 link /test e2e-aws-upgrade
ci/prow/e2e-metal-ipi 0942080 link /test e2e-metal-ipi
ci/prow/e2e-metal-ipi-ovn-dualstack 0942080 link /test e2e-metal-ipi-ovn-dualstack
ci/prow/e2e-metal-ipi-upgrade 0942080 link /test e2e-metal-ipi-upgrade
ci/prow/e2e-metal-ipi-virtualmedia 0942080 link /test e2e-metal-ipi-virtualmedia
ci/prow/e2e-vsphere-serial 0942080 link /test e2e-vsphere-serial

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.

@openshift-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 16, 2021

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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 openshift-ci bot closed this Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants