Repository: kubernetes-sigs/kueue
Pull request #204 (2022-04-11 14:58:01)

Renamed flavor.resourceFlavor to flavor.name

#### What type of PR is this?

/kind cleanup
/kind api-change

#### What this PR does / why we need it:

Renames clusterQueue.spec.requestableResources[*].flavors[*].resourceFlavor -> spec.requestableResources[*].flavors[*].name


#### Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

#### Special notes for your reviewer:



k8s-ci-robot: @ahg-g: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-kueue-test-unit-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-test-unit-main/1513531827833278464) | true | `/test pull-kueue-test-unit-main`
pull-kueue-test-integration-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-test-integration-main/1513531827862638592) | true | `/test pull-kueue-test-integration-main`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=kueue&pr=204). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aahg-g). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/kueue/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @ahg-g: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-kueue-test-unit-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-test-unit-main/1513531827833278464) | true | `/test pull-kueue-test-unit-main`
pull-kueue-test-integration-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-test-integration-main/1513531827862638592) | true | `/test pull-kueue-test-integration-main`
pull-kueue-verify-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-verify-main/1513531827891998720) | true | `/test pull-kueue-verify-main`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=kueue&pr=204). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aahg-g). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/kueue/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @ahg-g: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-kueue-test-unit-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-test-unit-main/1513531827833278464) | true | `/test pull-kueue-test-unit-main`
pull-kueue-test-integration-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-test-integration-main/1513531827862638592) | true | `/test pull-kueue-test-integration-main`
pull-kueue-verify-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-verify-main/1513531827891998720) | true | `/test pull-kueue-verify-main`
pull-kueue-build-image-main | d1a79aaa83d81d0742d5ca037ab8eacfc4f3a5ba | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kueue/204/pull-kueue-build-image-main/1513531827925553152) | true | `/test pull-kueue-build-image-main`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=kueue&pr=204). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aahg-g). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/kueue/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/kueue/pull/204#" title="Author self-approved">ahg-g</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fkueue).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/kueue/blob/main/OWNERS)~~ [ahg-g]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/apis/core/v1alpha1/clusterqueue_types.go b/apis/core/v1alpha1/clusterqueue_types.go
index 84a2ed970..1bb3bbdd2 100644
--- a/apis/core/v1alpha1/clusterqueue_types.go
+++ b/apis/core/v1alpha1/clusterqueue_types.go
@@ -183,14 +183,14 @@ type Resource struct {
 	// least one flavor must exist.
 	//
 	// +listType=map
-	// +listMapKey=resourceFlavor
+	// +listMapKey=name
 	Flavors []Flavor `json:"flavors,omitempty"`
 }
 
 type Flavor struct {
-	// resourceFlavor is a reference to the resourceFlavor that defines this flavor.
+	// name is a reference to the resourceFlavor that defines this flavor.
 	// +kubebuilder:default=default
-	ResourceFlavor ResourceFlavorReference `json:"resourceFlavor"`
+	Name ResourceFlavorReference `json:"name"`
 
 	// quota is the limit of resource usage at a point in time.
 	Quota Quota `json:"quota"`
diff --git a/config/crd/bases/kueue.x-k8s.io_clusterqueues.yaml b/config/crd/bases/kueue.x-k8s.io_clusterqueues.yaml
index a59ea3b07..4c0b99191 100644
--- a/config/crd/bases/kueue.x-k8s.io_clusterqueues.yaml
+++ b/config/crd/bases/kueue.x-k8s.io_clusterqueues.yaml
@@ -180,6 +180,11 @@ spec:
                         can’t be empty, at least one flavor must exist."
                       items:
                         properties:
+                          name:
+                            default: default
+                            description: name is a reference to the resourceFlavor
+                              that defines this flavor.
+                            type: string
                           quota:
                             description: quota is the limit of resource usage at a
                               point in time.
@@ -210,18 +215,13 @@ spec:
                                 pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
                                 x-kubernetes-int-or-string: true
                             type: object
-                          resourceFlavor:
-                            default: default
-                            description: resourceFlavor is a reference to the resourceFlavor
-                              that defines this flavor.
-                            type: string
                         required:
+                        - name
                         - quota
-                        - resourceFlavor
                         type: object
                       type: array
                       x-kubernetes-list-map-keys:
-                      - resourceFlavor
+                      - name
                       x-kubernetes-list-type: map
                     name:
                       description: name of the resource. For example, cpu, memory
diff --git a/docs/concepts/cluster_queue.md b/docs/concepts/cluster_queue.md
index 5e94b676b..843988f90 100644
--- a/docs/concepts/cluster_queue.md
+++ b/docs/concepts/cluster_queue.md
@@ -19,12 +19,12 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 9
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 36Gi
 ```
@@ -103,7 +103,7 @@ taints:
 ```
 
 You can use the `.metadata.name` to reference a flavor from a ClusterQueue in
-the `.spec.requestableResources[*].flavors[*].resourceFlavor` field.
+the `.spec.requestableResources[*].flavors[*].name` field.
 
 For each resource of each [pod set](workload.md#pod-sets) in a Workload, Kueue
 assigns the first flavor in the `.spec.requestableResources[*].resources.flavors`
@@ -199,12 +199,12 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 9
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 36Gi
 ```
@@ -220,12 +220,12 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 12
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 48Gi
 ```
diff --git a/docs/tasks/administer_cluster_quotas.md b/docs/tasks/administer_cluster_quotas.md
index 22e83a9e5..d659ebd71 100644
--- a/docs/tasks/administer_cluster_quotas.md
+++ b/docs/tasks/administer_cluster_quotas.md
@@ -43,12 +43,12 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 9
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 36Gi
 ```
@@ -184,15 +184,15 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: x86
+    - name: x86
       quota:
         min: 9
-    - resourceFlavor: arm
+    - name: arm
       quota:
         min: 12
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 84Gi
 ```
@@ -230,13 +230,13 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 9
         max: 15
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 36Gi
         max: 60Gi
@@ -254,12 +254,12 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 12
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 48Gi
 ```
@@ -298,16 +298,16 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: arm
+    - name: arm
       quota:
         min: 9
         max: 9
-    - resourceFlavor: x86
+    - name: x86
       quota:
         min: 0
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 36Gi
 ```
@@ -324,16 +324,16 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: arm
+    - name: arm
       quota:
         min: 12
         max: 12
-    - resourceFlavor: x86
+    - name: x86
       quota:
         min: 0
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 48Gi
 ```
@@ -350,12 +350,12 @@ spec:
   requestableResources:
   - name: "cpu"
     flavors:
-    - resourceFlavor: x86
+    - name: x86
       quota:
         min: 6
   - name: "memory"
     flavors:
-    - resourceFlavor: default
+    - name: default
       quota:
         min: 24Gi
 ```
diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go
index 8072d8e63..9e0990a5c 100644
--- a/pkg/cache/cache.go
+++ b/pkg/cache/cache.go
@@ -131,7 +131,7 @@ func (c *ClusterQueue) update(in *kueue.ClusterQueue, resourceFlavors map[string
 		existingUsedFlavors := c.UsedResources[r.Name]
 		usedFlavors := make(map[string]int64, len(r.Flavors))
 		for _, f := range r.Flavors {
-			usedFlavors[string(f.ResourceFlavor)] = existingUsedFlavors[string(f.ResourceFlavor)]
+			usedFlavors[string(f.Name)] = existingUsedFlavors[string(f.Name)]
 		}
 		usedResources[r.Name] = usedFlavors
 	}
@@ -473,7 +473,7 @@ func resourceLimitsByName(in []kueue.Resource) map[corev1.ResourceName][]FlavorL
 		for i := range flavors {
 			f := &r.Flavors[i]
 			fLimits := FlavorLimits{
-				Name: string(f.ResourceFlavor),
+				Name: string(f.Name),
 				Min:  workload.ResourceValue(r.Name, f.Quota.Min),
 			}
 			if f.Quota.Max != nil {


Test patch:
diff --git a/pkg/cache/cache_test.go b/pkg/cache/cache_test.go
index 00d8d8e70..4f0615256 100644
--- a/pkg/cache/cache_test.go
+++ b/pkg/cache/cache_test.go
@@ -46,7 +46,7 @@ func TestCacheClusterQueueOperations(t *testing.T) {
 					{
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{{
-							ResourceFlavor: "default",
+							Name: "default",
 							Quota: kueue.Quota{
 								Min: resource.MustParse("10"),
 								Max: pointer.Quantity(resource.MustParse("20")),
@@ -64,7 +64,7 @@ func TestCacheClusterQueueOperations(t *testing.T) {
 					{
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{{
-							ResourceFlavor: "default",
+							Name: "default",
 							Quota: kueue.Quota{
 								Min: resource.MustParse("15"),
 							},
@@ -208,7 +208,7 @@ func TestCacheClusterQueueOperations(t *testing.T) {
 									Name: corev1.ResourceCPU,
 									Flavors: []kueue.Flavor{
 										{
-											ResourceFlavor: "default",
+											Name: "default",
 											Quota: kueue.Quota{
 												Min: resource.MustParse("5"),
 												Max: pointer.Quantity(resource.MustParse("10")),
@@ -340,8 +340,8 @@ func TestCacheWorkloadOperations(t *testing.T) {
 					{
 						Name: "cpu",
 						Flavors: []kueue.Flavor{
-							{ResourceFlavor: "on-demand"},
-							{ResourceFlavor: "spot"},
+							{Name: "on-demand"},
+							{Name: "spot"},
 						},
 					},
 				},
@@ -354,8 +354,8 @@ func TestCacheWorkloadOperations(t *testing.T) {
 					{
 						Name: "cpu",
 						Flavors: []kueue.Flavor{
-							{ResourceFlavor: "on-demand"},
-							{ResourceFlavor: "spot"},
+							{Name: "on-demand"},
+							{Name: "spot"},
 						},
 					},
 				},
@@ -801,7 +801,7 @@ func TestClusterQueueUsage(t *testing.T) {
 					Name: corev1.ResourceCPU,
 					Flavors: []kueue.Flavor{
 						{
-							ResourceFlavor: "default",
+							Name: "default",
 							Quota: kueue.Quota{
 								Min: resource.MustParse("10"),
 								Max: pointer.Quantity(resource.MustParse("20")),
@@ -813,14 +813,14 @@ func TestClusterQueueUsage(t *testing.T) {
 					Name: "example.com/gpu",
 					Flavors: []kueue.Flavor{
 						{
-							ResourceFlavor: "model_a",
+							Name: "model_a",
 							Quota: kueue.Quota{
 								Min: resource.MustParse("5"),
 								Max: pointer.Quantity(resource.MustParse("10")),
 							},
 						},
 						{
-							ResourceFlavor: "model_b",
+							Name: "model_b",
 							Quota: kueue.Quota{
 								Min: resource.MustParse("5"),
 								// No max.
diff --git a/pkg/cache/snapshot_test.go b/pkg/cache/snapshot_test.go
index f6fbb3f26..6f230fd67 100644
--- a/pkg/cache/snapshot_test.go
+++ b/pkg/cache/snapshot_test.go
@@ -53,13 +53,13 @@ func TestSnapshot(t *testing.T) {
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "demand",
+								Name: "demand",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("100"),
 								},
 							},
 							{
-								ResourceFlavor: "spot",
+								Name: "spot",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("200"),
 								},
@@ -80,7 +80,7 @@ func TestSnapshot(t *testing.T) {
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "spot",
+								Name: "spot",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("100"),
 								},
@@ -91,7 +91,7 @@ func TestSnapshot(t *testing.T) {
 						Name: "example.com/gpu",
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "default",
+								Name: "default",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("50"),
 								},
@@ -111,7 +111,7 @@ func TestSnapshot(t *testing.T) {
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "default",
+								Name: "default",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("100"),
 								},
diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go
index a0562c133..3791afece 100644
--- a/pkg/scheduler/scheduler_test.go
+++ b/pkg/scheduler/scheduler_test.go
@@ -75,7 +75,7 @@ func TestSchedule(t *testing.T) {
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "default",
+								Name: "default",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("50"),
 									Max: pointer.Quantity(resource.MustParse("50")),
@@ -105,14 +105,14 @@ func TestSchedule(t *testing.T) {
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "on-demand",
+								Name: "on-demand",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("50"),
 									Max: pointer.Quantity(resource.MustParse("100")),
 								},
 							},
 							{
-								ResourceFlavor: "spot",
+								Name: "spot",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("100"),
 									Max: pointer.Quantity(resource.MustParse("100")),
@@ -142,14 +142,14 @@ func TestSchedule(t *testing.T) {
 						Name: corev1.ResourceCPU,
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "on-demand",
+								Name: "on-demand",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("50"),
 									Max: pointer.Quantity(resource.MustParse("60")),
 								},
 							},
 							{
-								ResourceFlavor: "spot",
+								Name: "spot",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("0"),
 									Max: pointer.Quantity(resource.MustParse("100")),
@@ -161,7 +161,7 @@ func TestSchedule(t *testing.T) {
 						Name: "example.com/gpu",
 						Flavors: []kueue.Flavor{
 							{
-								ResourceFlavor: "model-a",
+								Name: "model-a",
 								Quota: kueue.Quota{
 									Min: resource.MustParse("20"),
 									Max: pointer.Quantity(resource.MustParse("20")),
diff --git a/pkg/util/testing/wrappers.go b/pkg/util/testing/wrappers.go
index bfca7d2f0..7ecf6a039 100644
--- a/pkg/util/testing/wrappers.go
+++ b/pkg/util/testing/wrappers.go
@@ -312,7 +312,7 @@ type FlavorWrapper struct{ kueue.Flavor }
 // MakeFlavor creates a wrapper for a resource flavor.
 func MakeFlavor(rf, min string) *FlavorWrapper {
 	return &FlavorWrapper{kueue.Flavor{
-		ResourceFlavor: kueue.ResourceFlavorReference(rf),
+		Name: kueue.ResourceFlavorReference(rf),
 		Quota: kueue.Quota{
 			Min: resource.MustParse(min),
 		},