Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Allow HNC to propagate changes to CRD. #1513

Closed
wants to merge 2 commits into from

Conversation

just1900
Copy link

@just1900 just1900 commented Jul 8, 2021

A PR would be great, thanks! Just a few quick pointers / requests:

  • A change like this benefits from a lot of comments, e.g. linking to this issue. Otherwise we'll have no idea why we added this in a few months.

  • It would be great if you could add or update a unit test to verify that the rV is being copied (e.g. here.

  • It would be amazing if you could update an end-to-end test (e.g. here) to try to propagate a CRD, show that this fails without your fix, and that it passes with your fix. This test is probably a pretty good model, and you can embed yaml in the test as shown here.

    • The e2e tests assume that you've deployed HNC to a cluster, and your kubectl config is currently pointing at the cluster you want to run the tests on.
    • Running all the e2e tests takes ~30min but you only need to run the one you're writing. So you can modify your test so that the It() function has an F (for "focus") in front of it, like this: FIt() (note the first two letters are capitalized). This will only run your test. Just remember to change it back to It() before you submit the PR.
  • We use one commit per PR so please squash all commits and force-update the PR branch if necessary. We also describe how we tested the change in the commit message like this.

@adrianludwin PTAL, follow your pointers

  • I have link the issue and add some description to the code
  • for the unit test, I have no idea about how to verify that the rV is being copied by now, because every resource in k8s will have a ResourceVersion.
  • e2e test have been added and tested.
  • the commit msg is detailed for how to reproduce before this pr's change.

Currently, HNC are clearing out most of the metadata when doing an update request, which works fine for most types, but failed for CRDs. This PR allows HNC to propagate changes to CRD by setting 'ResourceVersion' explicitly when performing an update.
Tested: before this change, first create an crd in the parent namespace, and then update whatever field of the crd, wait a second and run the following command:
kubectl hns describe child

Result:

Events from the objects in namespace child
Last Seen Reason             Object                     Message
0s        CannotUpdateObject EETest:child/eetest-sample Could not write from source namespace parent: eetests.e2e.hnc.x-k8s.io eetest-sample is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update.

After this change, you should see it propagates normally and the inherited crd's field is updated.
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 8, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @just1900!

It looks like this is your first PR to kubernetes-sigs/multi-tenancy 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/multi-tenancy has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @just1900. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 8, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: just1900
To complete the pull request process, please assign adrianludwin after the PR has been reviewed.
You can assign the PR to them by writing /assign @adrianludwin 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

@k8s-ci-robot k8s-ci-robot requested review from rjbez17 and srampal July 8, 2021 03:27
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 8, 2021
@just1900
Copy link
Author

just1900 commented Jul 8, 2021

I signed it

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 8, 2021
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Great change! I've just left a few minor comments.

for the unit test, I have no idea about how to verify that the rV is being copied by now, because every resource in k8s will have a ResourceVersion.

I think that's fine, the e2e test captures everything we need and it's really the interaction with K8s that's important. There might have been a way to test this in the unit tests (which actually run a copy of the apiserver) but in this case, I like the clarity of the e2e test using kubectl.

e2e test have been added and tested.

Thanks for doing that. Can you just confirm that you tested that this new test fails if you break the code, i.e. leave resourceVersion as zero? That might be nice to put into the commit message as well, given that I've asked for some other minor changes anyway.

Also cc @rjbez17 for his review.

incubator/hnc/internal/reconcilers/object.go Outdated Show resolved Hide resolved
incubator/hnc/internal/reconcilers/object.go Show resolved Hide resolved
incubator/hnc/test/e2e/issues_test.go Outdated Show resolved Hide resolved
incubator/hnc/test/e2e/issues_test.go Show resolved Hide resolved
incubator/hnc/test/e2e/issues_test.go Outdated Show resolved Hide resolved
2. cleanup crd in AfterEach block instead of defer
@k8s-ci-robot k8s-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 Jul 8, 2021
@just1900 just1900 requested a review from adrianludwin July 8, 2021 16:03
@adrianludwin
Copy link
Contributor

Oh man, I just realized this is in the wrong repo! Sorry I didn't pick up on that. Can you please make this change in https://github.com/kubernetes-sigs/hierarchical-namespaces instead? Sorry about that. The code hasn't changed very much (apart from the paths - the incubator/hnc prefix has been removed) so it should be fairly easy to recreate the change in the new repo. I'm really sorry I missed that.

@just1900
Copy link
Author

just1900 commented Jul 9, 2021

I didn't realize that either 😂, I've open another PR there kubernetes-sigs/hierarchical-namespaces#59.
Shall we close this one?

@adrianludwin
Copy link
Contributor

Yup! Closing this copy.

/close

@k8s-ci-robot
Copy link
Contributor

@adrianludwin: Closed this PR.

In response to this:

Yup! Closing this copy.

/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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

3 participants