-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
ingress: rename backend to defaultBackend for ingress v1 #80179
Conversation
8228787
to
09e6ec5
Compare
thanks for picking this up :-) |
09e6ec5
to
b2fe1ca
Compare
/priority important-soon |
@cmluciano: You must be a member of the kubernetes/milestone-maintainers GitHub team to set the milestone. If you believe you should be able to issue the /milestone command, please contact your and have them propose you as an additional delegate for this responsibility. In response to this:
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. |
b2fe1ca
to
d03f4ed
Compare
Just need to add tests tomorrow and then will flip this to "ready" |
d03f4ed
to
417115b
Compare
Thanks @josiahbjorgaard we plan for this to be combined with other PRs for 1.18 |
Revisiting this, I still have zero idea how to solve this. |
@thockin Jordan shared some examples at KubeCon with me. I am taking a look at how this is done in the admissionregistration package and will pull some examples out of there. |
I spent time over holidays poking at this. A "real" fix might be long in coming, but @deads2k shared a cute trick. Take a look at https://github.com/kubernetes/kubernetes/compare/master...thockin:hack-ingress-versioned-validation?expand=1 If we plumb that down, we can use it to choose a name for the error |
@thockin Just saw this now, thanks! I believe this is what my commit is missing to fix the tests. |
e2c493a
to
c4d43b8
Compare
7d9ce52
to
50aa7c4
Compare
@liggitt I think I'm pretty close on this one. The last failure is seems to be the storage test. I think the problem might be that it is missing requestInfo details like I have in strategy.
|
I'd recommend something like this in ValidateUpdate and Validate: var requestGV schema.GroupVersion
if requestInfo, ok := request.RequestInfoFrom(ctx); ok {
requestGV = schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
} |
} | ||
if requestGV == networkingv1beta1.SchemeGroupVersion { | ||
allErrs = append(allErrs, field.Invalid(fldPath, spec.Rules, "either `backend` or `rules` must be specified")) | ||
} |
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.
Assuming we are better at naming this field now than we were four years ago, something like this that assumes future versions will continue using the v1 field name might make more sense:
var defaultBackendFieldName string
switch requestGV {
case networkingv1beta1.SchemeGroupVersion, extensionsv1beta1.SchemeGroupVersion:
defaultBackendFieldName = "backend"
default:
defaultBackendFieldName = "defaultBackend"
}
allErrs := field.ErrorList{}
if spec.DefaultBackend != nil {
allErrs = append(allErrs, validateIngressBackend(spec.DefaultBackend, fldPath.Child(defaultBackendFieldName))...)
} else if len(spec.Rules) == 0 {
allErrs = append(allErrs, field.Invalid(fldPath, spec.Rules, fmt.Sprintf("either `%s` or `rules` must be specified", defaultBackendFieldName)))
}
The worse-case failure mode of that approach if we change the field name in a future version and forget to update this is that you get the wrong field name in an error message. The failure mode of the current code if we add a version and forget to update this is that we get unvalidated fields!
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.
When I tried it this way it doesn't seem to trigger the validation error that is expected in strategy_test.go. I'm scouring the relevant files under pkg/registry/networking/ingress/* to see if I am accidentally using the old backend type but I have not found a mistake yet.
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.
Nvm copy/paste error, I found my mistake
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.
Actually even after fixing an indenting problem, this still doesnt work because it passes only a string to the ingressbackend validation. I kept the if/else for now.
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.
I kept the if/else for now.
We need a fallback case that still performs validation, not one that skips validation on unknown versions
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.
also, this code doesn't currently handle extensions/v1beta1
83450d1
to
c0e4c31
Compare
/retest |
/assign |
/retest |
Per the Ingress v1 KEP, we are renaming the backend field in IngressSpec to clarify its intended use. Appropriate defaults are added to ensure backend is converted to the new field type. ingress: validate backend based on schema.GroupVersion Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
e26ebea
to
95edbd5
Compare
@cmluciano: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
closing in favor of #88041 /close |
@liggitt: Closed this PR. In response to this:
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. |
Signed-off-by: Christopher M. Luciano cmluciano@us.ibm.com
What type of PR is this?
/kind api-change
What this PR does / why we need it:
Per the Ingress v1 KEP, we are renaming the backend field in IngressSpec to
clarify its intended use. Appropriate defaults are added to ensure backend is
converted to the new field type.
Which issue(s) this PR fixes:
Related kubernetes/enhancements#758
Special notes for your reviewer:
Does this PR introduce a user-facing change?: