mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-12 20:46:47 +00:00
Fix RunnerDeployment-managed runner pods to not get RUNNER_NAME and RUNNER_TOKEN injected twice
Since #1179, runner pods managed by RunnerDeployment had two duplicate environment variables for RUNNER_NAME and RUNNER_TOKEN. This fixes that.
This commit is contained in:
@@ -61,4 +61,7 @@ const (
|
|||||||
//
|
//
|
||||||
// See https://github.com/actions-runner-controller/actions-runner-controller/pull/1180
|
// See https://github.com/actions-runner-controller/actions-runner-controller/pull/1180
|
||||||
DefaultRunnerPodRecreationDelayAfterWebhookScale = 10 * time.Minute
|
DefaultRunnerPodRecreationDelayAfterWebhookScale = 10 * time.Minute
|
||||||
|
|
||||||
|
EnvVarRunnerName = "RUNNER_NAME"
|
||||||
|
EnvVarRunnerToken = "RUNNER_TOKEN"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -453,19 +453,12 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
|
|||||||
func mutatePod(pod *corev1.Pod, token string) *corev1.Pod {
|
func mutatePod(pod *corev1.Pod, token string) *corev1.Pod {
|
||||||
updated := pod.DeepCopy()
|
updated := pod.DeepCopy()
|
||||||
|
|
||||||
for i := range pod.Spec.Containers {
|
if getRunnerEnv(pod, EnvVarRunnerName) == "" {
|
||||||
if pod.Spec.Containers[i].Name == "runner" {
|
setRunnerEnv(updated, EnvVarRunnerName, pod.ObjectMeta.Name)
|
||||||
updated.Spec.Containers[i].Env = append(updated.Spec.Containers[i].Env,
|
}
|
||||||
corev1.EnvVar{
|
|
||||||
Name: "RUNNER_NAME",
|
if getRunnerEnv(pod, EnvVarRunnerToken) == "" {
|
||||||
Value: pod.ObjectMeta.Name,
|
setRunnerEnv(updated, EnvVarRunnerToken, token)
|
||||||
},
|
|
||||||
corev1.EnvVar{
|
|
||||||
Name: "RUNNER_TOKEN",
|
|
||||||
Value: token,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return updated
|
return updated
|
||||||
|
|||||||
Reference in New Issue
Block a user