diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml index 6877fba7..e7212c64 100644 --- a/deploy/helm/templates/deployment.yaml +++ b/deploy/helm/templates/deployment.yaml @@ -43,6 +43,8 @@ spec: value: "{{ .Values.rcm.shimDownloaderImage.repository }}:{{ .Values.rcm.shimDownloaderImage.tag | default .Chart.AppVersion }}" - name: SHIM_NODE_INSTALLER_IMAGE value: "{{ .Values.rcm.nodeInstallerImage.repository }}:{{ .Values.rcm.nodeInstallerImage.tag | default .Chart.AppVersion }}" + - name: SHIM_NODE_INSTALLER_JOB_TTL + value: "{{ .Values.rcm.nodeInstallerJob.ttl | default 0 }}" ports: - name: http containerPort: {{ .Values.service.port }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 62b381b7..960a24de 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -17,6 +17,8 @@ rcm: nodeInstallerImage: repository: "ghcr.io/spinkube/node-installer" tag: "latest" + nodeInstallerJob: + ttl: 0 imagePullSecrets: [] nameOverride: "" diff --git a/internal/controller/shim_controller.go b/internal/controller/shim_controller.go index 9c2183db..e6f9baa8 100644 --- a/internal/controller/shim_controller.go +++ b/internal/controller/shim_controller.go @@ -22,6 +22,7 @@ import ( "fmt" "math" "os" + "strconv" "github.com/rs/zerolog/log" "k8s.io/apimachinery/pkg/runtime" @@ -228,7 +229,7 @@ func (sr *ShimReconciler) handleInstallShim(ctx context.Context, shim *rcmv1.Shi case rcmv1.RolloutStrategyTypeRolling: { log.Debug().Msgf("Rolling strategy selected: maxUpdate=%d", shim.Spec.RolloutStrategy.Rolling.MaxUpdate) - return ctrl.Result{}, errors.New("Rolling strategy not implemented yet") + return ctrl.Result{}, errors.New("rolling strategy not implemented yet") } case rcmv1.RolloutStrategyTypeRecreate: { @@ -460,7 +461,12 @@ func (sr *ShimReconciler) createJobManifest(shim *rcmv1.Shim, node *corev1.Node, }, }, } - + // set ttl for the installer job only if specified by the user + if ttlStr := os.Getenv("SHIM_NODE_INSTALLER_JOB_TTL"); ttlStr != "" { + if ttl, err := strconv.Atoi(ttlStr); err == nil && ttl > 0 { + job.Spec.TTLSecondsAfterFinished = ptr(int32(ttl)) + } + } if operation == INSTALL { if err := ctrl.SetControllerReference(shim, job, sr.Scheme); err != nil { return nil, fmt.Errorf("failed to set controller reference: %w", err)