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

Cleanup: Use ResourceFlavor.metadata.labels #353

Conversation

thisisprasad
Copy link
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

ResourceFlavor's .labels field is removed. Now users can specify the labels in .metadata.labels.

Which issue(s) this PR fixes:

Fixes #334

Special notes for your reviewer:

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 25, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @thisisprasad. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 25, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: thisisprasad
Once this PR has been reviewed and has the lgtm label, please assign alculquicondor for approval by writing /assign @alculquicondor in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 25, 2022
@thisisprasad
Copy link
Contributor Author

/assign @alculquicondor

Copy link
Contributor

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

I guess the validation code just works without changes?

Comment on lines -32 to -37
// labels associated with this flavor. They are matched against or
// converted to node affinity constraints on the workload’s pods.
// For example, cloud.provider.com/accelerator: nvidia-tesla-k80.
// More info: http://kubernetes.io/docs/user-guide/labels
//
// labels can be up to 8 elements.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can something similar be added above ObjectMeta? Would that be included in the CRD yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding single or multi-line comment does not generate description for ObjectMeta in CRD yaml using make manifests command.
metav1.ObjectMeta struct is embedded inside ResourceFlavor struct. It's not a separate field defined. Don't know of any other way to add for .metadata.labels.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. That's fine then.

@@ -68,7 +69,7 @@ var _ = ginkgo.Describe("ResourceFlavor Webhook", func() {
resourceFlavor := testing.MakeResourceFlavor("resource-flavor").Label("foo", "@abcd").Obj()
err := k8sClient.Create(ctx, resourceFlavor)
gomega.Expect(err).Should(gomega.HaveOccurred())
gomega.Expect(errors.IsForbidden(err)).Should(gomega.BeTrue(), "error: %v", err)
gomega.Expect(err.Error()).To(gomega.ContainSubstring(errorInvalidLabelValue("@abcd")))
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error returned is not of type forbidden. Hence, added the error substring. Any other way to assert the error?

Copy link
Contributor

Choose a reason for hiding this comment

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

there should be an error type that matches in the package.

The substrings could change upstream, so I rather not pay attention to that.

Copy link
Contributor

Choose a reason for hiding this comment

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

probably errors.IsBadRequest

@@ -92,7 +93,11 @@ var _ = ginkgo.Describe("ResourceFlavor Webhook", func() {
ginkgo.By("Updating the resourceFlavor with invalid labels")
err := k8sClient.Update(ctx, &created)
gomega.Expect(err).Should(gomega.HaveOccurred())
gomega.Expect(errors.IsForbidden(err)).Should(gomega.BeTrue(), "error: %v", err)
gomega.Expect(err.Error()).To(gomega.ContainSubstring(errorInvalidLabelValue("@abcd")))
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

@alculquicondor
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 25, 2022
@alculquicondor
Copy link
Contributor

Actually, I think you need to update the validation code to have the proper path for "too many labels"

@alculquicondor
Copy link
Contributor

I created #355 to accelerate the process, so that we can release today. I kept your name on the commit :)

/close

@k8s-ci-robot
Copy link
Contributor

@alculquicondor: Closed this PR.

In response to this:

I created #355 to accelerate the process, so that we can release today. I kept your name on the commit :)

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Use ResourceFlavor.metadata.labels instead of ResourceFlavor.labels
3 participants