Skip to content

Commit

Permalink
Apply all pod level runtime settings to CronJob (#1396)
Browse files Browse the repository at this point in the history
Signed-off-by: Leon Kiefer <leon.k97@gmx.de>
  • Loading branch information
Legion2 committed Oct 25, 2021
1 parent 535efca commit a5b7398
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/controller/backup_configuration.go
Expand Up @@ -45,6 +45,7 @@ import (
core_util "kmodules.xyz/client-go/core/v1"
meta2 "kmodules.xyz/client-go/meta"
"kmodules.xyz/client-go/tools/queue"
ofst_util "kmodules.xyz/offshoot-api/util"
workload_api "kmodules.xyz/webhook-runtime/apis/workload/v1"
)

Expand Down Expand Up @@ -427,14 +428,9 @@ func (c *StashController) EnsureBackupTriggeringCronJob(inv invoker.BackupInvoke
in.Spec.JobTemplate.Spec.Template.Spec.ServiceAccountName = serviceAccountName
in.Spec.JobTemplate.Spec.Template.Spec.ImagePullSecrets = imagePullSecrets

// only apply the pod level runtime settings that make sense for the CronJob
// apply all the pod level runtime settings even though they may make no sense in every context
if inv.RuntimeSettings.Pod != nil {
if len(inv.RuntimeSettings.Pod.ImagePullSecrets) != 0 {
in.Spec.JobTemplate.Spec.Template.Spec.ImagePullSecrets = inv.RuntimeSettings.Pod.ImagePullSecrets
}
if inv.RuntimeSettings.Pod.SecurityContext != nil {
in.Spec.JobTemplate.Spec.Template.Spec.SecurityContext = inv.RuntimeSettings.Pod.SecurityContext
}
ofst_util.ApplyPodRuntimeSettings(in.Spec.JobTemplate.Spec.Template.Spec, *inv.RuntimeSettings.Pod)
}

return in
Expand Down

0 comments on commit a5b7398

Please sign in to comment.