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: If image functions have same metadata, only 1st one is in the result #2624

Merged
merged 4 commits into from
Feb 13, 2021

Conversation

aahung
Copy link
Contributor

@aahung aahung commented Feb 12, 2021

…s built

Which issue(s) does this change fix?

Why is this change necessary?

How does it address the issue?

What side effects does this change have?

Checklist

  • Add input/output type hints to new functions/methods
  • Write design document (Do I need to write a design document?)
  • Write unit tests
  • Write/update functional tests
  • Write/update integration tests
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

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

@aahung aahung changed the title fix: If multiple image functions have same metadata, only first one can be built fix: If image functions have same metadata, only first one can be built Feb 12, 2021
@aahung aahung changed the title fix: If image functions have same metadata, only first one can be built fix: If image functions have same metadata, only 1st one is built Feb 12, 2021
@aahung aahung requested a review from sriram-mv February 12, 2021 22:44
@aahung aahung changed the title fix: If image functions have same metadata, only 1st one is built fix: If image functions have same metadata, only 1st one is in the result Feb 12, 2021
@@ -193,6 +193,30 @@ def test_build_layers_and_functions(self, mock_copy_tree, mock_path):
str(mock_path(given_build_dir, self.function1_2.name)),
)

def test_build_single_function_definition_image_functions_with_same(self, mock_copy_tree, mock_path):
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also add an integ test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Comment on lines 128 to 131
if build_definition.packagetype == ZIP:
for function in build_definition.functions:
if function.name is not single_function_name:
for function in build_definition.functions:
if function.name != single_function_name:
if build_definition.packagetype == ZIP:
# for zip function we need to copy over the artifacts
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need to change the order here? This will check the if statement for every function in the build definition (no matter it is ZIP or IMAGE), but the previous order will have 2 separate flow for IMAGE and ZIP from the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, good catch! I optimized for more less code. This indeed introduced more checks. Reverted

@aahung aahung force-pushed the fix-image-functions-with-same-image branch from 06788b5 to c0142f4 Compare February 12, 2021 23:11
@aahung aahung requested review from sriram-mv and mndeveci February 12, 2021 23:14
@@ -127,12 +127,18 @@ def build_single_function_definition(self, build_definition: FunctionBuildDefini
# copy results to other functions
if build_definition.packagetype == ZIP:
for function in build_definition.functions:
if function.name is not single_function_name:
if function.name != single_function_name:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should use != instead of is not to compare strings.

@aahung aahung merged commit 9440f15 into aws:develop Feb 13, 2021
elbayaaa added a commit that referenced this pull request Feb 19, 2021
elbayaaa added a commit that referenced this pull request Feb 19, 2021
* Revert "fix: If image functions have same metadata, only 1st one is in the result (#2624)"

This reverts commit 9440f15.

* Revert "fix: SamFunctionProvider could miss functions with same name but in different stacks (#2609)"

This reverts commit 1382eaf.

* Revert "fix: Nested stack cannot be extracted if not in working dir (#2618)"

This reverts commit d7bcfc6.
elbayaaa added a commit that referenced this pull request Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants