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

[BE] Upgrade runner lambdas from deprecated v2 client to v3 #5920

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ZainRizvi
Copy link
Contributor

v2 reached maintenance mode in Sept 2024 and will reach end of life Sept 2025

Context:
https://aws.amazon.com/blogs/developer/announcing-end-of-support-for-aws-sdk-for-javascript-v2/

Part of pytorch/pytorch#137228

Testing: ...none yet. Will try deploying these to canary and verify the autoscaling appears to work and logs show no obvious errors

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
torchci ⬜️ Ignored (Inspect) Nov 15, 2024 0:31am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 15, 2024
@ZainRizvi ZainRizvi marked this pull request as draft November 15, 2024 00:31
@@ -41,7 +52,7 @@ export interface RunnerTypeOptional {

export interface RunnerType extends RunnerTypeOptional {
disk_size: number;
instance_type: string;
instance_type: _InstanceType;
Copy link
Contributor

Choose a reason for hiding this comment

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

If it starts with a underscore _ it is not a public interface, and we should not be using it. Can't we cast this to a string or something else?


const data = await expBackOff(() => {
return metrics.trackRequest(
metrics.smGetSecretValueAWSCallSuccess,
metrics.smGetSecretValueAWSCallFailure,
() => {
return secretsManager.getSecretValue({ SecretId: secretsManagerSecretsId }).promise();
return secretsManager.getSecretValue({ SecretId: secretsManagerSecretsId });
Copy link
Contributor

Choose a reason for hiding this comment

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

seems promise is still supported in the latest version.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Request.html#promise-property

Is there a reason you migrated from a async call to a sync call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The auto converter removed those. As per the migration guide, it seems like it automatically returns a promise without it needing to be explicitly referenced:
https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/migrating.html

EncryptionContext: {
['Environment']: environmentName,
},
})
Copy link
Contributor

Choose a reason for hiding this comment

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

same here about the sync calling.

@@ -220,7 +222,7 @@ export class Metrics {
`NS: ${metricsReq.Namespace}] (${i} of ${awsMetrics.length})`,
);
await expBackOff(async () => {
return await this.cloudwatch.putMetricData(metricsReq).promise();
return await this.cloudwatch.putMetricData(metricsReq);
Copy link
Contributor

Choose a reason for hiding this comment

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

please review all removals of the .promise() it might be a big problem

const ec2Client = new EC2({ region: awsRegion });
const command = new DescribeInstancesCommand({ Filters: ec2Filters });
const describeInstanceResult = await ec2Client.send(command);
console.debug(
Copy link
Contributor

Choose a reason for hiding this comment

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

.promise().then...

});
});
if (response.Failed == undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we update the if statements below over overwriting the response here?

@jeanschmidt
Copy link
Contributor

I really like the initiative, but I believe we have some major things that we need to solve before moving forward with tests. What stands out the most is making sure we're properly returning Promise<AWS.Request> or awaiting. Sometimes it is a bit confusing.

Some functions are regular functions, that expect to return Promise<...> and are awaited in the parent function (like the metrics.trackRequest), but others are expect to return the actual response and await.

And, seems that there are some confusing changes on the .promise() function on v3 that I am not entirely confident how to properly await / return the promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants