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

feat: upload go binaries as al2-compatible zip #490

Merged
merged 4 commits into from
Oct 13, 2023
Merged

feat: upload go binaries as al2-compatible zip #490

merged 4 commits into from
Oct 13, 2023

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented Sep 21, 2023

Ensures that Go binaries that have provided.al2 as their runtimeVersion are uploaded in a provided.al2-compatible ZIP. This means that the name of the binary inside the created ZIP needs to be bootstrap, and that we're sending runtime=provided.al2 to the Netlify API.

Part of https://github.com/netlify/pod-dev-foundations/issues/581.

@Skn0tt Skn0tt requested a review from a team as a code owner September 21, 2023 13:41
@Skn0tt Skn0tt self-assigned this Sep 21, 2023
@netlify
Copy link

netlify bot commented Sep 21, 2023

Deploy Preview for open-api ready!

Name Link
🔨 Latest commit c15e6db
🔍 Latest deploy log https://app.netlify.com/sites/open-api/deploys/652919cb2a4e9f00083acecc
😎 Deploy Preview https://deploy-preview-490--open-api.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@mraerino mraerino left a comment

Choose a reason for hiding this comment

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

how are we making sure that binaries we get are ready for this runtime? they need to use a certain version of the Lambda Go SDK right?

@Skn0tt
Copy link
Contributor Author

Skn0tt commented Sep 21, 2023

The binary needs to be built with GOOS=linux GOARCH=amd64: https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html#heading:r1i:
This hasn't changed between the go1.x and provided.al2 runtimes, so our customers won't need to change anything to the binaries they're uploading.

@mraerino
Copy link
Contributor

hmm, i was under the impression that you needed to run a minimum version of the Go SDK for the provided runtime to be supported, but i can't find any docs on this. i guess that must have been possible for a long time.
still the risk that some people have very old go modules that they use for building their Go functions, not sure


assert.Equal(t, "js", jsFunction.Runtime)
assert.Equal(t, "py", pyFunction.Runtime)
assert.Equal(t, "rs", rsFunction.Runtime)
assert.Equal(t, "go", goFunction.Runtime)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's no manifest file, there's no change. We're still uploading stuff as go, for now.

assert.Equal(t, "a-runtime", functions.Files["hello-js-function-test"].Runtime)
assert.Empty(t, functions.Files["hello-js-function-test"].FunctionMetadata.InvocationMode)
assert.Equal(t, "some-other-runtime", functions.Files["hello-py-function-test"].Runtime)
assert.Equal(t, "stream", functions.Files["hello-py-function-test"].FunctionMetadata.InvocationMode)
assert.Equal(t, "provided.al2", functions.Files["hello-go-binary-function"].Runtime)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's a runtimeVersion: "provided.al2" in the manifest, we now pick that up and send it to the API as the runtime.

@Skn0tt
Copy link
Contributor Author

Skn0tt commented Oct 11, 2023

I've made some updates to go along with netlify/zip-it-and-ship-it#1609, and would love another review.

@Skn0tt
Copy link
Contributor Author

Skn0tt commented Oct 11, 2023

Uh-oh, the tests are failing on windows, probably because

func goFile(filePath string, i os.FileInfo, observer DeployObserver) bool {
warner, hasWarner := observer.(DeployWarner)
if m := i.Mode(); m&0111 == 0 { // check if it's an executable file
if hasWarner {
warner.OnWalkWarning(filePath, "Go binary does not have executable permissions")
}
return false
}
if _, err := elf.Open(filePath); err != nil { // check if it's a linux executable
if hasWarner {
warner.OnWalkWarning(filePath, "Go binary is not a linux executable")
}
return false
}
v, err := version.ReadExe(filePath)
if err != nil || !strings.HasPrefix(v.Release, "go1.") {
if hasWarner {
warner.OnWalkWarning(filePath, "Unable to detect Go version 1.x")
}
}
return true
}
isn't working correctly on windows 🫤

Copy link
Contributor

@JGAntunes JGAntunes left a comment

Choose a reason for hiding this comment

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

LGTM. CI seems to be complaining but I don't know how relevant it is since we've changed the porcelain part and nothing on the auto generated bit - https://github.com/netlify/open-api/actions/runs/6494408840/job/17671324967?pr=490#step:5:10

@Skn0tt Skn0tt enabled auto-merge October 13, 2023 10:19
@Skn0tt Skn0tt merged commit 537abf5 into master Oct 13, 2023
14 of 15 checks passed
@Skn0tt Skn0tt deleted the golang-al2 branch October 13, 2023 10:20
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