Skip to content

Commit

Permalink
Add random suffix when make volumn from secret
Browse files Browse the repository at this point in the history
To avoid same volumn name when length of secret name is too big(more than 63)
  • Loading branch information
vincent-pli authored and tekton-robot committed Feb 14, 2020
1 parent e43c8de commit 7cdd923
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/pod/creds_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func credsInit(credsImage string, serviceAccountName, namespace string, kubeclie
}

if matched {
name := names.SimpleNameGenerator.RestrictLength(fmt.Sprintf("tekton-internal-secret-volume-%s", secret.Name))
name := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("tekton-internal-secret-volume-%s", secret.Name))
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: name,
MountPath: credentials.VolumeName(secret.Name),
Expand Down
2 changes: 1 addition & 1 deletion pkg/pod/creds_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCredsInit(t *testing.T) {
},
Env: envVars,
VolumeMounts: append(volumeMounts, corev1.VolumeMount{
Name: "tekton-internal-secret-volume-my-creds",
Name: "tekton-internal-secret-volume-my-creds-9l9zj",
MountPath: "/tekton/creds-secrets/my-creds",
}),
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func TestMakePod(t *testing.T) {
names.TestingSeed()

secretsVolumeMount := corev1.VolumeMount{
Name: "tekton-internal-secret-volume-multi-creds",
Name: "tekton-internal-secret-volume-multi-creds-9l9zj",
MountPath: "/tekton/creds-secrets/multi-creds",
}
secretsVolume := corev1.Volume{
Name: "tekton-internal-secret-volume-multi-creds",
Name: "tekton-internal-secret-volume-multi-creds-9l9zj",
VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: "multi-creds"}},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (c *Reconciler) createPod(tr *v1alpha1.TaskRun, rtr *resources.ResolvedTask

pod, err := podconvert.MakePod(c.Images, tr, *ts, c.KubeClientSet, c.entrypointCache)
if err != nil {
return nil, fmt.Errorf("translating Build to Pod: %w", err)
return nil, fmt.Errorf("translating TaskSpec to Pod: %w", err)
}

return c.KubeClientSet.CoreV1().Pods(tr.Namespace).Create(pod)
Expand Down

0 comments on commit 7cdd923

Please sign in to comment.