feat: default to running one-off k3s containers to a max of 1 day
This follows the standard enforced by Heroku.
This commit is contained in:
2 files changed
+11
No files matched your search
@@ -367,6 +367,7 @@ type Job struct {
|
|||||||
Suffix string
|
Suffix string
|
||||||
RemoveContainer bool
|
RemoveContainer bool
|
||||||
WorkingDir string
|
WorkingDir string
|
||||||
|
ActiveDeadlineSeconds int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecurityContext contains the security context for a process
|
// SecurityContext contains the security context for a process
|
||||||
@@ -479,6 +480,7 @@ func templateKubernetesJob(input Job) (batchv1.Job, error) {
|
|||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
},
|
},
|
||||||
Spec: batchv1.JobSpec{
|
Spec: batchv1.JobSpec{
|
||||||
|
ActiveDeadlineSeconds: ptr.To(input.ActiveDeadlineSeconds),
|
||||||
BackoffLimit: ptr.To(int32(0)),
|
BackoffLimit: ptr.To(int32(0)),
|
||||||
Template: corev1.PodTemplateSpec{
|
Template: corev1.PodTemplateSpec{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
|||||||
@@ -1329,6 +1329,14 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
|
|||||||
return fmt.Errorf("Error getting security context: %w", err)
|
return fmt.Errorf("Error getting security context: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeDeadlineSeconds := int64(86400) // 24 hours
|
||||||
|
if os.Getenv("DOKKU_RUN_TTL_SECONDS") != "" {
|
||||||
|
activeDeadlineSeconds, err = strconv.ParseInt(os.Getenv("DOKKU_RUN_TTL_SECONDS"), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing DOKKU_RUN_TTL_SECONDS value as int64: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
workingDir := common.GetWorkingDir(appName, image)
|
workingDir := common.GetWorkingDir(appName, image)
|
||||||
job, err := templateKubernetesJob(Job{
|
job, err := templateKubernetesJob(Job{
|
||||||
AppName: appName,
|
AppName: appName,
|
||||||
@@ -1346,6 +1354,7 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
|
|||||||
RemoveContainer: rmContainer,
|
RemoveContainer: rmContainer,
|
||||||
SecurityContext: securityContext,
|
SecurityContext: securityContext,
|
||||||
WorkingDir: workingDir,
|
WorkingDir: workingDir,
|
||||||
|
ActiveDeadlineSeconds: activeDeadlineSeconds,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error templating job: %w", err)
|
return fmt.Errorf("Error templating job: %w", err)
|
||||||
|
|||||||
Reference in new issue
Block a user