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

Rename member webhook cluster scoped objects #562

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

mfrancisc
Copy link
Contributor

This PR contains:

  • renaming of the cluster scoped objects in the webhook deployments. It appends the member namespace in all the cluster scoped resources.
  • temporary old-name label used to delete the objects using the current name ( since we are redeploying with new name )
  • temporary migration logic to delete current objects in favor of the ones with new name

The renaming of the cluster scoped objects is needed in order to be able to delete the member2 webhook configuration during e2e tests.
We cannot avoid deploying the webhook on member2 anymore since we inverted the order of the make targets in https://github.com/codeready-toolchain/toolchain-e2e/pull/950/files#diff-163703aeb25751c1605d305fbfdf39f3a9dfb74d2ac9d8a03f5cf0169d7d41b7R266 , due to the fact that member operator is now deploying the toolchaincluster-sa and we need to verify and use the toolchaincluster-member SA in setup-toolchainclusters only after deploy the member operator.

Paired with:

see: https://redhat-internal.slack.com/archives/C06MJ2DVBU4/p1713534677202559

Copy link

codecov bot commented Apr 27, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 32 lines in your changes are missing coverage. Please review.

Project coverage is 83.09%. Comparing base (2a79f46) to head (1790160).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #562      +/-   ##
==========================================
- Coverage   84.06%   83.09%   -0.98%     
==========================================
  Files          29       29              
  Lines        2636     2673      +37     
==========================================
+ Hits         2216     2221       +5     
- Misses        277      307      +30     
- Partials      143      145       +2     
Files Coverage Δ
pkg/webhook/mutatingwebhook/vm_mutate.go 80.83% <ø> (ø)
...roperatorconfig/memberoperatorconfig_controller.go 75.75% <60.00%> (-3.19%) ⬇️
pkg/webhook/deploy/deployment.go 32.07% <6.66%> (-35.93%) ⬇️

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Could you please add unit tests for the deletion part of the code?

pkg/webhook/deploy/deployment.go Outdated Show resolved Hide resolved
pkg/webhook/deploy/deployment.go Outdated Show resolved Hide resolved
pkg/webhook/deploy/deployment.go Outdated Show resolved Hide resolved
pkg/webhook/deploy/deployment.go Outdated Show resolved Hide resolved
pkg/webhook/deploy/deployment.go Outdated Show resolved Hide resolved
@mfrancisc
Copy link
Contributor Author

Could you please add unit tests for the deletion part of the code?

@MatousJobanek thanks for your review. I've added a couple of additional unit tests to cover:

  • migration , when old objects are replaced by new ones
  • e2e tests, when all the objects ( except the ones marked as no-deletion) are deleted

@mfrancisc
Copy link
Contributor Author

/retest

Copy link
Contributor

@rajivnathan rajivnathan left a comment

Choose a reason for hiding this comment

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

Can you please revert the VM-related changes for this PR to ensure it has no impact?

Comment on lines +118 to +124
deleted, err := deploy.Delete(ctx, r.Client, r.Client.Scheme(), namespace, false)
if err != nil {
return err
}
if deleted {
logger.Info("Deleted previously deployed webhook app")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a change in behaviour such that if Webhook.Deploy is set to false in the member operator config then the webhook deployment will be deleted. I think the configuration was meant for stopping the member operator from deploying/redeploying the webhook automatically but without deleting any existing ones. I think that's desirable for debugging scenarios. Any reason why we want to change that behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, I see your point now. I think the webhook provides some pretty important functionality that I'm not sure we'd want to delete unless it's explicitly meant to be deleted but I can't think of a reason why we'd disable the configuration and expect the webhook to stay as it was so I guess it's fine. I'd just suggest we update the comment in the api to make it clear what happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd just suggest we update the comment in the api to make it clear what happens.

good point, please see https://github.com/codeready-toolchain/api/pull/425/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the webhook provides some pretty important functionality that I'm not sure we'd want to delete unless it's explicitly meant to be deleted but I can't think of a reason why we'd disable the configuration and expect the webhook to stay

I was discussing this with @MatousJobanek, a better approach IMO would be to decouple the deployment of the webhooks from member operator , this would allow to have more flexibility and would avoid such "workarounds" where we deploy something and then we need to delete it. But the decoupling of the webhooks is a bigger effort and not on the priority list atm.

@@ -3,11 +3,19 @@ package deploy
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"testing"
Copy link
Contributor

Choose a reason for hiding this comment

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

The test functions should be moved to the test file unless I'm missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! done in e07e190 thanks!

Copy link

sonarcloud bot commented May 22, 2024

Quality Gate Passed Quality Gate passed

Issues
8 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

openshift-ci bot commented May 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfrancisc, rajivnathan

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:
  • OWNERS [mfrancisc,rajivnathan]

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants