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

Update AWSMachine webhook validate logic on update to be consistent #3728

Conversation

cnmcavoy
Copy link
Contributor

@cnmcavoy cnmcavoy commented Sep 12, 2022

Update AWSMachine webhook validate logic on update to be consistent with validation on creation.

What type of PR is this?
/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #3109 & #3105

Special notes for your reviewer:

  • Split into 2 commits, one for each webhook modified.

Checklist:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

Release note:

AWSMachine's webhook validation `onCreate` now checks that additional security groups are validated. This brings it into line with the existing AWSMachine `onUpdate` validation.
AWSMachineTemplate's webhook validation `onCreate` now checks that the template spec for the AWSMachine pass validation. Previously only volumes and ignition settings were validated.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 12, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @cnmcavoy. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 12, 2022
@cnmcavoy
Copy link
Contributor Author

Need to address #3109 (comment) first.

@Skarlso
Copy link
Contributor

Skarlso commented Sep 12, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 12, 2022
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 21, 2022
@cnmcavoy cnmcavoy force-pushed the cnmcavoy/awsmachine-webhook-validate-consistency branch from 2701f7f to 3c098fc Compare September 22, 2022 17:40
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 22, 2022
@Ankitasw
Copy link
Member

Ankitasw commented Dec 5, 2022

@cnmcavoy is this still WIP? Would you be able to continue with this PR?

@cnmcavoy
Copy link
Contributor Author

@cnmcavoy is this still WIP? Would you be able to continue with this PR?

I have an open question here: #3109 (comment)

If we don't want to address, this can be unmarked as WIP and merged.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 9, 2023
@cnmcavoy cnmcavoy force-pushed the cnmcavoy/awsmachine-webhook-validate-consistency branch from 3c699be to 2f7a99f Compare January 9, 2023 19:49
@cnmcavoy
Copy link
Contributor Author

cnmcavoy commented Jan 9, 2023

I added logic to the AWSMachineTemplate so that the validation behavior is consistent with the existing on create behavior of AWSMachine's as well.

@cnmcavoy cnmcavoy changed the title WIP: Update AWSMachine webhook validate logic on update to be consistent Update AWSMachine webhook validate logic on update to be consistent Jan 9, 2023
@k8s-ci-robot k8s-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 Jan 9, 2023
@cnmcavoy cnmcavoy force-pushed the cnmcavoy/awsmachine-webhook-validate-consistency branch from 2f7a99f to 1037077 Compare January 9, 2023 20:26
@Ankitasw
Copy link
Member

/test pull-cluster-api-provider-aws-e2e-blocking
/test pull-cluster-api-provider-aws-e2e-eks

@Ankitasw
Copy link
Member

@cnmcavoy I think the update part is still not done right, as discussed in the original issue?

@cnmcavoy cnmcavoy force-pushed the cnmcavoy/awsmachine-webhook-validate-consistency branch from 1037077 to e23b67d Compare February 27, 2023 18:47
@cnmcavoy
Copy link
Contributor Author

@Ankitasw I realize there description of this change is lacking and the issue it fixes is rather brief as well. Here's a summary of the changes in the PR:

The existing AWSMachine webhook validates onCreate that:

  • Cloud Init is configured correctly
  • [immutable] Ignition is configured correctly
  • [immutable] root volumes are configured with valid settings
  • [immutable] non-root volumes are configured with valid settings
  • [immutable] ssh key name is valid
  • additional security groups are configured with valid IDs or filters
  • additional aws tags are valid

The existing AWSMachine webhook validates onUpdate that:

  • Cloud Init is configured correctly
  • additional aws tags are valid
  • immutable spec fields are immutable

My change addresses the missing validation of the security groups onUpdate for AWSMachine. It also fixes the bug identified in #3105, where the wrong volume was compared in one of the validation non-root volumes.


Additionally, the existing AWSMachineTemplate webhook validates that onCreate that:

  • [immutable] Ignition is configured correctly
  • [immutable] root volumes are configured with valid settings
  • [immutable] non-root volumes are configured with valid settings

The existing AWSMachineTemplate webhook validates onUpdate that:

  • Modifying the secret backend store from the default ("") to the SSM Parameter store is not a distinct update from the default ("") state for older crd versions.
  • immutable spec fields are immutable

My change addresses all of the missing validation from the AWSMachineTemplate onCreate webhook which is present in the AWSMachine onCreate webhook, and introduces new validation onCreate for the AWSMachineTemplate to cover:

  • Cloud Init is configured correctly
  • ssh key name is valid
  • additional security groups are configured with valid IDs or filters
  • additional aws tags are valid

There shouldn't be any changes to the API contract in this PR, only enforcement of the existing contract. Is there anything that is incorrect or I left out in this? Please let me know if so.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 27, 2023
@Ankitasw
Copy link
Member

/test pull-cluster-api-provider-aws-e2e-blocking

@Ankitasw
Copy link
Member

/easycla

@Ankitasw
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ankitasw

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 28, 2023
@k8s-ci-robot k8s-ci-robot merged commit 8137760 into kubernetes-sigs:main Feb 28, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWSMachine and AWSMachineTemplate.Spec creation validation should be consistent
4 participants