Skip to content

Commit

Permalink
chore: Allow users to configure TTL for Installer Job
Browse files Browse the repository at this point in the history
Signed-off-by: Thorsten Hans <[email protected]>
  • Loading branch information
ThorstenHans authored and 0xE282B0 committed Jan 20, 2025
1 parent f57e58d commit f8d3f97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions deploy/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 2 additions & 0 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ rcm:
nodeInstallerImage:
repository: "ghcr.io/spinkube/node-installer"
tag: "latest"
nodeInstallerJob:
ttl: 0

imagePullSecrets: []
nameOverride: ""
Expand Down
10 changes: 8 additions & 2 deletions internal/controller/shim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math"
"os"
"strconv"

"github.com/rs/zerolog/log"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -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:
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f8d3f97

Please sign in to comment.