resource claim controller: separate generated suffix from base

When the resource claim name inside the pod had some suffix like "1a" in
"resource-1a", the generated name suffix got added directly after that, leading
to "my-pod-resource-1ax6zgt".

Adding another hyphen makes the result more readable: "my-pod-resource-1a-x6zgt".
This commit is contained in:
Patrick Ohly 2023-09-01 07:51:41 +02:00
parent 6eca142082
commit 3c2cfd9a4f
2 changed files with 2 additions and 2 deletions

View File

@ -616,7 +616,7 @@ func (ec *Controller) handleClaim(ctx context.Context, pod *v1.Pod, podClaim v1.
annotations = make(map[string]string) annotations = make(map[string]string)
} }
annotations[podResourceClaimAnnotation] = podClaim.Name annotations[podResourceClaimAnnotation] = podClaim.Name
generateName := pod.Name + "-" + podClaim.Name generateName := pod.Name + "-" + podClaim.Name + "-"
maxBaseLen := 57 // Leave space for hyphen and 5 random characters in a name with 63 characters. maxBaseLen := 57 // Leave space for hyphen and 5 random characters in a name with 63 characters.
if len(generateName) > maxBaseLen { if len(generateName) > maxBaseLen {
// We could leave truncation to the apiserver, but as // We could leave truncation to the apiserver, but as

View File

@ -62,7 +62,7 @@ var (
testClaimReserved = reserveClaim(testClaimAllocated, testPodWithResource) testClaimReserved = reserveClaim(testClaimAllocated, testPodWithResource)
testClaimReservedTwice = reserveClaim(testClaimReserved, otherTestPod) testClaimReservedTwice = reserveClaim(testClaimReserved, otherTestPod)
generatedTestClaim = makeGeneratedClaim(podResourceClaimName, testPodName+"-"+podResourceClaimName, testNamespace, className, 1, makeOwnerReference(testPodWithResource, true)) generatedTestClaim = makeGeneratedClaim(podResourceClaimName, testPodName+"-"+podResourceClaimName+"-", testNamespace, className, 1, makeOwnerReference(testPodWithResource, true))
generatedTestClaimAllocated = allocateClaim(generatedTestClaim) generatedTestClaimAllocated = allocateClaim(generatedTestClaim)
generatedTestClaimReserved = reserveClaim(generatedTestClaimAllocated, testPodWithResource) generatedTestClaimReserved = reserveClaim(generatedTestClaimAllocated, testPodWithResource)