Skip to content

Commit cf114f1

Browse files
authored
[slice] Use v7x constant (#835)
* Renames * Rename tpu v7x const
1 parent 4317f99 commit cf114f1

File tree

7 files changed

+34
-33
lines changed

7 files changed

+34
-33
lines changed

slice/api/v1alpha1/slice_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ type Type string
2525

2626
const (
2727
TypeV6e Type = "v6e"
28-
TypeTpu7x Type = "tpu-v7x"
28+
TypeTpu7x Type = "tpu7x"
2929
)
3030

3131
// SliceSpec defines the desired state of Slice.
3232
type SliceSpec struct {
33-
// Type specifies the type of accelerator used in this slice, e.g., "v6e", "tpu-v7x".
33+
// Type specifies the type of accelerator used in this slice, e.g., "v6e", "tpu7x".
3434
// +kubebuilder:validation:Immutable
35-
// +kubebuilder:validation:Enum=v6e;tpu-v7x
35+
// +kubebuilder:validation:Enum=v6e;tpu7x
3636
Type Type `json:"type"`
3737

3838
// Topology represents the network topology of the slice.

slice/config/crd/bases/slice.accelerator.gke.io_slices.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ spec:
7070
type: string
7171
type:
7272
description: Type specifies the type of accelerator used in this slice,
73-
e.g., "v6e", "tpu-v7x".
73+
e.g., "v6e", "tpu7x".
7474
enum:
7575
- v6e
76-
- tpu-v7x
76+
- tpu7x
7777
type: string
7878
required:
7979
- partitionIds

slice/hack/kind-cluster.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ nodes:
2424
- role: worker
2525
labels:
2626
cloud.google.com/gke-node-group: tas-group
27-
cloud.google.com/gke-tpu-accelerator: tpu-v7x
27+
cloud.google.com/gke-tpu-accelerator: tpu7x
2828
cloud.google.com/gce-topology-block: b1
2929
cloud.google.com/gke-tpu-slice-4x4x4-id: sb1
3030
cloud.google.com/gke-tpu-slice-4x4x4-health: true
3131
- role: worker
3232
labels:
3333
cloud.google.com/gke-node-group: tas-group
34-
cloud.google.com/gke-tpu-accelerator: tpu-v7x
34+
cloud.google.com/gke-tpu-accelerator: tpu7x
3535
cloud.google.com/gce-topology-block: b2
3636
cloud.google.com/gke-tpu-slice-4x4x4-id: sb2
3737
cloud.google.com/gke-tpu-slice-4x4x4-health: true
3838
- role: worker
3939
labels:
4040
cloud.google.com/gke-node-group: tas-group
41-
cloud.google.com/gke-tpu-accelerator: tpu-v7x
41+
cloud.google.com/gke-tpu-accelerator: tpu7x
4242
cloud.google.com/gce-topology-block: b2
4343
cloud.google.com/gke-tpu-slice-4x4x4-id: sb3
4444
cloud.google.com/gke-tpu-slice-4x4x4-health: true
4545
- role: worker
4646
labels:
4747
cloud.google.com/gke-node-group: tas-group
48-
cloud.google.com/gke-tpu-accelerator: tpu-v7x
48+
cloud.google.com/gke-tpu-accelerator: tpu7x
4949
cloud.google.com/gce-topology-block: b2
5050
cloud.google.com/gke-tpu-slice-4x4x4-id: sb4
5151
cloud.google.com/gke-tpu-slice-4x4x4-health: true

slice/internal/controller/workload_controller_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func TestWorkloadReconciler(t *testing.T) {
103103
baseAdmissionCheckWrapper := utiltesting.MakeAdmissionCheck(baseACName).ControllerName(SliceControllerName)
104104
basePodSet1Wrapper := *utiltesting.MakePodSet("ps1", 2).
105105
Annotation("cloud.google.com/gke-tpu-topology", "4x4x12").
106-
NodeSelector("cloud.google.com/gke-tpu-accelerator", "tpu-v7x")
106+
NodeSelector("cloud.google.com/gke-tpu-accelerator", string(slice.TypeTpu7x))
107107
basePodSet2Wrapper := basePodSet1Wrapper.Clone().Name("ps2")
108108
basePodSets := []kueue.PodSet{
109109
*basePodSet1Wrapper.DeepCopy(),
@@ -134,12 +134,12 @@ func TestWorkloadReconciler(t *testing.T) {
134134
UID(baseWorkloadName).
135135
AdmissionCheck(buildAdmissionCheckState(kueue.CheckStatePending, ""))
136136
baseSlice1Wrapper := utiltesting.MakeSliceWrapper(core.SliceName(baseWorkloadName, "ps1"), corev1.NamespaceDefault).
137-
Type("tpu-v7x").
137+
Type(slice.TypeTpu7x).
138138
Topology("4x4x12").
139139
ControllerReference(workloadGVK, baseWorkloadName, baseWorkloadName).
140140
PartitionIds("subblock1")
141141
baseSlice2Wrapper := baseSlice1Wrapper.Clone().Name(core.SliceName(baseWorkloadName, "ps2")).
142-
Type("tpu-v7x").
142+
Type(slice.TypeTpu7x).
143143
Topology("4x4x12").
144144
PartitionIds("subblock2")
145145

@@ -448,7 +448,7 @@ func TestWorkloadReconciler(t *testing.T) {
448448
PodSets(
449449
*utiltesting.MakePodSet("ps", 2).
450450
Annotation("cloud.google.com/gke-tpu-topology", "4x4").
451-
NodeSelector("cloud.google.com/gke-tpu-accelerator", "tpu-v7x").
451+
NodeSelector("cloud.google.com/gke-tpu-accelerator", string(slice.TypeTpu7x)).
452452
Obj(),
453453
).
454454
ReserveQuota(
@@ -472,7 +472,7 @@ func TestWorkloadReconciler(t *testing.T) {
472472
PodSets(
473473
*utiltesting.MakePodSet("ps", 2).
474474
Annotation("cloud.google.com/gke-tpu-topology", "4x4").
475-
NodeSelector("cloud.google.com/gke-tpu-accelerator", "tpu-v7x").
475+
NodeSelector("cloud.google.com/gke-tpu-accelerator", string(slice.TypeTpu7x)).
476476
Obj(),
477477
).
478478
ReserveQuota(
@@ -756,7 +756,7 @@ func TestWorkloadReconciler(t *testing.T) {
756756
PodSets(
757757
*utiltesting.MakePodSet("ps1", 2).
758758
Annotation("cloud.google.com/gke-tpu-topology", "4x4x12").
759-
NodeSelector("cloud.google.com/gke-tpu-accelerator", "tpu-v7x").
759+
NodeSelector("cloud.google.com/gke-tpu-accelerator", string(slice.TypeTpu7x)).
760760
Obj(),
761761
*utiltesting.MakePodSet("ps2", 2).
762762
Annotation("cloud.google.com/gke-tpu-topology", "4x4x12").
@@ -775,7 +775,7 @@ func TestWorkloadReconciler(t *testing.T) {
775775
PodSets(
776776
*utiltesting.MakePodSet("ps1", 2).
777777
Annotation("cloud.google.com/gke-tpu-topology", "4x4x12").
778-
NodeSelector("cloud.google.com/gke-tpu-accelerator", "tpu-v7x").
778+
NodeSelector("cloud.google.com/gke-tpu-accelerator", string(slice.TypeTpu7x)).
779779
Obj(),
780780
*utiltesting.MakePodSet("ps2", 2).
781781
Annotation("cloud.google.com/gke-tpu-topology", "4x4x12").

slice/internal/util/testing/wrappers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (s *SliceWrapper) Name(name string) *SliceWrapper {
274274
return s
275275
}
276276

277-
func (s *SliceWrapper) Type(acceleratorType string) *SliceWrapper {
277+
func (s *SliceWrapper) Type(acceleratorType v1alpha1.Type) *SliceWrapper {
278278
s.Spec.Type = v1alpha1.Type(acceleratorType)
279279
return s
280280
}

slice/internal/webhooks/jobset_webhook_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/google/go-cmp/cmp/cmpopts"
2424
jobset "sigs.k8s.io/jobset/api/jobset/v1alpha2"
2525

26+
slice "tpu-slice-controller/api/v1alpha1"
2627
testingjobjobset "tpu-slice-controller/internal/util/testingjobs/jobset"
2728
"tpu-slice-controller/test/utils"
2829
)
@@ -46,7 +47,7 @@ func TestDefault(t *testing.T) {
4647
"cloud.google.com/gke-tpu-topology": "4x4x12",
4748
},
4849
NodeSelector: map[string]string{
49-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
50+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
5051
},
5152
}).
5253
Obj(),
@@ -58,7 +59,7 @@ func TestDefault(t *testing.T) {
5859
"cloud.google.com/gke-tpu-topology": "4x4x12",
5960
},
6061
NodeSelector: map[string]string{
61-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
62+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
6263
},
6364
}).
6465
Obj(),
@@ -70,7 +71,7 @@ func TestDefault(t *testing.T) {
7071
Name: "rj1",
7172
Parallelism: 12,
7273
NodeSelector: map[string]string{
73-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
74+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
7475
},
7576
}).
7677
Obj(),
@@ -80,7 +81,7 @@ func TestDefault(t *testing.T) {
8081
Name: "rj1",
8182
Parallelism: 12,
8283
NodeSelector: map[string]string{
83-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
84+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
8485
},
8586
}).
8687
Obj(),
@@ -117,7 +118,7 @@ func TestDefault(t *testing.T) {
117118
"cloud.google.com/gke-tpu-topology": "4x4x12",
118119
},
119120
NodeSelector: map[string]string{
120-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
121+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
121122
},
122123
}).
123124
Obj(),
@@ -133,7 +134,7 @@ func TestDefault(t *testing.T) {
133134
"kueue.x-k8s.io/podset-slice-size": "4",
134135
},
135136
NodeSelector: map[string]string{
136-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
137+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
137138
"cloud.google.com/gke-tpu-slice-4x4x4-health": "true",
138139
},
139140
}).
@@ -149,7 +150,7 @@ func TestDefault(t *testing.T) {
149150
"cloud.google.com/gke-tpu-topology": "invalid",
150151
},
151152
NodeSelector: map[string]string{
152-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
153+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
153154
},
154155
}).
155156
Obj(),
@@ -162,7 +163,7 @@ func TestDefault(t *testing.T) {
162163
"cloud.google.com/gke-tpu-topology": "invalid",
163164
},
164165
NodeSelector: map[string]string{
165-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
166+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
166167
},
167168
}).
168169
Obj(),

slice/test/e2e/jobset_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var _ = ginkgo.Describe("JobSet", func() {
145145
"cloud.google.com/gke-tpu-topology": tc.tpuTopology,
146146
},
147147
NodeSelector: map[string]string{
148-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
148+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
149149
},
150150
},
151151
).
@@ -223,7 +223,7 @@ var _ = ginkgo.Describe("JobSet", func() {
223223
g.Expect(createdSlice.Spec.PartitionIds).To(gomega.HaveLen(len(tc.wantPartitionIds)))
224224
g.Expect(createdSlice.Spec.PartitionIds).To(gomega.BeComparableTo(tc.wantPartitionIds))
225225
g.Expect(createdSlice.Spec.Topology).To(gomega.Equal(tc.tpuTopology))
226-
g.Expect(createdSlice.Spec.Type).To(gomega.Equal(slice.Type("tpu-v7x")))
226+
g.Expect(createdSlice.Spec.Type).To(gomega.Equal(slice.TypeTpu7x))
227227
}, utils.Timeout, utils.Interval).Should(gomega.Succeed())
228228
})
229229

@@ -453,7 +453,7 @@ var _ = ginkgo.Describe("JobSet", func() {
453453
"cloud.google.com/gke-tpu-topology": "4x4x4",
454454
},
455455
NodeSelector: map[string]string{
456-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
456+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
457457
},
458458
TerminationGracePeriodSeconds: 60,
459459
LifecyclePreStopSleepSeconds: 60,
@@ -557,7 +557,7 @@ var _ = ginkgo.Describe("JobSet", func() {
557557
"cloud.google.com/gke-tpu-topology": "4x4x4",
558558
},
559559
NodeSelector: map[string]string{
560-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
560+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
561561
},
562562
},
563563
).
@@ -686,7 +686,7 @@ var _ = ginkgo.Describe("JobSet", func() {
686686
"cloud.google.com/gke-tpu-topology": "4x4x4",
687687
},
688688
NodeSelector: map[string]string{
689-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
689+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
690690
},
691691
},
692692
).
@@ -809,7 +809,7 @@ var _ = ginkgo.Describe("JobSet", func() {
809809
"cloud.google.com/gke-tpu-topology": "4x4x4",
810810
},
811811
NodeSelector: map[string]string{
812-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
812+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
813813
},
814814
},
815815
).
@@ -905,7 +905,7 @@ var _ = ginkgo.Describe("JobSet", func() {
905905
"cloud.google.com/gke-tpu-topology": "4x4x4",
906906
},
907907
NodeSelector: map[string]string{
908-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
908+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
909909
},
910910
},
911911
testingjobsjobset.ReplicatedJobRequirements{
@@ -919,7 +919,7 @@ var _ = ginkgo.Describe("JobSet", func() {
919919
"cloud.google.com/gke-tpu-topology": "4x4x4",
920920
},
921921
NodeSelector: map[string]string{
922-
"cloud.google.com/gke-tpu-accelerator": "tpu-v7x",
922+
"cloud.google.com/gke-tpu-accelerator": string(slice.TypeTpu7x),
923923
},
924924
},
925925
).

0 commit comments

Comments
 (0)