mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
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:
parent
6eca142082
commit
3c2cfd9a4f
@ -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
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user