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

validate third party resources #25007

Merged

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Apr 30, 2016

addresses validation portion of #22768

  • ThirdPartyResource: validates name (3 segment DNS subdomain) and version names (single segment DNS label)
  • ThirdPartyResourceData: validates objectmeta (name is validated as a DNS label)
  • removes ability to use GenerateName with thirdpartyresources (kind and api group should not be randomized, in my opinion)

test improvements:

  • updates resttest to clean up after create tests (so the same valid object can be used)
  • updates resttest to take a name generator (in case "foo1" isn't a valid name for the object under test)

action required for alpha thirdpartyresource users:

  • existing thirdpartyresource objects that do not match these validation rules will need to be removed/updated (after removing thirdpartyresourcedata objects stored under the disallowed versions, kind, or group names)
  • existing thirdpartyresourcedata objects that do not match the name validation rule will not be able to be updated, but can be removed

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed labels Apr 30, 2016
@@ -152,6 +165,8 @@ func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorL
version := &obj.Versions[ix]
if len(version.Name) == 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty"))
} else if validation.IsDNS1123Label(version.Name) {
Copy link
Member Author

@liggitt liggitt Apr 30, 2016

Choose a reason for hiding this comment

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

not sure how tight we should make this... we've never really defined what is allowed for a version. it definitely needs to be single-segment, but not sure beyond that. Pretty sure @thockin would be happy making this tight to begin with.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lavalamp @caesarxuchao @deads2k @kubernetes/sig-api-machinery opinions on allowed format for an api version?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

No slash, versions have to take one URL segment for API server routing sanity

Copy link
Contributor

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.

@lavalamp @caesarxuchao @deads2k @kubernetes/sig-api-machinery opinions on allowed format for an api version?

I like the tight rules. Definitely no dots or slashes we'll hose the cli.

Copy link
Member

Choose a reason for hiding this comment

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

Starting with IsDNS1123Label LGTM.

@lavalamp
Copy link
Member

lavalamp commented May 2, 2016

Hold on-- why should these be cluster scoped?

@lavalamp
Copy link
Member

lavalamp commented May 2, 2016

Never mind. I see you're not talking about the data objects. I agree the schemas need to be cluster scoped.

@liggitt
Copy link
Member Author

liggitt commented May 2, 2016

cluster scope change is in #25006, see discussion there

@deads2k
Copy link
Contributor

deads2k commented May 2, 2016

Hold on-- why should these be cluster scoped?

When you add a third party resources, they affect the types that are available across the entire cluster, effectively reserving that name.

@liggitt liggitt force-pushed the third-party-resource-validation branch from 8ad7e9e to 1bfd234 Compare May 2, 2016 19:48
@smarterclayton
Copy link
Contributor

Validation looks ok to me.

@thockin
Copy link
Member

thockin commented May 4, 2016

no red flags from me

@liggitt liggitt changed the title WIP - validate third party resources validate third party resources May 4, 2016
@liggitt liggitt added release-note Denotes a PR that will be considered when it comes time to generate release notes. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note-label-needed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 4, 2016
@liggitt liggitt force-pushed the third-party-resource-validation branch from 1bfd234 to a17967f Compare May 7, 2016 03:53
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 7, 2016
@liggitt liggitt force-pushed the third-party-resource-validation branch from a17967f to 6c323a4 Compare May 9, 2016 13:27
@liggitt
Copy link
Member Author

liggitt commented May 9, 2016

/cc @lavalamp @caesarxuchao @deads2k

@@ -152,6 +165,8 @@ func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorL
version := &obj.Versions[ix]
if len(version.Name) == 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty"))
} else if !validation.IsDNS1123Label(version.Name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

very restrictive, what if i want a third party resource that has an underscore in the name? Or a colon?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I'm not sure what the right line to draw is. if there was a way for thirdpartyresources to specify what name formats they allow, that would be better, but in the absence of that, how much should we protect users of this API from bad names? see discussion at #25007 (diff)

@liggitt: should we make the name validation tight (dns label or subdomain, etc) or minimal (anything we can represent as a URL path segment)?

@deads2k: Without actual hooks to allow them to shape their names, I think forcing the label is reasonable.

@liggitt: you don't think most API consumers would be equipped to handle resources named İ ♥ \n?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with starting tight. But it also encourages clients to make
assumptions "oh, third party is label, I'll just mix in some colons and
underscores and everything will be safe". No objection, otherwise LGTM.

On Mon, May 9, 2016 at 2:55 PM, Jordan Liggitt notifications@github.com
wrote:

In pkg/apis/extensions/validation/validation.go
#25007 (comment)
:

@@ -152,6 +165,8 @@ func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorL
version := &obj.Versions[ix]
if len(version.Name) == 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty"))

  •   } else if !validation.IsDNS1123Label(version.Name) {
    

yeah, I'm not sure what the right line to draw is. if there was a way for
thirdpartyresources to specify what name formats they allow, that would be
better, but in the absence of that, how much should we protect users of
this API from bad names? see discussion at #25007 (diff)
#25007 (diff)

@liggitt https://github.com/liggitt: should we make the name validation
tight (dns label or subdomain, etc) or minimal (anything we can represent
as a URL path segment)?

@deads2k https://github.com/deads2k: Without actual hooks to allow them
to shape their names, I think forcing the label is reasonable.

@liggitt https://github.com/liggitt: you don't think most API consumers
would be equipped to handle resources named İ ♥ \n?


You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/25007/files/6c323a4f723cbcb1a11d12edf1c81b8ed908057d#r62552880

@lavalamp
Copy link
Member

lavalamp commented May 9, 2016

this LGTM

@liggitt liggitt added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 9, 2016
@k8s-bot
Copy link

k8s-bot commented May 13, 2016

GCE e2e build/test passed for commit 6c323a4.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented May 15, 2016

GCE e2e build/test passed for commit 6c323a4.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 272674b into kubernetes:master May 15, 2016
@liggitt liggitt deleted the third-party-resource-validation branch May 18, 2016 04:27
@erictune erictune removed the release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. label Jul 2, 2016
openshift-publish-robot pushed a commit to openshift/kubernetes that referenced this pull request May 23, 2020
Bug 1825915: UPSTREAM: 90985: Set session scanning to manual to avoid discovering all iSCSI devices during login

Origin-commit: afc841de5012eb1cb721be2ce6c70ea4c584ae9f
openshift-publish-robot pushed a commit to openshift/kubernetes that referenced this pull request May 27, 2020
Bug 1825915: UPSTREAM: 90985: Set session scanning to manual to avoid discovering all iSCSI devices during login

Origin-commit: afc841de5012eb1cb721be2ce6c70ea4c584ae9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants