Skip to content

Commit 149d3fc

Browse files
committed
index from 0 for generated pod claim names
Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com>
1 parent bffce49 commit 149d3fc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

internal/shared/resourceclaims.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func generateUniquePodClaimName(nameCache map[string]int, nimServiceName string,
100100
if ok {
101101
nameCache[uniqueName] = count + 1
102102
} else {
103-
nameCache[uniqueName] = 1
103+
nameCache[uniqueName] = 0
104104
}
105105
return fmt.Sprintf("%s-%d", uniqueName, nameCache[uniqueName])
106106
}

internal/shared/resourceclaims_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ var _ = Describe("DRA resourceclaim tests", func() {
283283

284284
name1 := generateUniquePodClaimName(nameCache, nimServiceName, resource)
285285
Expect(name1).To(HavePrefix(expectedPrefix(testClaimHash, 0)))
286-
Expect(name1).To(HaveSuffix("-1"))
286+
Expect(name1).To(HaveSuffix("-0"))
287287
})
288288

289289
It("should generate unique name for ResourceClaimTemplateName", func() {
@@ -293,7 +293,7 @@ var _ = Describe("DRA resourceclaim tests", func() {
293293

294294
name1 := generateUniquePodClaimName(nameCache, nimServiceName, resource)
295295
Expect(name1).To(HavePrefix(expectedPrefix(testTemplateHash, 1)))
296-
Expect(name1).To(HaveSuffix("-1"))
296+
Expect(name1).To(HaveSuffix("-0"))
297297
})
298298

299299
It("should handle different templateswith same name", func() {
@@ -309,9 +309,9 @@ var _ = Describe("DRA resourceclaim tests", func() {
309309

310310
Expect(name1).ToNot(Equal(name2))
311311
Expect(name1).To(HavePrefix(expectedPrefix(testTemplateHash, 1)))
312-
Expect(name1).To(HaveSuffix("-1"))
312+
Expect(name1).To(HaveSuffix("-0"))
313313
Expect(name2).To(HavePrefix(expectedPrefix(testTemplateHash, 1)))
314-
Expect(name2).To(HaveSuffix("-2"))
314+
Expect(name2).To(HaveSuffix("-1"))
315315
})
316316

317317
It("should handle claims and templates with different names", func() {
@@ -327,7 +327,7 @@ var _ = Describe("DRA resourceclaim tests", func() {
327327

328328
Expect(name1).ToNot(Equal(name2))
329329
Expect(name1).To(HavePrefix(expectedPrefix(testClaim1Hash, 0)))
330-
Expect(name1).To(HaveSuffix("-1"))
330+
Expect(name1).To(HaveSuffix("-0"))
331331
Expect(name2).To(HavePrefix(expectedPrefix(testTemplateHash, 1)))
332332
Expect(name2).To(HaveSuffix("-1"))
333333
})
@@ -346,8 +346,8 @@ var _ = Describe("DRA resourceclaim tests", func() {
346346
// The names should be different due to the counter, but the prefix should be the same
347347
Expect(name1).ToNot(Equal(name2))
348348
Expect(name1).To(HavePrefix(expectedPrefix(testClaimHash, 0)))
349-
Expect(name1).To(HaveSuffix("-1"))
350-
Expect(name2).To(HavePrefix(expectedPrefix(testClaimHash, 1)))
349+
Expect(name1).To(HaveSuffix("-0"))
350+
Expect(name2).To(HavePrefix(expectedPrefix(testClaimHash, 0)))
351351
Expect(name2).To(HaveSuffix("-1"))
352352
})
353353
})

0 commit comments

Comments
 (0)