Skip to content
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

(aws-ecr-assets): TarballImageAsset Fails in Stage #24827

Open
gilday opened this issue Mar 28, 2023 · 5 comments
Open

(aws-ecr-assets): TarballImageAsset Fails in Stage #24827

gilday opened this issue Mar 28, 2023 · 5 comments
Labels
@aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@gilday
Copy link

gilday commented Mar 28, 2023

Describe the bug

The TarballImageAsset construct fails when it is nested inside of a Stack that is also inside of a Stage. Moving that Stack outside of the Stage works around the issue.

Expected Behavior

The TarballImageAsset should push the image to ECR.

Current Behavior

The failure occurs when TarballImageAsset attempts to shell out to docker load.

[78%] fail: docker tag .dkr.ecr..amazonaws.com/cdk--container-assets--: exited with error code 1: Error parsing reference: "" is not a valid repository/tag: invalid reference format

Reproduction Steps

  class MyStack extends Stack {
    public MyStack(final Construct scope, final String id) {
      super(scope, id);
      new TarballImageAsset(
          this, "image", TarballImageAssetProps.builder().tarballFile("./my-image.tar").build());
    }
  }

  class MyStage extends Stage {
    public MyStage(final Construct scope, final String id) {
      super(scope, id);
      new MyStack(this, "stack");
    }
  }

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.70.0 (build c13a0f1)

Framework Version

2.70.0

Node.js Version

v19.8.1

OS

macOS 13.2.1

Language

Java

Language Version

17.0.6

Other information

Consider sending requests to the Docker daemon without shelling out to the Docker CLI to get more descriptive errors and avoid issues like #19627.

@gilday gilday added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 28, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets label Mar 28, 2023
@pahud pahud self-assigned this Mar 28, 2023
@pahud pahud added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Mar 28, 2023
@pahud
Copy link
Contributor

pahud commented Mar 28, 2023

Unfortunately I can't get this reproduced.

I am using CDK in TypeScript as the following code:

class MyStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);
    new ecrassets.TarballImageAsset(this, "image",  {
      tarballFile: path.join(__dirname, '../demo.tar')
    });
  }
}

class MyStage extends cdk.Stage {
  constructor(scope: Construct, id: string) {
    super(scope, id)
    new MyStack(this, "mystack-test")
  }
}


new MyStage(app, 'mystage-dev')

I generate demo.tar by

$ docker pull busybox
$ docker save busybox -o demo.tar

I am not sure if it only happens in Java or is it tarball-specific. Can you generate a new tarball just as what I did above and see if the issue still exists?

@pahud pahud removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 28, 2023
gilday added a commit to gilday/cdk-issue-24827 that referenced this issue Mar 28, 2023
@gilday
Copy link
Author

gilday commented Mar 28, 2023

The busybox image also fails in my application.

I tried building a reproducer (https://github.com/gilday/cdk-issue-24827), but I'm unable to reproduce whatever it is about my other project that makes this fail.

I'm on macOS, and in the Console, I see error messages from com.docker.backend that correspond to the cdk deploy failures.

(3364e464) 46760170-CLIAPI S<-C Go-http-client/1.1 bind: {"command":"tag","context":"moby","source":"cli","status":"failure"}

@lorenzo-shape
Copy link

I am experiencing the same (CDK v2.75.0).

I gave a look at the cdk repo (in particular packages/cdk-assets/lib/private/handlers/container-images.ts) and I think the error comes from where the .tar asset file is saved inside the cdk.out folder.

The file is saved at the root of the folder while the workDir for the docker command is set at cdk.out/assembly-[StageName]. So the docker load command fails returning an empty string for the docker tag command.

I tried to manually move the generated .tar asset file inside the cdk.out/assembly-[StageName] folder and the deployment worked.

@pahud pahud added bug This issue is a bug. p2 effort/medium Medium work item – several days of effort labels May 2, 2023
@viktorvoltaire
Copy link

Any updates on this?

@pahud
Copy link
Contributor

pahud commented Aug 7, 2024

@viktorvoltaire

Are you able to reproduce this error using my code snippet here?

@pahud pahud added p3 and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 labels Aug 7, 2024
@pahud pahud removed their assignment Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

4 participants