-
Notifications
You must be signed in to change notification settings - Fork 254
🎨 Async/Await migration on bucketGet and objectGetLegalHold #6045
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
base: development/9.2
Are you sure you want to change the base?
Conversation
Hello darkisdude,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
Codecov Report❌ Patch coverage is
Additional details and impacted files
@@ Coverage Diff @@
## development/9.2 #6045 +/- ##
===================================================
- Coverage 84.35% 84.34% -0.01%
===================================================
Files 206 206
Lines 12997 13008 +11
===================================================
+ Hits 10964 10972 +8
- Misses 2033 2036 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
16402cf to
4e7d644
Compare
Request integration branchesWaiting for integration branch creation to be requested by the user. To request integration branches, please comment on this pull request with the following command: Alternatively, the |
| * @return {Promise<object>} - object containing xml and additionalResHeaders | ||
| */ | ||
| function objectGetLegalHold(authInfo, request, log, callback) { | ||
| async function objectGetLegalHold(authInfo, request, log, callback) { |
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.
Isn't it weird to have an async function that takes a callback 🤔 Don't we need to change the code where the function is called too (I think you know what you're doing but still wanna know)
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.
That'a good point. When we are doing the migration it'll be needed to support both case. Here we need the callback to stay compliant and wait for arsenal to support async/await. We can of course change the upstream but then you'll have huge PR
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.
It seems to me that in any case, we would have to change all callers to become also async functions and await the result of this function? So if we are changing them to become async we can also drop the callback at that time, too?
Maybe a way to progressively async/await is to start with the bottom of the call stack and go up? i.e.:
- HTTP handler for the route -> turn that into async first
- cloudserver functions like objectGet -> then, turn this into async, no callback needed
- arsenal functions -> last, turn those into async, no callback needed?
If we start with objectGet and make objectGet async, we already have to edit the HTTP handlers to be async and call await, no?
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
Request integration branchesWaiting for integration branch creation to be requested by the user. To request integration branches, please comment on this pull request with the following command: Alternatively, the |
| return callback(null, xml, additionalResHeaders); | ||
| } catch (err) { | ||
| const additionalResHeaders = collectCorsHeaders(request.headers.origin, request.method, bucket); | ||
| err.additionalResHeaders = additionalResHeaders; | ||
| return callback(err); |
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.
If we are to keep the callbacks, it would perhaps be nice to make the function purely async without callbacks, e.g. async function objectGetLegalHold(authInfo, request, log), then have some util that turns that function into a callback func?
Like some "callbackify" util func that would take a generic async function(arg1, arg2, arg3, ...) -> (ret1, ret2, ...) and return an async function(arg1, arg2, arg3, ..., callback(err, ret1, ret2, ...)) -> void. (That awaits the result, if no exception calls the callback passing the args, if theres is an exception catches it and passes that as callback err).)
Then we could just make the async function purely async, no callbacks, and just have module.exports = callbackify(objectGetLegalHold) when exporting it.
Issue: CLDSRV-823
Description
Motivation and context
Opening a first PR to migrate from callback to async/await syntax. A TAD is opened.
https://scality.atlassian.net/wiki/spaces/OS/pages/3523346468/2025-10-30+-+Async+Await+migration
This is a first PR to start the migration. As mention in the TAD, the idea is to migrate to async/await when working on a specific part of our component. Maybe a common goal of one PR per squad per sprint is a good idea.
All idea or remarks are welcome 🙏