AWS Batch: Activating Previous Revisions marked as inactive

Requirement: Given the requirement for compute resources capable of handling tasks lasting over 15 minutes, we determined that AWS Batch was the optimal solution.

Problem: We support versioning of our application. However, AWS Batch doesn’t support versioning like AWS Lambdas. Though, it creates a new JobDefinition with a new incremental revision after each deployment.

Example:

Here, the revision = 58.

However, it marks the previous revision of the JobDefinition as inactive and eligible for deletion automatically.

Like:

When we try to submit Job on any of these previous revision using aws sdk.

Like:

SubmitJobRequest submitJobRequest =
    SubmitJobRequest.builder()
        .jobName("sample")
        .jobQueue("sample")
        .jobDefinition("sample:"+ revision)
        .containerOverrides(
            ContainerOverrides.builder()
                .command(
                    "java",
                    "-cp",
                    "app.jar",
                    "-Dspring.main.web-application-type=none",
                    "-Dloader.main=com.BatchJob",
                    "org.springframework.boot.loader.PropertiesLauncher")
                .build())
        .build();

SubmitJobResponse submitJobResponse = batchClient.submitJob(submitJobRequest);

Exception:

JobDefinition arn:aws:batch:eu-west-1:123456789123:job-definition/sample:57 is not in ACTIVE status. (Service: Batch, Status Code: 400, Request ID: bd6199a1-3978-458c-a84e-19de4c1acb62)

Answers already read:

I’ve read below answer on the Stack Overflow but none of the answers answered my question:

  1. aws Batch Jobdefinition Cloudfromation error

  2. aws lambda cannot start step functions in eu-west-1

  3. AWS batch job submit error-Batch.ClientException

Any help would be very appreciated!


MORE DETAIL:

We are using terraform as Infrastructure as Code (IaC) and my aws_batch_job_definition look like:

resource "aws_batch_job_definition" "test" {
  name = "sample"
  type = "container"

  platform_capabilities = [
    "FARGATE",
  ]

  container_properties = jsonencode({
    command    = ["echo", "test"]
    image      = "${var.ecr_url_primary}:${local.version}-sample"
    jobRoleArn = aws_iam_role.job_task_role.arn

    fargatePlatformConfiguration = {
      platformVersion = "LATEST"
    }

    resourceRequirements = [
      {
        type  = "VCPU"
        value = "1"
      },
      {
        type  = "MEMORY"
        value = "3072"
      }
    ]
    executionRoleArn = aws_iam_role.execution_role.arn
    environment = [
      {
        name = "SPRING_PROFILES_ACTIVE"
        value = "${tostring(var.env)}"
      }
    ]
  })
  provider = "aws"
}

3

Research Summary: If you check the events in the CloudTrail you can easily find the DeregisterJobDefinition events getting triggered. That causes the previous revision of the job-definition to go into inactive state and eligible for deletion after 90 days. Furthermore, the CloudTrail event contains critical information like userAgent that tells you who has caused the event that can be leveraged to delve deeper into the problem.

{
    "eventVersion": "1.09",
.   ...
    "eventSource": "batch.amazonaws.com",
    "eventName": "DeregisterJobDefinition",
    "userAgent": "APN/1.0 HashiCorp/1.0 Terraform/0.13.7 (+https://www.terraform.io) terraform-provider-aws/5.82.1 (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go-v2/1.32.6 ua/2.1 os/linux lang/go#1.23.3 md/GOOS#linux md/GOARCH#amd64 api/batch#1.49.0",
}

How to fix the issue?

The fix is to explicitly add deregister_on_new_revision in the aws_batch_job_definition resource block of your terraform like below:

resource "aws_batch_job_definition" "test" {
  name = "tf_test_batch_job_definition"
  type = "container"

  .. 
  deregister_on_new_revision = false
}

Description:

deregister_on_new_revision – (Optional) When updating a job definition a new revision is created. This parameter determines if the previous version is deregistered (INACTIVE) or left ACTIVE. Defaults to true.

New contributor

Sarvat Mir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật