Skip to content

Add validation to SDN objects with invalid name funcs #13124

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

Merged

Conversation

enj
Copy link
Contributor

@enj enj commented Feb 27, 2017

Fixes #12697 with openshift/openshift-ansible#3387 as a prerequisite.

Supersedes #12959

I left the two invalid ObjectNameFuncs alone as this prevents them from being a problem (and @soltysh has already removed them in #12541).

cc @openshift/api-review @mfojtik @sdodson @openshift/networking

Signed-off-by: Monis Khan [email protected]

@enj
Copy link
Contributor Author

enj commented Feb 27, 2017

[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 1d263a2

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_future/587/) (Base Commit: db96925)

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Nits, otherwise this LGTM.

if err := sdnapi.ValidVNID(netnamespace.NetID); err != nil {
allErrs = append(allErrs, field.Invalid(field.NewPath("netID"), netnamespace.NetID, err.Error()))
allErrs = append(allErrs, field.Invalid(field.NewPath("netid"), netnamespace.NetID, err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately we're not consistent with that. But most the places I've checked use uppercase ID, so I'd suggest leaving as was.

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 changed it to match the struct tags.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't notice, sorry for the noise in that case.

@@ -85,6 +86,10 @@ func ValidateClusterNetworkUpdate(obj *sdnapi.ClusterNetwork, old *sdnapi.Cluste
func ValidateHostSubnet(hs *sdnapi.HostSubnet) field.ErrorList {
allErrs := validation.ValidateObjectMeta(&hs.ObjectMeta, false, path.ValidatePathSegmentName, field.NewPath("metadata"))

if hs.Host != hs.Name {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we default Host to Name, if it's empty?

Copy link
Contributor

Choose a reason for hiding this comment

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

This would simplify the redundancy.

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 do not have a strong opinion on if we should or should not default this value. All existing code should be setting both of them to the same thing, so I am leaning towards just leaving this as-is.

Copy link

@pravisankar pravisankar left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@rajatchopra rajatchopra left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -939,15 +933,6 @@ func createSerializers(config restclient.ContentConfig) (*restclient.Serializers
return s, nil
}

// do NOT add anything to this - doing so means you wrote something that is broken
func isInInvalidNameWhiteList(mapping *meta.RESTMapping) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, with this I guess I can get rid of the api group error here as well ;-)

@mfojtik
Copy link
Contributor

mfojtik commented Mar 1, 2017

LGTM [merge]

Do we need this for 1.5?

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 1d263a2

@openshift-bot
Copy link
Contributor

openshift-bot commented Mar 1, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_future/658/) (Base Commit: 517824a) (Image: devenv-rhel7_6004)

@openshift-bot openshift-bot merged commit ba1d1c7 into openshift:master Mar 1, 2017
@enj enj added this to the 1.5.0 milestone Mar 1, 2017
@enj enj mentioned this pull request Mar 1, 2017
@enj
Copy link
Contributor Author

enj commented Mar 1, 2017

@mfojtik yeah we definitely need this for 1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants