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

Enable Dynamic Admission Control for Application #1619

Merged
merged 3 commits into from May 8, 2021

Conversation

yangsoon
Copy link
Collaborator

@yangsoon yangsoon commented May 8, 2021

enable dynamic admission control for Application, the admissionWebhooks will check the correctness of the fields in Application.

@codecov
Copy link

codecov bot commented May 8, 2021

Codecov Report

Merging #1619 (dbd881c) into master (1660930) will increase coverage by 0.25%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1619      +/-   ##
==========================================
+ Coverage   62.00%   62.26%   +0.25%     
==========================================
  Files         120      120              
  Lines       11899    11900       +1     
==========================================
+ Hits         7378     7409      +31     
+ Misses       3761     3725      -36     
- Partials      760      766       +6     
Flag Coverage Δ
e2etests 43.82% <100.00%> (+0.13%) ⬆️
unittests 58.23% <0.00%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...oam.dev/v1alpha2/application/validating_handler.go 88.88% <100.00%> (+15.81%) ⬆️
pkg/dsl/model/instance.go 75.67% <0.00%> (-5.41%) ⬇️
pkg/appfile/appfile.go 76.09% <0.00%> (-1.60%) ⬇️
...dev/v1alpha2/application/application_controller.go 79.13% <0.00%> (-1.44%) ⬇️
pkg/dsl/definition/template.go 48.38% <0.00%> (-0.93%) ⬇️
...am.dev/v1alpha2/applicationconfiguration/render.go 90.24% <0.00%> (-0.82%) ⬇️
...troller/core.oam.dev/v1alpha2/application/apply.go 72.86% <0.00%> (-0.49%) ⬇️
...oam.dev/v1alpha2/applicationconfiguration/apply.go 68.34% <0.00%> (ø)
...a2/applicationrollout/applicationrollout_helper.go 65.44% <0.00%> (ø)
...pplicationrollout/applicationrollout_controller.go 81.18% <0.00%> (+1.07%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1660930...dbd881c. Read the comment docs.

if allErrs := h.ValidateUpdate(ctx, app, oldApp); len(allErrs) > 0 {
return admission.Errored(http.StatusUnprocessableEntity, allErrs.ToAggregate())
if app.ObjectMeta.DeletionTimestamp.IsZero() {
if allErrs := h.ValidateUpdate(ctx, app, oldApp); len(allErrs) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if allErrs := h.ValidateUpdate(ctx, app, oldApp); len(allErrs) > 0 {
if len(h.ValidateUpdate(ctx, app, oldApp)) > 0 {

Better? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This cannot be modified here, because the following logic needs to return the error in allErrs

@@ -98,5 +99,5 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a
// RegisterValidatingHandler will register application validate handler to the webhook
func RegisterValidatingHandler(mgr manager.Manager, args controller.Args) {
server := mgr.GetWebhookServer()
server.Register("/validating-core-oam-dev-v1alpha2-applications", &webhook.Admission{Handler: &ValidatingHandler{dm: args.DiscoveryMapper, pd: args.PackageDiscover}})
server.Register("/validating-core-oam-dev-v1beta1-applications", &webhook.Admission{Handler: &ValidatingHandler{dm: args.DiscoveryMapper, pd: args.PackageDiscover}})
Copy link
Collaborator

Choose a reason for hiding this comment

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

What will happed if there the old webhook is already registered and running in a cluster?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In fact, vela has never enable the Admission Control for Application

Copy link
Collaborator

@wonderflow wonderflow left a comment

Choose a reason for hiding this comment

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

good job

@wonderflow wonderflow merged commit 1866753 into kubevela:master May 8, 2021
yangsoon added a commit to yangsoon/kubevela that referenced this pull request May 13, 2021
* add webhook

* fix test

* fix validating_handler
yangsoon added a commit to yangsoon/kubevela that referenced this pull request May 17, 2021
* add webhook

* fix test

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

Successfully merging this pull request may close these issues.

None yet

3 participants