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

fix(assets): parallel docker image publishing fails on macOS #20117

Merged
merged 14 commits into from
May 18, 2022

Conversation

misterjoshua
Copy link
Contributor

@misterjoshua misterjoshua commented Apr 28, 2022

Changes container image publishing so that publishing doesn't re-run docker logins for the same repository and so logins are run one at a time.

Fixes #20116


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Apr 28, 2022

@github-actions github-actions bot added bug This issue is a bug. p2 labels Apr 28, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team April 28, 2022 02:39
@mitchlloyd
Copy link
Contributor

I'd like to help by testing against my app since I can consistently get a failure with the current version of CDK. However, I'm having a heck of a time trying to test against the CDK source. I ran

scripts/foreach.sh yarn install --frozen-lockfile
scripts/foreach.sh yarn build
# from my project root
../../aws/aws-cdk/link-all.sh

But then I'm getting stuck with the fact that the built aws-cdk-lib requires a peerDependency on constructs 3.x while my app (and current CDK version) is using 10.x. Attempting to downgrade to 3.x in my app doesn't seem to be working as Construct has no public methods. Attempting to upgrade to 10.x in the cdk libraries doesn't seem to work because I end up with type conflicts between <my-project>/node_modules/aws-cdk-lib/core/lib/construct-compat).IConstruct and <my-project>/node_modules/constructs/lib/construct").IConstruct.

Any idea how to work around this 3.x/10.x mismatch?

@misterjoshua
Copy link
Contributor Author

misterjoshua commented Apr 29, 2022

I'd like to help by testing against my app since I can consistently get a failure with the current version of CDK. However, I'm having a heck of a time trying to test against the CDK source. I ran

scripts/foreach.sh yarn install --frozen-lockfile
scripts/foreach.sh yarn build
# from my project root
../../aws/aws-cdk/link-all.sh

But then I'm getting stuck with the fact that the built aws-cdk-lib requires a peerDependency on constructs 3.x while my app (and current CDK version) is using 10.x. Attempting to downgrade to 3.x in my app doesn't seem to be working as Construct has no public methods. Attempting to upgrade to 10.x in the cdk libraries doesn't seem to work because I end up with type conflicts between <my-project>/node_modules/aws-cdk-lib/core/lib/construct-compat).IConstruct and <my-project>/node_modules/constructs/lib/construct").IConstruct.

Any idea how to work around this 3.x/10.x mismatch?

I usually go like this to link cdk:

yarn --immutable
cd packages/aws-cdk
../../scripts/buildup
yarn link

Then in my project I just type yarn link aws-cdk. After this, you can go yarn cdk --version in your project and it should show version 0.0.0.

@mitchlloyd
Copy link
Contributor

Thanks for the detail instructions @misterjoshua. Relying on yarn link worked a lot better than what I was digging up from the internal CDK documentation.

I can confirm that this fixes the issue I saw in my application when I switch to the aws-cdk library from this PR.


I updated to 2.21.1 and added a dummy COPY command in 2 of my Docker files to bust the cache and get all new ECS task definitions.

I got this error:

[66%] fail: docker login --username <redacted> --password-stdin <redacted> exited with error code 1: Error saving credentials: error storing credentials - err: exit status 1, out: `error storing credentials - err: exit status 1, out: `The specified item already exists in the keychain.``

Checkout fix-multi-login branch and run

yarn --immutable
cd packages/aws-cdk
../../scripts/buildup
yarn link

In my project

yarn link aws-cdk
yarn cdk --version # => 0.0.0 (build f3fd3d3)

Then my CDK deployment worked as expected.

@misterjoshua
Copy link
Contributor Author

@pahud Hey. This PR could use a little review. Are you still running that community reviewer program?

@misterjoshua misterjoshua changed the title fix(cdk-assets): osx errors during parallel docker image publishing fix(assets): osx errors during parallel docker image publishing May 2, 2022
@github-actions github-actions bot added p1 and removed p2 labels May 2, 2022
@brianfrantz
Copy link

@misterjoshua @mitchlloyd Sorry. Only today got to a place where I could test this. Running cdk from this branch worked as expected. Running cdk version 2.23.0 (build 50444aa) still returns "The specified item already exists in the keychain."

Best I can tell, this fix will solve our issue.

return async (criticalFunction: () => Promise<void>) => {
const res = lock.then(() => criticalFunction());
lock = res.catch(e => e);
return res.then(v => v);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be return res ? What's the value of the added then ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spotting this. I've removed it - it was a leftover from some hand testing I was doing.

@misterjoshua misterjoshua requested a review from rix0rrr May 10, 2022 15:56
@misterjoshua
Copy link
Contributor Author

@rix0rrr I've made the change you suggested to the critical section function. Please let me know if you'd like any more changes to this PR. Thanks

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for addressing this!

@rix0rrr rix0rrr changed the title fix(assets): osx errors during parallel docker image publishing fix(assets): parallel docker image publishing fails on macOS May 18, 2022
@mergify
Copy link
Contributor

mergify bot commented May 18, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 4d3f234
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit a58a803 into aws:master May 18, 2022
@mergify
Copy link
Contributor

mergify bot commented May 18, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@misterjoshua misterjoshua deleted the fix-multi-login branch May 20, 2022 00:29
wphilipw pushed a commit to wphilipw/aws-cdk that referenced this pull request May 23, 2022
Changes container image publishing so that publishing doesn't re-run docker logins for the same repository and so logins are run one at a time.

Fixes aws#20116

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(cdk-assets): osx cannot run identical docker login commands in parallel
5 participants