-
Notifications
You must be signed in to change notification settings - Fork 105
Upgrade runner-binaries-syncer to aws sdk v3 #7078
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
1aae26f
to
5f74300
Compare
...ner/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/handler.test.ts
Outdated
Show resolved
Hide resolved
Tagging: versionKey + '=' + actionRunnerReleaseAsset.name, | ||
Body: writeStream, | ||
}).promise(); | ||
const upload = new Upload({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original upload
function did multipart uploads automatically, but there is no upload
function anymore, and putObject
doesn't to multipart uploads. This doesn't matter if the file is small but idk how large the file is, so I use this to handle multipart uploads automatically. Code taken from chatgpt
"dependencies": { | ||
"@aws-sdk/client-s3": "^3.879.0", | ||
"@aws-sdk/lib-storage": "^3.879.0", | ||
"@vercel/ncc": "^0.38.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was getting build problems so I also swapped the ncc dependency. the other lambdas use @vercel
, maybe not this version tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more than likely correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
"@jridgewell/gen-mapping" "^0.3.5" | ||
"@jridgewell/trace-mapping" "^0.3.24" | ||
|
||
"@aws-crypto/crc32@5.2.0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I wonder if we can add these to the linguist file at the root to note that these are generated files and should be automatically minimized in PR reviews.
This is unrelated to the migration work but just a thought I was having.
"dependencies": { | ||
"@aws-sdk/client-s3": "^3.879.0", | ||
"@aws-sdk/lib-storage": "^3.879.0", | ||
"@vercel/ncc": "^0.38.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more than likely correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. Is this testable in canary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades the runner-binaries-syncer Lambda function from AWS SDK v2 to v3 to fix broken tests on the main branch. The changes modernize the S3 client usage and dependencies while maintaining the same functionality.
- Replaces AWS SDK v2 imports and usage with v3 equivalents
- Updates S3 client initialization and API calls to use the new SDK patterns
- Migrates from
@zeit/ncc
to@vercel/ncc
bundler
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/syncer/handler.ts | Updates S3 client imports, initialization, and API calls to use AWS SDK v3 patterns |
package.json | Replaces AWS SDK v2 dependencies with v3 equivalents and updates bundler |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
}).catch((error) => { | ||
console.error(`Exception: ${error}`); | ||
}); | ||
await uploadPromise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The uploadPromise is awaited after the request stream has already finished, which could cause the upload to complete before all data is written. Move await uploadPromise;
inside the Promise callback after writeStream.end()
to ensure proper sequencing.
Copilot uses AI. Check for mistakes.
const versions = objectTagging.TagSet?.filter((t: Tag) => t.Key === versionKey); | ||
return versions?.length === 1 ? versions[0].Value : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining versions?.length
is inconsistent with the original logic. If versions
is undefined, the condition should return undefined, but if it's an empty array, it should also return undefined. The original code versions.length === 1
would throw if versions is undefined, which may have been the intended behavior.
const versions = objectTagging.TagSet?.filter((t: Tag) => t.Key === versionKey); | |
return versions?.length === 1 ? versions[0].Value : undefined; | |
if (!objectTagging.TagSet) { | |
throw new Error('TagSet is undefined'); | |
} | |
const versions = objectTagging.TagSet.filter((t: Tag) => t.Key === versionKey); | |
return versions.length === 1 ? versions[0].Value : undefined; |
Copilot uses AI. Check for mistakes.
console.debug('latest: ' + currentVersion); | ||
if (currentVersion === undefined || currentVersion != actionRunnerReleaseAsset.name) { | ||
uploadToS3(s3, cacheObject, actionRunnerReleaseAsset); | ||
await uploadToS3(s3, cacheObject, actionRunnerReleaseAsset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an await since uploadToS3 is an async function and is in a for loop, so this should wait for the upload to finish. Alt: add to a list of promises and await at the end
yarn test
is broken on main, you can see this intest-infra/terraform-aws-github-runner/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/Makefile
Line 15 in a32b8f6
Testing:
Stole some environment variables from the lambda and mangled the key to upload to a dummy key then ran
yarn build; cd dist;node -e 'require("./index").handler();' > t.log
Saw that it uploaded a file, and skipped some because they didn't need to be uploaded.
The one that was uploaded was arm64, which I'm thinking was uploaded manually since it lacks a tag on s3.
I had to add an
await
since it wasn't working, which I think is a bug in the original code