Skip to content

Enabling variables to control job batch limits #103

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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 main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ module "metaflow-computation" {
launch_template_http_endpoint = var.launch_template_http_endpoint
launch_template_http_tokens = var.launch_template_http_tokens
launch_template_http_put_response_hop_limit = var.launch_template_http_put_response_hop_limit
job_state_time_limit_timeout = var.job_state_time_limit_timeout
job_state_time_limit_reason = var.job_state_time_limit_reason

standard_tags = var.tags
}
Expand Down
6 changes: 6 additions & 0 deletions modules/computation/batch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,11 @@ resource "aws_batch_job_queue" "this" {
aws_batch_compute_environment.this.arn
]

job_state_time_limit_action {
action= "CANCEL"
max_time_seconds = var.job_state_time_limit_timeout
reason=var.job_state_time_limit_reason
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute set is only valid if both reason and time limit are defined. The Batch API will throw an error if not all attributes are defined, so a check is not strictly necessary but it would be nice to know before starting a deploy that this will fail if both are not defined.

state="RUNNABLE"
}
tags = var.standard_tags
}
10 changes: 10 additions & 0 deletions modules/computation/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@ variable "launch_template_image_id" {
nullable = true
default = null
}

variable "job_state_time_limit_timeout" {
type = number
description = "The time limit in seconds for the job to run before the action is taken"
}

variable "job_state_time_limit_reason" {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point to Batch docs for valid reasons

type = string
description = "The reason for the job state time limit action"
}
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,17 @@ variable "enable_key_rotation" {
description = "Enable key rotation for KMS keys"
default = false
}

variable "job_state_time_limit_timeout" {
type = number
description = "The time limit in seconds for the job to run before the action is taken"
validation {
condition = var.job_state_time_limit_timeout >= 600
error_message = "The value for 'job_state_time_limit_timeout' must be greater than 600."
}
}

variable "job_state_time_limit_reason" {
type = string
description = "The reason to log for the action being taken."
}