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

add validation functions for metav1.Conditions #92519

Merged
merged 1 commit into from
Jul 9, 2020

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Jun 25, 2020

The last commit adds validation rules. It's best to be as constraining as we think is reasonable, but we should try to make it possible to be consistent with generated schemas.

@liggitt as promised. See if you agree with the restrictions.

/kind feature
/priority important-soon
@kubernetes/sig-api-machinery-feature-requests

/hold this still needs tests

@damemi @sttts I tried to make these validation rules easy to port into kubebuilder markers in the types themselves so CRDs will generate cleanly. Can you confirm these look good.
@mfojtik do these rules correspond to how you've seen them used too?

NONE

related to kubernetes/enhancements#1623

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 25, 2020
@k8s-ci-robot k8s-ci-robot added area/code-generation kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Jun 25, 2020
@fedebongio
Copy link
Contributor

/cc @liggitt

Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

a couple nits, looks reasonable otherwise

I'm unsure about adding kube-builder annotations in types defined in k8s.io/kubernetes

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2020
@deads2k
Copy link
Contributor Author

deads2k commented Jun 30, 2020

I'm unsure about adding kube-builder annotations in types defined in k8s.io/kubernetes

I think we can draw a reasonable line about adding these tags based on the generator being in kubernetes-sigs. I would allow additional tags on these types to added as long as they were for generators in kubernetes or kubernetes-sigs. I would decline PRs for tags for generators that are not sponsored by kubernetes sigs.

@mfojtik
Copy link
Contributor

mfojtik commented Jul 1, 2020

@deads2k regarding to condition API, do we believe that the message in condition provide enough information for users to understand its context or give users clue about possible mitigations?

@deads2k
Copy link
Contributor Author

deads2k commented Jul 1, 2020

@deads2k regarding to condition API, do we believe that the message in condition provide enough information for users to understand its context or give users clue about possible mitigations?

Yes. I think that's the purpose of the message. Its clarity will depend on the author

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 1, 2020
@deads2k
Copy link
Contributor Author

deads2k commented Jul 1, 2020

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 1, 2020
@liggitt
Copy link
Member

liggitt commented Jul 2, 2020

/approve

nit on message, then lgtm

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 2, 2020
allErrs = append(allErrs, field.Invalid(fldPath.Child("observedGeneration"), condition.ObservedGeneration, "must be greater than or equal to zero"))
}

if condition.LastTransitionTime.IsZero() {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this match https://github.com/kubernetes/kubernetes/pull/92660/files#diff-eca3b8d856fa2e661f6da91b61de5e76R1391 ? I think the OpenAPI schema will allow a zero date (not null).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does this match https://github.com/kubernetes/kubernetes/pull/92660/files#diff-eca3b8d856fa2e661f6da91b61de5e76R1391 ? I think the OpenAPI schema will allow a zero date (not null).

Ok. We'll control the ones we can then. Not allowing zero is correct.

}

const conditionReasonFmt string = "[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?"
const conditionReasonErrMsg string = "a condition reason must start with alphabetic character, followed by a string of alphanumeric characters or '_,:', and must end with an alphanumeric character or '_'"
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't match the regexp. Some "optionally" are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this doesn't match the regexp. Some "optionally" are missing.

I need help seeing it. Which optionally do I need to add?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const conditionReasonErrMsg string = "a condition reason must start with alphabetic character, followed by a string of alphanumeric characters or '_,:', and must end with an alphanumeric character or '_'"
const conditionReasonErrMsg string = "a condition reason must start with alphabetic character, optionally followed by a string of alphanumeric characters or '_,:', and must end with an alphanumeric character or '_'"

@sttts
Copy link
Contributor

sttts commented Jul 2, 2020

@deads2k
Copy link
Contributor Author

deads2k commented Jul 7, 2020

/retest

@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 7, 2020
@deads2k deads2k added this to the v1.19 milestone Jul 7, 2020
@deads2k
Copy link
Contributor Author

deads2k commented Jul 7, 2020

tagging per comments.

@deads2k
Copy link
Contributor Author

deads2k commented Jul 7, 2020

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

2 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 8, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, liggitt

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@liggitt
Copy link
Member

liggitt commented Jul 8, 2020

/lgtm
/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 8, 2020
@deads2k
Copy link
Contributor Author

deads2k commented Jul 8, 2020

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jul 8, 2020

@deads2k: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-e2e-kind-ipv6 c690974f893062ec233713850571e45bde3e15e2 link /test pull-kubernetes-e2e-kind-ipv6

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.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 9a343ed into kubernetes:master Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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.

None yet

7 participants