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

[feature request]it is not appropriate to return Invalid in nodepool webhook #1823

Closed
rambohe-ch opened this issue Nov 23, 2023 · 1 comment · Fixed by #1826
Closed

[feature request]it is not appropriate to return Invalid in nodepool webhook #1823

rambohe-ch opened this issue Nov 23, 2023 · 1 comment · Fixed by #1826
Assignees
Labels
help wanted help wanted kind/feature kind/feature kind/good-first-issue kind/good-first-issue

Comments

@rambohe-ch
Copy link
Member

What would you like to be added:
In nodepool validation webhook, some fields in NodePool.Spec is not allowed to modify, but Invalid error code is returned. I think that it is appropriate to return Forbidden error code.

The following code lines should be modified:

return apierrors.NewInvalid(appsv1beta1.GroupVersion.WithKind("NodePool").GroupKind(), newNp.Name, allErrs)

=> return apierrors.NewForbidden(appsv1beta1.GroupVersion.WithResource("nodepools").GroupResource(), np.Name, allErrs.ToAggregate())

return apierrors.NewInvalid(appsv1beta1.GroupVersion.WithKind("NodePool").GroupKind(), np.Name, allErrs)

=> return apierrors.NewForbidden(appsv1beta1.GroupVersion.WithResource("nodepools").GroupResource(), np.Name, allErrs.ToAggregate())

field.Invalid(field.NewPath("spec").Child("type"), spec.Type, "pool type can't be changed")})

=> field.Forbidden(field.NewPath("spec").Child("type"), "pool type can't be changed")})

field.Invalid(field.NewPath("spec").Child("hostNetwork"), spec.HostNetwork, "pool hostNetwork can't be changed"),

=> field.Forbidden(field.NewPath("spec").Child("hostNetwork"), "pool hostNetwork can't be changed"),

Why is this needed:

others
/kind feature

@rambohe-ch rambohe-ch added kind/feature kind/feature help wanted help wanted kind/good-first-issue kind/good-first-issue labels Nov 23, 2023
@lilongfeng0902
Copy link
Member

/assign @lilongfeng0902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted help wanted kind/feature kind/feature kind/good-first-issue kind/good-first-issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants