-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add Validation and Mutating Webhook support #15
Add Validation and Mutating Webhook support #15
Conversation
Skipping CI for Draft Pull Request. |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/ba9786543d1b477ab2bbe1da7cd6334f ❌ openstack-meta-content-provider FAILURE in 8m 58s |
we should also add the maketarget for running with a webhook and the hacking scripts https://github.com/openstack-k8s-operators/placement-operator/tree/main/hack |
Thank you @SeanMooney for sending the links, Updated the pr with |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/1e5d782b2e0845dea8118600fef8dab3 ❌ openstack-meta-content-provider FAILURE in 8m 23s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/3adf6a259ce1402dbde43ea02d20c073 ❌ openstack-meta-content-provider FAILURE in 8m 59s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/ccb0a0d778f146ebb67c6e6e3092b324 ❌ openstack-meta-content-provider FAILURE in 8m 32s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/e5a842175ea24bafa7fc7da68678c56a ✔️ openstack-meta-content-provider SUCCESS in 1h 24m 37s |
Moving to draft till we make EDPM job passing! |
/test functional |
2ed29ef
to
b62f9b9
Compare
/test functional |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/8c703bd1c7ba4ac4a6976478ed9ac941 ✔️ openstack-meta-content-provider SUCCESS in 2h 12m 29s |
|
A high level question. Checking at others operators, i see two different patterns:
This PR is implementing (2), but, given that the user should be using only the top-level Watcher, I'd be inclined to go with (1) for simplicity. What do you think? I'll do a more detailed review today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug found in patch_webhook_configurations.yaml while testing locally
hack/run_with_local_webhook.sh
Outdated
- CREATE | ||
- UPDATE | ||
resources: | ||
- watcher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be watchers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
hack/run_with_local_webhook.sh
Outdated
- CREATE | ||
- UPDATE | ||
resources: | ||
- watcher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amoralej 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 |
if err = (&watcherv1beta1.WatcherDecisionEngine{}).SetupWebhookWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create webhook", "webhook", "WatcherDecisionEngine") | ||
os.Exit(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add a line like this [1] after this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is somethign i never got around to optimising in the nova operator but
again i would like to clean this up into a for loop over like we do with
NewReconcilers
we have one function that map of reconsiler name to and instance of the object
and then a second function that struct and loops over each setting them up and checking for an error.
we should try and avoid having long if chains like this were we can by transforming it into a data-driven flow.
that is escpially true when it all or nothing (if any fails we abort)
and when it needs to be done in two places, main.go and suite_tests.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I refactor these function as a follow up pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure lets move forward with this one as is and follow up
Below is the command used to generate the same. ``` operator-sdk create webhook --group watcher --version v1beta1 --kind Watcher --programmatic-validation --defaulting ``` Signed-off-by: Chandan Kumar <[email protected]>
Below is the command used to generate webhook: ``` operator-sdk create webhook --group watcher --version v1beta1 --kind WatcherAPI --programmatic-validation --defaulting ``` Signed-off-by: Chandan Kumar <[email protected]>
Below is the command used to generate the same: ``` operator-sdk create webhook --group watcher --version v1beta1 --kind WatcherDecisionEngine --programmatic-validation --defaulting ``` Signed-off-by: Chandan Kumar <[email protected]>
Below is the command used to generate the same: ``` operator-sdk create webhook --group watcher --version v1beta1 --kind WatcherApplier --programmatic-validation --defaulting ``` Signed-off-by: Chandan Kumar <[email protected]>
It will help to run with webhook. Signed-off-by: Chandan Kumar <[email protected]>
api/v1beta1/watcher_webhook.go
Outdated
// log is for logging in this package. | ||
var watcherlog = logf.Log.WithName("watcher-resource") | ||
|
||
func (r *Watcher) SetupWebhookWithManager(mgr ctrl.Manager) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is not really part of the API module
its a method that should be defined on the reconcile base class
or factored out into a common class like this
there is actually still some technical debt in the nova operator to meve this from being defined on each webhook to webhook to a common subclass so we could proceed with this as is i just want to call out the fac that this will largely be identical for every webhooks so we should try and duplicate this in the futrure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @SeanMooney , I have move this method into common_webhook.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
api/v1beta1/watcher_webhook.go
Outdated
Complete() | ||
} | ||
|
||
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should proably remove theses TODO comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
if err = (&watcherv1beta1.WatcherDecisionEngine{}).SetupWebhookWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create webhook", "webhook", "WatcherDecisionEngine") | ||
os.Exit(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is somethign i never got around to optimising in the nova operator but
again i would like to clean this up into a for loop over like we do with
NewReconcilers
we have one function that map of reconsiler name to and instance of the object
and then a second function that struct and loops over each setting them up and checking for an error.
we should try and avoid having long if chains like this were we can by transforming it into a data-driven flow.
that is escpially true when it all or nothing (if any fails we abort)
and when it needs to be done in two places, main.go and suite_tests.go
Moving it to Draft, working on existing comment! |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/e2220f3d861c4f5da974c84100f44222 ✔️ noop SUCCESS in 0s |
It also fixes: - Fix admission.Validator value in variable declaration error - Fix functional tests and pre-commit - Fix tls.crt no such file or directory - Use METRICS_PORT to 33080 and HEALTH_PORT to 33081 Signed-off-by: Chandan Kumar <[email protected]>
if err = (&watcherv1beta1.WatcherDecisionEngine{}).SetupWebhookWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create webhook", "webhook", "WatcherDecisionEngine") | ||
os.Exit(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure lets move forward with this one as is and follow up
b552b28
into
openstack-k8s-operators:main
This pull-request adds following things based on webhooks doc:
Jira: https://issues.redhat.com/browse/OSPRH-11933