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-elasticsearch/aws-opensearch: lambda resource synth not stable between linux and windows #16928

Closed
fknittel opened this issue Oct 12, 2021 · 3 comments · Fixed by #16945
Closed
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug.

Comments

@fknittel
Copy link

What is the problem?

Since 1.123.0 the lambda resources brought in by use of aws-elasticsearch constructs produce different synth values for Linux and Windows. This is a problem for us, as we use the synth results as goldenmaster tests and have Windows on the dev machines and Linux on the CI machines.

I assume that this also affects custom Lambdas, but our problem is specifically with the aws-elasticsearch use.

Reproduction Steps

I've prepared a simple reproduction project, starting with cdk init and a stack containing an example Domain construct copy&pasted from the documentation and a simple test case that highlights which elements of the synth result differ between platforms. Please see the three branches

I've added github actions that hopefully highlight the problem. The test works on both platforms for 1.122.0 but produces different results between Linux and Windows on 1.123.0 up to 1.127.0.

What did you expect to happen?

I expected the same (construct internal) lambda resources to get synthesized, regardless of the platform the synth is performed on.

What actually happened?

The synth differs between Linux and Windows.

CDK CLI Version

1.127.0 (build 0ea309a)

Framework Version

1.127.0 (also affects >= 1.123.0)

Node.js Version

v16.11.0 / v14.18.0

OS

Linux and Windows

Language

Typescript, Java

Language Version

TypeScript (3.9.10) | Java (11)

Other information

I've tried to make it easily reproducible in the referenced repo. If you need anything else, please don't hesitate.

We're currently stuck on 1.122.0 due to this issue.

After some research I found #14555, but I'm not sure whether it's the same issue. Please advise.

@fknittel fknittel added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 12, 2021
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Oct 12, 2021
@peterwoodworth
Copy link
Contributor

@jogold I'd appreciate if you could take a look at this, thanks!

@peterwoodworth peterwoodworth removed the needs-triage This issue or PR still needs to be triaged. label Oct 12, 2021
@jogold
Copy link
Contributor

jogold commented Oct 13, 2021

Thanks for the very detailed bug report @fknittel!

I was able to reproduce this and found the problem:

_hashField(hash, `file:${relativePath}`, contentFingerprint(realPath));

  • This relative path uses \ on windows but / on linux

In versions < 1.123.0 there were no subfolders in the custom resource's "asset", relatives path were : index.d.ts and index.js => no differences between windows and linux

Opening a PR to fix this.

jogold added a commit to jogold/aws-cdk that referenced this issue Oct 13, 2021
The hash for a specific file in a directory include its relative path.
This gives different results on Linux vs Windows because of the
different path separator. The solution is to normalize the relative path
using forward slashes.

Affects directory assets with subdirectories.

Closes aws#14555
Closes aws#16928
@mergify mergify bot closed this as completed in #16945 Oct 13, 2021
mergify bot pushed a commit that referenced this issue Oct 13, 2021
The hash for a specific file in a directory include its relative path.
This gives different results on Linux vs Windows because of the
different path separator. The solution is to normalize the relative path
using forward slashes.

Affects directory assets with subdirectories.

Closes #14555
Closes #16928


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
The hash for a specific file in a directory include its relative path.
This gives different results on Linux vs Windows because of the
different path separator. The solution is to normalize the relative path
using forward slashes.

Affects directory assets with subdirectories.

Closes aws#14555
Closes aws#16928


----

*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
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants