Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to configure TTL for Installer Job #300

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -227,7 +228,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 @@ -459,7 +460,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.ParseInt(ttlStr, 10, 32); 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
Loading