Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Ensure that ObjectMeta field selectors (e.g. name and namespace) can be used appropriately for all types #2214

Merged
merged 2 commits into from
Aug 6, 2018
Merged

Conversation

jimmidyson
Copy link
Contributor

Noticed that the ObjectMeta fields metadata.name and metadata.namespace do not work as they haven't been registered in conversions.

I also took the liberty of tidying up the fields methods in registry to make them consitent in their approach.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 19, 2018
Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Thanks for adding this! Once it is in we can use it to clean up some of our existing code around filtering by name vs external name. I'll create a follow-on issue once this is merged.

Just need a few new tests and this should be all set.

@@ -89,8 +89,7 @@ func Match(label labels.Selector, field fields.Selector) storage.SelectionPredic

// toSelectableFields returns a field set that represents the object for matching purposes.
func toSelectableFields(broker *servicecatalog.ClusterServiceBroker) fields.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(&broker.ObjectMeta, true)
return generic.MergeFieldsSets(objectMetaFieldsSet, nil)
return generic.ObjectMetaFieldsSet(&broker.ObjectMeta, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Thanks for fixing the "hasnamespacefield" arg

@@ -542,6 +542,15 @@ func testClusterServiceClassClient(sType server.StorageType, client servicecatal
return fmt.Errorf("should have two ClusterServiceClasses, had %v ClusterServiceClasses", len(serviceClasses.Items))
}

serviceClasses, err = serviceClassClient.List(metav1.ListOptions{FieldSelector: "metadata.name=" + name})
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we are missing existing tests for ServiceClasses and ServicePlan which were also modified in this PR.

Let's use those existing tests in this file and add tests for these resources as well so that we can test all of your changes.

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 can't find any existing tests for these non-namespaced resources so just to clarify: would you like me to add tests for them in this PR? Or have I missed them somehow?

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 suggesting that you copy the existing test testClusterServiceClassClient and tweak it to test the namespaced resource ServiceClasss so that you can also test your changes made to that as well. Same for plans (TestClusterServicePlanClient).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 23, 2018
client, _, shutdownServer := getFreshApiserverAndClient(t, sType.String(), func() runtime.Object {
return &servicecatalog.ClusterServicePlan{}
return &servicecatalog.ClusterServiceClass{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be ServiceClass{}, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep good catch thanks! Updated.

@@ -568,17 +770,23 @@ func testClusterServiceClassClient(sType server.StorageType, client servicecatal
return nil
}

// TestClusterServicePlanClient exercises the ClusterServicePlan client.
func TestClusterServicePlanClient(t *testing.T) {
// TestClusterServiceClassClient exercises the ClusterServiceClass client.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this test for namespaced classes or cluster scoped class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aligned all types/names/comments now (I hope!).

})
defer shutdownServer()

if err := testClusterServicePlanClient(sType, client, name); err != nil {
if err := testClusterServiceClassClient(sType, client, name); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's get the comment, the function name and this call to all align. 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - sorry!

// check that the plan is the same from get and list
servicePlanListed := &servicePlans.Items[0]
if !reflect.DeepEqual(servicePlanAtServer, servicePlanListed) {
// check that the broker is the same from get and list
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this say class instead of broker?

@@ -33,3 +49,19 @@ func falsePtr() *bool {
b := false
return &b
}

func enableNamespacedResources() (resetFeaturesFunc func(), 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.

👍

@MHBauer
Copy link
Contributor

MHBauer commented Jul 24, 2018

/test pull-service-catalog-xbuild

@jimmidyson
Copy link
Contributor Author

Any chance of a review of this?

@jboyd01
Copy link
Contributor

jboyd01 commented Aug 1, 2018

@jimmidyson I see @carolynvs left some review comments & requested some changes.

@jimmidyson
Copy link
Contributor Author

Which I'm pretty sure I've addressed...

@jboyd01
Copy link
Contributor

jboyd01 commented Aug 3, 2018

fixes #2260

// t.Errorf("%q test failed", sType)
// }
// }
sType := server.StorageTypeEtcd
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is copy and paste of another test, it should be fixed up as well and remove the CRD comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed up and removed comments.

@jboyd01
Copy link
Contributor

jboyd01 commented Aug 6, 2018

@jimmidyson This looks solid to me. A couple of things still outstanding here: @carolynvs called out issues in #2214 about inconsistencies between the Name Spaced ServiceClass vs ClusterServiceClass and a nit on an old comment. and @MHBauer asking to clean up some dead CRD comments in #2214 Thanks for the work, I look forward to getting this merged.

@jimmidyson
Copy link
Contributor Author

Sorry I missed those things... I'm on it later today, will be ready for merge then.

@jimmidyson
Copy link
Contributor Author

@jboyd01 @carolynvs Ready for another review round - thanks for your comments!

@jboyd01
Copy link
Contributor

jboyd01 commented Aug 6, 2018

Thanks @jimmidyson!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 6, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jboyd01

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2018
@jboyd01 jboyd01 added the LGTM1 label Aug 6, 2018
@k8s-ci-robot k8s-ci-robot merged commit 3984a95 into kubernetes-retired:master Aug 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. LGTM1 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.

5 participants