kreuzwerker/terraform-provider-docker

docker_registry_image resource not created after successful push

Tonkari opened this issue ยท 1 comments

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

Terraform v1.9.5
on linux_amd64
+ provider registry.terraform.io/kreuzwerker/docker v3.0.2

I also tried on other versions (starting terraform 1.5.7 and provider 2.25.0)

Affected Resource(s)

  • docker_registry_image

Terraform Configuration Files

provider "docker" {
  registry_auth {
    address  = "https://${var.registry_dns}/test_project_1724672309"
    username = xxx
    password = xxx
  }
}

resource "docker_image" "public_image" {
  name         = "nginx:latest"
}

resource "docker_tag" "retag_image" {
  source_image = docker_image.public_image.name
  target_image = "${var.registry_dns}/test_project_1724672309/nginx:latest"
}

resource "docker_registry_image" "push_image" {
  name          = docker_tag.retag_image.target_image
}

Debug Output

docker_registry_image.push_image: Creating...
2024-08-26T14:30:41.976+0200 [INFO]  Starting apply for docker_registry_image.push_image
2024-08-26T14:30:41.976+0200 [DEBUG] docker_registry_image.push_image: applying the planned Create change
2024-08-26T14:30:41.977+0200 [INFO]  provider.terraform-provider-docker_v3.0.2: 2024/08/26 14:30:41 [DEBUG] Creating docker image redacted.for.privacy/test_project_1724672309/nginx:latest: timestamp="2024-08-26T14:30:41.977+0200"
2024-08-26T14:30:42.630+0200 [INFO]  provider.terraform-provider-docker_v3.0.2: 2024/08/26 14:30:42 [DEBUG] Pushed image: redacted.for.privacy/test_project_1724672309/nginx:latest: timestamp="2024-08-26T14:30:42.629+0200"
2024-08-26T14:30:42.704+0200 [ERROR] provider.terraform-provider-docker_v3.0.2: Response contains error diagnostic: @module=sdk.proto diagnostic_detail="" diagnostic_severity=ERROR tf_provider_addr=provider tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_summary="Unable to create image, image not found: unable to get digest: Error reading registry response body: %!s(<nil>)" tf_proto_version=5.3 tf_req_id=009570d2-e7b6-5eeb-7f6b-989597b074ce tf_resource_type=docker_registry_image timestamp="2024-08-26T14:30:42.704+0200"

Expected Behaviour

Resource should be created when push succeeds

Actual Behaviour

Resource is not created and Error above is thrown.
In my registry I can see, that the image is present and I can pull it, so it seems no error has occurred.

Steps to Reproduce

  1. terraform apply

Important Factoids

Target is a harbor based registry - push via docker cli works without errors.

I suspect the response is interpreted incorrectly since the error reads <nil>
Other resources work fine with the same registry. I can pull a docker_image from it without issue.

Yes same issue here on ECR:

Debug logs:

2024-10-24T16:22:23.356+1100 [WARN]  Provider "registry.terraform.io/kreuzwerker/docker" produced an invalid plan for module.lambda.docker_registry_image.invoices_registry_image, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .insecure_skip_verify: planned value cty.False for a non-computed attribute
      - .keep_remotely: planned value cty.False for a non-computed attribute
module.lambda.docker_registry_image.invoices_registry_image: Creating...
2024-10-24T16:22:23.356+1100 [INFO]  Starting apply for module.lambda.docker_registry_image.invoices_registry_image
2024-10-24T16:22:23.356+1100 [WARN]  Provider "registry.terraform.io/kreuzwerker/docker" produced an invalid plan for module.lambda.docker_registry_image.readings_registry_image, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .insecure_skip_verify: planned value cty.False for a non-computed attribute
      - .keep_remotely: planned value cty.False for a non-computed attribute
module.lambda.docker_registry_image.readings_registry_image: Creating...
2024-10-24T16:22:23.356+1100 [INFO]  Starting apply for module.lambda.docker_registry_image.readings_registry_image
2024-10-24T16:22:23.356+1100 [DEBUG] module.lambda.docker_registry_image.invoices_registry_image: applying the planned Create change
2024-10-24T16:22:23.357+1100 [DEBUG] module.lambda.docker_registry_image.readings_registry_image: applying the planned Create change
2024-10-24T16:22:23.358+1100 [INFO]  provider.terraform-provider-docker_v3.0.2: 2024/10/24 16:22:23 [DEBUG] Creating docker image 300428143068.dkr.ecr.ap-southeast-2.amazonaws.com/esg-nzc-lambda-docker-repo/invoices:latest: timestamp="2024-10-24T16:22:23.358+1100"
2024-10-24T16:22:23.358+1100 [INFO]  provider.terraform-provider-docker_v3.0.2: 2024/10/24 16:22:23 [DEBUG] Creating docker image 300428143068.dkr.ecr.ap-southeast-2.amazonaws.com/esg-nzc-lambda-docker-repo/readings:latest: timestamp="2024-10-24T16:22:23.358+1100"
2024-10-24T16:22:24.059+1100 [INFO]  provider.terraform-provider-docker_v3.0.2: 2024/10/24 16:22:24 [DEBUG] Pushed image: 300428143068.dkr.ecr.ap-southeast-2.amazonaws.com/esg-nzc-lambda-docker-repo/readings:latest: timestamp="2024-10-24T16:22:24.059+1100"
2024-10-24T16:22:24.220+1100 [ERROR] provider.terraform-provider-docker_v3.0.2: Response contains error diagnostic: @module=sdk.proto diagnostic_detail="" diagnostic_summary="Unable to create image, image not found: unable to get digest: Got bad response from registry: 404 Not Found" tf_req_id=a9c1da4a-bd67-cc23-414f-902cc48b7fba tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_severity=ERROR tf_proto_version=5.3 tf_provider_addr=provider tf_resource_type=docker_registry_image timestamp="2024-10-24T16:22:24.219+1100"
2024-10-24T16:22:24.230+1100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-10-24T16:22:24.230+1100 [ERROR] vertex "module.lambda.docker_registry_image.readings_registry_image" error: Unable to create image, image not found: unable to get digest: Got bad response from registry: 404 Not Found
2024-10-24T16:22:24.313+1100 [INFO]  provider.terraform-provider-docker_v3.0.2: 2024/10/24 16:22:24 [DEBUG] Pushed image: 300428143068.dkr.ecr.ap-southeast-2.amazonaws.com/esg-nzc-lambda-docker-repo/invoices:latest: timestamp="2024-10-24T16:22:24.313+1100"
2024-10-24T16:22:24.461+1100 [ERROR] provider.terraform-provider-docker_v3.0.2: Response contains error diagnostic: @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_summary="Unable to create image, image not found: unable to get digest: Got bad response from registry: 404 Not Found" tf_proto_version=5.3 tf_provider_addr=provider tf_resource_type=docker_registry_image @module=sdk.proto diagnostic_detail="" diagnostic_severity=ERROR tf_req_id=d19b8435-d636-7c6e-3b67-9f7bb0242162 tf_rpc=ApplyResourceChange timestamp="2024-10-24T16:22:24.461+1100"
2024-10-24T16:22:24.468+1100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-10-24T16:22:24.469+1100 [ERROR] vertex "module.lambda.docker_registry_image.invoices_registry_image" error: Unable to create image, image not found: unable to get digest: Got bad response from registry: 404 Not Found
โ•ท
โ”‚ Error: Unable to create image, image not found: unable to get digest: Got bad response from registry: 404 Not Found
โ”‚ 
โ”‚   with module.lambda.docker_registry_image.readings_registry_image,
โ”‚   on modules/lambda/lambda.tf line 65, in resource "docker_registry_image" "readings_registry_image":
โ”‚   65: resource "docker_registry_image" "readings_registry_image" {
โ”‚ 
โ•ต
โ•ท
โ”‚ Error: Unable to create image, image not found: unable to get digest: Got bad response from registry: 404 Not Found
โ”‚ 
โ”‚   with module.lambda.docker_registry_image.invoices_registry_image,
โ”‚   on modules/lambda/lambda.tf line 70, in resource "docker_registry_image" "invoices_registry_image":
โ”‚   70: resource "docker_registry_image" "invoices_registry_image" {
โ”‚ 
โ•ต
2024-10-24T16:22:24.476+1100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"

image

Images were pushed successfully