Skip to content

Commit caa2ec9

Browse files
committed
chore: Allow users to configure TTL for Installer Job
Signed-off-by: Thorsten Hans <[email protected]>
1 parent 534bf3c commit caa2ec9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

deploy/helm/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ spec:
4343
value: "{{ .Values.rcm.shimDownloaderImage.repository }}:{{ .Values.rcm.shimDownloaderImage.tag | default .Chart.AppVersion }}"
4444
- name: SHIM_NODE_INSTALLER_IMAGE
4545
value: "{{ .Values.rcm.nodeInstallerImage.repository }}:{{ .Values.rcm.nodeInstallerImage.tag | default .Chart.AppVersion }}"
46+
- name: SHIM_NODE_INSTALLER_JOB_TTL
47+
value: "{{ .Values.rcm.nodeInstallerJob.ttl | default 0 }}"
4648
ports:
4749
- name: http
4850
containerPort: {{ .Values.service.port }}

deploy/helm/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ rcm:
1717
nodeInstallerImage:
1818
repository: "ghcr.io/spinkube/node-installer"
1919
tag: "latest"
20+
nodeInstallerJob:
21+
ttl: 0
2022

2123
imagePullSecrets: []
2224
nameOverride: ""

internal/controller/shim_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"math"
2424
"os"
25+
"strconv"
2526

2627
"github.com/rs/zerolog/log"
2728
"k8s.io/apimachinery/pkg/runtime"
@@ -227,7 +228,7 @@ func (sr *ShimReconciler) handleInstallShim(ctx context.Context, shim *rcmv1.Shi
227228
case rcmv1.RolloutStrategyTypeRolling:
228229
{
229230
log.Debug().Msgf("Rolling strategy selected: maxUpdate=%d", shim.Spec.RolloutStrategy.Rolling.MaxUpdate)
230-
return ctrl.Result{}, errors.New("Rolling strategy not implemented yet")
231+
return ctrl.Result{}, errors.New("rolling strategy not implemented yet")
231232
}
232233
case rcmv1.RolloutStrategyTypeRecreate:
233234
{
@@ -459,7 +460,12 @@ func (sr *ShimReconciler) createJobManifest(shim *rcmv1.Shim, node *corev1.Node,
459460
},
460461
},
461462
}
462-
463+
// set ttl for the installer job only if specified by the user
464+
if ttlStr := os.Getenv("SHIM_NODE_INSTALLER_JOB_TTL"); ttlStr != "" {
465+
if ttl, err := strconv.Atoi(ttlStr); err == nil && ttl > 0 {
466+
job.Spec.TTLSecondsAfterFinished = ptr(int32(ttl))
467+
}
468+
}
463469
if operation == INSTALL {
464470
if err := ctrl.SetControllerReference(shim, job, sr.Scheme); err != nil {
465471
return nil, fmt.Errorf("failed to set controller reference: %w", err)

0 commit comments

Comments
 (0)