Hand a finished runner's pod back as soon as its job is over (#4673)

This commit is contained in:
Nikola Jokic
2026-09-23 14:12:11 +02:00
committed by GitHub
parent 390ceb03f6
commit 2adef8f8c4
13 changed files with 797 additions and 52 deletions
@@ -866,6 +866,55 @@ func TestTemplate_ControllerDeployment_MaxConcurrentReconciles(t *testing.T) {
})
}
// TestTemplate_ControllerDeployment_TerminatedRunnerPodGracePeriod pins how the
// grace period of a finished runner pod reaches the controller.
//
// Leaving the value unset has to render no flag at all, so the controller keeps
// its own default of removing those pods immediately. Setting it is what a
// cluster that wants finished pods to stay readable for a while does, and a
// negative value is how it asks for the pod's own grace period instead.
func TestTemplate_ControllerDeployment_TerminatedRunnerPodGracePeriod(t *testing.T) {
t.Parallel()
helmChartPath, err := filepath.Abs("../../gha-runner-scale-set-controller")
require.NoError(t, err)
releaseName := "test-arc"
namespaceName := "test-" + strings.ToLower(random.UniqueID())
renderArgs := func(t *testing.T, values map[string]string) []string {
options := &helm.Options{
Logger: logger.Discard,
SetValues: values,
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}
output := helm.RenderTemplateContext(t, t.Context(), options, helmChartPath, releaseName, []string{"templates/deployment.yaml"})
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(t, output, &deployment)
require.Len(t, deployment.Spec.Template.Spec.Containers, 1)
return deployment.Spec.Template.Spec.Containers[0].Args
}
t.Run("no flag renders by default", func(t *testing.T) {
for _, arg := range renderArgs(t, nil) {
assert.NotContains(t, arg, "--terminated-runner-pod-grace-period-seconds")
}
})
t.Run("the flag renders when configured", func(t *testing.T) {
args := renderArgs(t, map[string]string{"flags.terminatedRunnerPodGracePeriodSeconds": "30"})
assert.Contains(t, args, "--terminated-runner-pod-grace-period-seconds=30")
})
t.Run("the flag renders when it hands the grace period back to the pod", func(t *testing.T) {
args := renderArgs(t, map[string]string{"flags.terminatedRunnerPodGracePeriodSeconds": "-1"})
assert.Contains(t, args, "--terminated-runner-pod-grace-period-seconds=-1")
})
}
func TestTemplate_ControllerContainerEnvironmentVariables(t *testing.T) {
t.Parallel()