JDK
JDK

Reputation: 31

AWS ECS runc create failed: args must not be empty: unknown

I am currently trying to mount a Fargate ECS with an image on ECR using terraform except recently I have this error

CannotStartContainerError: ResourceInitializationError: failed to create new container runtime task: failed to create shim task: OCI runtime create failed: runc create failed: args must not be empty: unknown

Note that the code I'm using worked for several months, this error appeared to me overnight. Please find more info on the cluster in screenshot Tasks Tasks Details Tasks Logs Tasks definitions

I tried to increase the memory and the cpu of the cluster but it does not seem to do anything. Please find the terraform code provisioning the infra
Any help would be welcome Thank you !

### main.tf
module "ecs" {
  source                                    = "./modules/ecs"
  cluster_count                             = 1
  cluster_name                              = var.cluster_name
  capacity_provider                         = var.capacity_provider
  container_name                            = var.container_name
  container_image                           = module.gitlab-ecr.image_url    
  family                                    = var.family
  network_mode                              = var.network_mode
  execution_role_arn                        = module.iam.iam_role
  task_role_arn                             = module.iam.iam_role
  cpu                                       = 256 #1024
  memory                                    = 512 #2048
  container_port                            = 80
  host_port                                 = 80
  subnets_ecs                               = var.subnets_ecs
  lb_target_group_arn                       = module.loadbalancer.lb_target_group_arn
  assign_public_ip                          = false
  default_capacity_provider_strategy_base   = 1
  default_capacity_provider_strategy_weight = 100
  container_definitions_essential           = true
  #ecs_fargate_sg                            = module.sg.fargate_sg
}

module "loadbalancer" {
  source                     = "./modules/loadbalancer"
  vpc_id                     = var.vpc_id
  certificate_arn            = var.certificate_arn
  subnets_alb                = var.subnets_alb
  lb_sg                      = module.sg.fargate_sg
  default_sg                 = module.sg.fargate_sg_default
}

module "sg" {
  source = "./modules/sg"
  vpc_id =  var.vpc_id
}

module "iam" {
  source                 = "./modules/iam"
  name                   = var.policy_name
  policy_name            = var.policy_name
  path                   = "/"
  iam_policy_description = var.iam_policy_description
  iam_policy             = file("./policy.json")
  assume_role_policy     = file("./trusted-entity.json")
}


# Get Docker  image stored in gitlab registry and push it to ECR
module "gitlab-ecr" {
  source       = "git::https://gitlab.softfactory-accor.net/data-analytics/infrastructure/terraform-modules/module-docker-to-ecr.git?ref=master"
  image        = "ecom/front/applications/components/dfprefix"
  name         = "dfprefix"
  tag          = "release-0.1"
  registry_url = "registry.softfactory-accor.net"
}

resource "aws_cloudwatch_log_group" "burn" {
  name              = "/ecs/prefix"
  retention_in_days = 7
  tags              = {
    Name = "ECS Prefixe Logs"
  }
}
### MODULE ECS - main.tf
resource "aws_ecs_cluster" "cluster_ecs" {
  name = var.cluster_name
  setting {
    name  = "containerInsights"
    value = "enabled"
  }
}

  
resource "aws_ecs_cluster_capacity_providers" "cluster_capacity_reservation" {
  cluster_name = aws_ecs_cluster.cluster_ecs.name

  capacity_providers = [var.capacity_provider]

  default_capacity_provider_strategy {
    base              = var.default_capacity_provider_strategy_base
    weight            = var.default_capacity_provider_strategy_weight
    capacity_provider = var.capacity_provider
  }
}

resource "aws_ecs_task_definition" "cluster_task_definition" {
  family                   = var.family
  requires_compatibilities = [var.capacity_provider]
  network_mode             = var.network_mode
  cpu                      = var.cpu
  memory                   = var.memory
  execution_role_arn       = var.execution_role_arn
  task_role_arn            = var.task_role_arn

  container_definitions = jsonencode([
    {
      name      = var.container_name
      image     = var.container_image
      cpu       = var.cpu
      memory    = var.memory
      essential = var.container_definitions_essential
      portMappings = [
        {
          containerPort = var.container_port
          hostPort      = var.host_port
        }
      ],
      logConfiguration = {
        logDriver = "awslogs",
        options   = {
          awslogs-create-group  = "true",
          awslogs-group         = "/ecs/prefix",
          awslogs-region        = "eu-west-1",
          awslogs-stream-prefix = "ecs"
        }
      }
    }
  ])
}

resource "aws_ecs_service" "cluster_service" {
  name            = var.cluster_name
  cluster         = aws_ecs_cluster.cluster_ecs.id
  task_definition = aws_ecs_task_definition.cluster_task_definition.arn
  desired_count   = var.cluster_count
  load_balancer {
    target_group_arn = var.lb_target_group_arn
    container_name   = var.container_name
    container_port   = var.container_port
  }

  capacity_provider_strategy {
    capacity_provider = var.capacity_provider
    weight            = 1

  }

  network_configuration {
    subnets          = var.subnets_ecs
    assign_public_ip = var.assign_public_ip

    #security_groups = [ var.ecs_fargate_sg ]
  }
}

Upvotes: 2

Views: 1073

Answers (1)

CodeSelf
CodeSelf

Reputation: 1

Same my issue.

Solve with Disabled Buildkit work for me.

export DOCKER_BUILDKIT=0

Upvotes: 0

Related Questions