Skip to content

Commit 071f0cf

Browse files
authored
Merge pull request #509 from netlify/al2-uploads-need-different-shas
fix: al2 uploads need to have function name in SHA
2 parents 4bc8b72 + 418eb97 commit 071f0cf

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
Binary file not shown.

go/porcelain/deploy.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,13 @@ func createHeader(archive *zip.Writer, i os.FileInfo, runtime string) (io.Writer
981981
return archive.CreateHeader(&zip.FileHeader{
982982
CreatorVersion: 3 << 8, // indicates Unix
983983
ExternalAttrs: 0777 << 16, // -rwxrwxrwx file permissions
984-
Name: "bootstrap",
985-
Method: zip.Deflate,
984+
985+
// we need to make sure we don't have two ZIP files with the exact same contents - otherwise, our upload deduplication mechanism will do weird things.
986+
// adding in the function name as a comment ensures that every function ZIP is unique
987+
Comment: i.Name(),
988+
989+
Name: "bootstrap",
990+
Method: zip.Deflate,
986991
})
987992
}
988993
return archive.Create(i.Name())

go/porcelain/deploy_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,23 @@ func TestBundle(t *testing.T) {
612612
functions, schedules, functionsConfig, err := bundle(gocontext.Background(), "../internal/data", mockObserver{})
613613

614614
assert.Nil(t, err)
615-
assert.Equal(t, 4, len(functions.Files))
615+
assert.Equal(t, 5, len(functions.Files))
616616
assert.Empty(t, schedules)
617617
assert.Nil(t, functionsConfig)
618618

619619
jsFunction := functions.Files["hello-js-function-test"]
620620
pyFunction := functions.Files["hello-py-function-test"]
621621
rsFunction := functions.Files["hello-rs-function-test"]
622622
goFunction := functions.Files["hello-go-binary-function"]
623+
goBackgroundFunction := functions.Files["hello-go-binary-function-background"]
623624

624625
assert.Equal(t, "js", jsFunction.Runtime)
625626
assert.Equal(t, "py", pyFunction.Runtime)
626627
assert.Equal(t, "rs", rsFunction.Runtime)
627628
assert.Equal(t, "provided.al2", goFunction.Runtime)
629+
assert.Equal(t, "provided.al2", goBackgroundFunction.Runtime)
630+
631+
assert.NotEqual(t, goFunction.Sum, goBackgroundFunction.Sum)
628632
}
629633

630634
func TestBundleWithManifest(t *testing.T) {

0 commit comments

Comments
 (0)