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

Validation of system labels only #4879

Merged
merged 10 commits into from
Jul 24, 2019

Conversation

shashwathi
Copy link
Contributor

Addresses partially #4700

Proposed Changes

Release Note


cc @dgerd @vagababov @savitaashture

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 22, 2019
@knative-prow-robot knative-prow-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 22, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@shashwathi: 0 warnings.

In response to this:

Addresses partially #4700

Proposed Changes

Release Note


cc @dgerd @vagababov @savitaashture

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.

@shashwathi shashwathi changed the title Labels only Validation of system labels only Jul 22, 2019
@knative-prow-robot knative-prow-robot added the area/API API objects and controllers label Jul 22, 2019
@shashwathi
Copy link
Contributor Author

/assign @dgerd
/assign @vagababov

pkg/apis/serving/v1beta1/configuration_validation.go Outdated Show resolved Hide resolved
@@ -19,6 +19,8 @@ package serving
const (
GroupName = "serving.knative.dev"
Copy link

Choose a reason for hiding this comment

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

While you are here do you mind dropping a comment on this public constant?

if ref.Kind != resource || val != ref.Name {
errs = errs.Also(apis.ErrInvalidArrayValue(ref.Name, label, i))
}
found = true
Copy link

Choose a reason for hiding this comment

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

I am not sure this loop is doing what you expect... With this we always return found true on the first item??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

found variable is used for tracking there is at least one owner reference with expected key.

Copy link
Contributor

Choose a reason for hiding this comment

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

but you set it to true regardless of whether you found proper one or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad. gotcha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed the logic for this function. Please take another look.

pkg/apis/serving/v1beta1/route_validation.go Outdated Show resolved Hide resolved
pkg/apis/serving/register.go Outdated Show resolved Hide resolved
pkg/apis/serving/v1beta1/configuration_validation.go Outdated Show resolved Hide resolved
Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

In general looks good.
But I am a bit annoyed that there's lot's of repetition, that can be torn out into non versioned validator in the pkg/apis/serving directory. But I guess it's a decent first step.
I'll let Dan approve.

errs = errs.Also(apis.ErrInvalidValue(val, label))
}
for i, ref := range ownerRefs {
if ref.Kind == resource && val == ref.Name {
Copy link
Contributor

Choose a reason for hiding this comment

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

well, just if !(...) { errs = errs.Also(...)

- Refactor to use switch instead of if condition
- Use serving constants in tests
- Use viaField for uniform field values
- use return variable names to avoid multiple declarations
- Address edge case of multiple owner references
- Logic was broken for case when parent label is present but the owner
ref is absent or wrong owner references are present.
- Fixed the logic and added testcase to guard for future
- Update serving.GroupNamePrefix to local const
- If there is at least one owner ref present for matching label then
ignore the rest of references.
@dgerd
Copy link

dgerd commented Jul 23, 2019

/approve

I will let @vagababov set the lgtm

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgerd, shashwathi

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 23, 2019
Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2019
@andrew-su
Copy link
Member

/test pull-knative-serving-integration-tests

@knative-prow-robot knative-prow-robot merged commit 398c3e6 into knative:master Jul 24, 2019
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/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants