From 466dcdfcf6386718093fcf8fcc2d2f57fb95e06e Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 31 Aug 2021 08:39:55 +0200 Subject: [PATCH] auth: use generic ephemeral volume helper functions The name concatenation and ownership check were originally considered small enough to not warrant dedicated functions, but the intent of the code is more readable with them. --- plugin/pkg/auth/authorizer/node/graph.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/pkg/auth/authorizer/node/graph.go b/plugin/pkg/auth/authorizer/node/graph.go index c0d8bee4e30..793765d90b9 100644 --- a/plugin/pkg/auth/authorizer/node/graph.go +++ b/plugin/pkg/auth/authorizer/node/graph.go @@ -22,6 +22,7 @@ import ( corev1 "k8s.io/api/core/v1" utilfeature "k8s.io/apiserver/pkg/util/feature" + "k8s.io/component-helpers/storage/ephemeral" pvutil "k8s.io/kubernetes/pkg/api/v1/persistentvolume" podutil "k8s.io/kubernetes/pkg/api/v1/pod" "k8s.io/kubernetes/pkg/features" @@ -386,7 +387,7 @@ func (g *Graph) AddPod(pod *corev1.Pod) { if v.PersistentVolumeClaim != nil { claimName = v.PersistentVolumeClaim.ClaimName } else if v.Ephemeral != nil && utilfeature.DefaultFeatureGate.Enabled(features.GenericEphemeralVolume) { - claimName = pod.Name + "-" + v.Name + claimName = ephemeral.VolumeClaimName(pod, &v) } if claimName != "" { pvcVertex := g.getOrCreateVertex_locked(pvcVertexType, pod.Namespace, claimName)