pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

Panic in batch job definition in 6.33.1

Open t0yv0 opened this issue 1 year ago • 2 comments

What happened?

Customer report:

panic: interface conversion: interface {} is nil, not map[string]interface {}
    goroutine 2639 [running]:
    github.com/hashicorp/terraform-provider-aws/internal/service/batch.needsJobDefUpdate(0x1400266c3c0)
    	/home/runner/work/pulumi-aws/pulumi-aws/upstream/internal/service/batch/job_definition.go:537 +0x1004
    github.com/hashicorp/terraform-provider-aws/internal/service/batch.jobDefinitionCustomizeDiff({0x11282d880?, 0x11e7ab5c0?}, 0x1400266c3c0, {0xe?, 0x140020009c0?})
    	/home/runner/work/pulumi-aws/pulumi-aws/upstream/internal/service/batch/job_definition.go:452 +0x44
    github.com/hashicorp/terraform-provider-aws/internal/service/batch.ResourceJobDefinition.Sequence.func23({0x113b73488, 0x14002680030}, 0x1400266c3c0, {0x1139133c0, 0x140020009c0})
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/[email protected]/helper/customdiff/compose.go:69 +0x80
    github.com/hashicorp/terraform-provider-aws/internal/provider.New.(*wrappedResource).CustomizeDiff.func5({0x113b73488?, 0x140040117d0?}, 0x1400266c3c0, {0x1139133c0, 0x140020009c0})
    	/home/runner/work/pulumi-aws/pulumi-aws/upstream/internal/provider/intercept.go:186 +0x68
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0x1400201def0, {0x113b73488, 0x140040117d0}, 0x14003546dd0, 0x1400277fae0, 0x14001187d70, {0x1139133c0, 0x140020009c0}, 0x0)
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:698 +0x3b8
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x113b738b0?, {0x113b73488?, 0x140040117d0?}, 0x14003546dd0, 0x14004011800?, {0x1139133c0?, 0x140020009c0?})
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:967 +0x9c
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChangeExtra(0x14001f9d080, {0x113b73488?, 0x140053b0a80?}, 0x140027e8fb0)
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:831 +0x824
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.(*grpcServer).PlanResourceChange(0x14000930d90, {0x113b73488, 0x140053b0a80}, {0x10e66db3b, 0x18}, {{0x113b738b0?, 0x140045f4de8?}}, {{{0x113b738b0?, 0x140045f4ef8?}}, {0x111a2a020?, ...}}, ...)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/[email protected]/pkg/tfshim/sdk-v2/provider2.go:437 +0x320
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.(*planResourceChangeImpl).Diff(0x14000eaf380, {0x113b73488, 0x140053b0a80}, {0x10e66db3b, 0x18}, {0x113b73920?, 0x14004afe480?}, {0x1139a3920?, 0x14005d60690?}, {0x0?, ...})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/[email protected]/pkg/tfshim/sdk-v2/provider2.go:159 +0x25c
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.(*providerWithPlanResourceChangeDispatch).Diff(0x140021146f0, {0x113b73488, 0x140053b0a80}, {0x10e66db3b, 0x18}, {0x113b73920, 0x14004afe480}, {0x1139a3920, 0x14005d60690}, {0x0?, ...})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/[email protected]/pkg/tfshim/sdk-v2/provider2.go:677 +0xb0
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Diff(0x14000f93988, {0x113b73488?, 0x140053b0660?}, 0x1400141c080)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/[email protected]/pkg/tfbridge/provider.go:912 +0x720
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff.func1({0x113bfe3e8?, 0x14000f93988?})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/[email protected]/muxer.go:369 +0x3c
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.resourceMethod[...](0x14004d56fc0?, 0x113316fa0, 0x1400270d698?)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/[email protected]/muxer.go:334 +0xc4
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff(0x11e202250?, {0x113b73488?, 0x140053b0660?}, 0x110fef8e0?)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/[email protected]/muxer.go:368 +0x58
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Diff_Handler.func1({0x113b73488?, 0x140053b0660?}, {0x11327ace0?, 0x1400141c080?})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider_grpc.pb.go:575 +0xd0
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x113b73488, 0x140053b0210}, {0x11327ace0, 0x1400141c080}, 0x140044ca0c0, 0x14004c0e0d8)
    	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/go/otgrpc/server.go:57 +0x2e4
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Diff_Handler({0x11375f520, 0x14004d56fc0}, {0x113b73488, 0x140053b0210}, 0x1400141c000, 0x14002630140)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider_grpc.pb.go:577 +0x148
    google.golang.org/grpc.(*Server).processUnaryRPC(0x140046e6000, {0x113b73488, 0x140053b0180}, {0x113bbf2e0, 0x140001f1200}, 0x1400274c000, 0x1400239ccf0, 0x11e7165a8, 0x0)
    	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1369 +0xb58
    google.golang.org/grpc.(*Server).handleStream(0x140046e6000, {0x113bbf2e0, 0x140001f1200}, 0x1400274c000)
    	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1780 +0xb20
    google.golang.org/grpc.(*Server).serveStreams.func2.1()
    	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1019 +0x8c
    created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 59
    	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1030 +0x13c

Issue occurs when upgrading to latest.

Example

N/A

Output of pulumi about

N/A

Additional context

N/A

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

t0yv0 avatar May 07 '24 20:05 t0yv0

I can trigger this panic on the following program. Do pulumi up twice, second pulumi up panics:

import pulumi
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition("test",
    name="my_test_batch_job_definition",
    type="container",
    retry_strategy={}, # None seems OK, but {} fails
    container_properties=json.dumps({
        "command": [
            "ls",
            "-la",
        ],
        "image": "busybox",
        "resourceRequirements": [
            {
                "type": "VCPU",
                "value": "4",
            },
            {
                "type": "MEMORY",
                "value": "512",
            },
        ],
        "volumes": [{
            "host": {
                "sourcePath": "/tmp",
            },
            "name": "tmp",
        }],
        "environment": [{
            "name": "VARNAME",
            "value": "VARVAL",
        }],
        "mountPoints": [{
            "sourceVolume": "tmp",
            "containerPath": "/tmp",
            "readOnly": False,
        }],
        "ulimits": [{
            "hardLimit": 1024,
            "name": "nofile",
            "softLimit": 1024,
        }],
    }))

t0yv0 avatar May 07 '24 21:05 t0yv0

CLI          
Version      3.111.1
Go Version   go1.22.1
Go Compiler  gc

Plugins
NAME    VERSION
aws     6.33.1
python  unknown

Host     
OS       darwin
Version  14.4.1
Arch     arm64

This project is written in python: executable='/Users/anton/bin/python3' version='3.10.13'

Current Stack: anton-pulumi-corp/py/dev3905

TYPE                                   URN
pulumi:pulumi:Stack                    urn:pulumi:dev3905::py::pulumi:pulumi:Stack::py-dev3905
pulumi:providers:aws                   urn:pulumi:dev3905::py::pulumi:providers:aws::default_6_33_1
aws:batch/jobDefinition:JobDefinition  urn:pulumi:dev3905::py::aws:batch/jobDefinition:JobDefinition::test


Found no pending operations associated with dev3905

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/anton-pulumi-corp
User           anton-pulumi-corp
Organizations  anton-pulumi-corp, moolumi, pulumi
Token type     personal

Dependencies:
NAME        VERSION
pip         24.0
pulumi_aws  6.33.1
setuptools  69.5.1
wheel       0.43.0

Pulumi locates its logs in /var/folders/gd/3ncjb1lj5ljgk8xl5ssn_gvc0000gn/T/com.apple.shortcuts.mac-helper// by default

t0yv0 avatar May 07 '24 21:05 t0yv0

I can reproduce this with terraform. Same behavior as with pulumi, consecutive applies/plans fail after the first apply:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.48.0"
    }
  }

  required_version = ">= 1.2.0"
}

provider "aws" {
  region  = "us-west-2"
}

resource "aws_batch_job_definition" "example" {
  name = "florian-test-job-definition"
  type = "container"

  retry_strategy {
    
  }
  container_properties = <<EOT
{
  "command": [
    "ls",
    "-la"
  ],
  "image": "busybox",
  "resourceRequirements": [
    {
      "type": "VCPU",
      "value": "4"
    },
    {
      "type": "MEMORY",
      "value": "512"
    }
  ],
  "volumes": [
    {
      "host": {
        "sourcePath": "/tmp"
      },
      "name": "tmp"
    }
  ],
  "environment": [
    {
      "name": "VARNAME",
      "value": "VARVAL"
    }
  ],
  "mountPoints": [
    {
      "sourceVolume": "tmp",
      "containerPath": "/tmp",
      "readOnly": false
    }
  ],
  "ulimits": [
    {
      "hardLimit": 1024,
      "name": "nofile",
      "softLimit": 1024
    }
  ]
}
EOT
}

flostadler avatar May 08 '24 15:05 flostadler

Output:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Plugin did not respond
│
│   with aws_batch_job_definition.example,
│   on main.tf line 16, in resource "aws_batch_job_definition" "example":
│   16: resource "aws_batch_job_definition" "example" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).PlanResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-aws_v5.48.0_x5 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 45 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/batch.needsJobDefUpdate(0x14005992f80)
	github.com/hashicorp/terraform-provider-aws/internal/service/batch/job_definition.go:537 +0x1004
github.com/hashicorp/terraform-provider-aws/internal/service/batch.jobDefinitionCustomizeDiff({0x116abab20?, 0x120930e20?}, 0x14005992f80, {0xe?, 0x14002bc2680?})
	github.com/hashicorp/terraform-provider-aws/internal/service/batch/job_definition.go:452 +0x44
github.com/hashicorp/terraform-provider-aws/internal/service/batch.ResourceJobDefinition.Sequence.func23({0x117d08648, 0x14002d95bc0}, 0x14005992f80, {0x117ab7e00, 0x14002bc2680})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/customdiff/compose.go:69 +0x80
github.com/hashicorp/terraform-provider-aws/internal/provider.New.(*wrappedResource).CustomizeDiff.func5({0x117d08648?, 0x14002955920?}, 0x14005992f80, {0x117ab7e00, 0x14002bc2680})
	github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:186 +0x68
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0x1400109da10, {0x117d08648, 0x14002955920}, 0x14002d84820, 0x14000631d60, 0x14000759608, {0x117ab7e00, 0x14002bc2680}, 0x0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:698 +0x3b8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x117d08a78?, {0x117d08648?, 0x14002955920?}, 0x14002d84820, 0x14002955950?, {0x117ab7e00?, 0x14002bc2680?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:962 +0x9c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0x140019b6798, {0x117d08648?, 0x14002955830?}, 0x14000a39590)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:798 +0x824
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).PlanResourceChange(0x140005b70a0, {0x117d08648?, 0x14002955560?}, 0x14000a39590)
	github.com/hashicorp/[email protected]/tf5muxserver/mux_server_PlanResourceChange.go:73 +0x250
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0x1400029d7c0, {0x117d08648?, 0x14002954ba0?}, 0x140001d91f0)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:811 +0x2b4
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0x117874b60, 0x1400029d7c0}, {0x117d08648, 0x14002954ba0}, 0x14000618c80, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:500 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000fe6a00, {0x117d08648, 0x14002954b10}, {0x117d4fd98, 0x1400056a000}, 0x14002953c20, 0x14002c574d0, 0x1208a0d40, 0x0)
	google.golang.org/[email protected]/server.go:1369 +0xb58
google.golang.org/grpc.(*Server).handleStream(0x14000fe6a00, {0x117d4fd98, 0x1400056a000}, 0x14002953c20)
	google.golang.org/[email protected]/server.go:1780 +0xb20
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/[email protected]/server.go:1019 +0x8c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 26
	google.golang.org/[email protected]/server.go:1030 +0x13c

Error: The terraform-provider-aws_v5.48.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

flostadler avatar May 08 '24 15:05 flostadler

Opened issue in upstream: https://github.com/hashicorp/terraform-provider-aws/issues/37349

flostadler avatar May 08 '24 15:05 flostadler

We should probably either remove the P1 label or plan to fix the upstream issue ourselves

mikhailshilkov avatar May 09 '24 13:05 mikhailshilkov

We decided to keep it as a P1. Given that there's no traction on the upstream issue, I'm starting to work on a fix

flostadler avatar May 10 '24 07:05 flostadler