Skip to content

Conversation

@DarkIsDude
Copy link
Contributor

@DarkIsDude DarkIsDude commented Jan 15, 2026

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 🙏

@DarkIsDude DarkIsDude self-assigned this Jan 15, 2026
@bert-e
Copy link
Contributor

bert-e commented Jan 15, 2026

Hello darkisdude,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Jan 15, 2026

Incorrect fix version

The Fix Version/s in issue CLDSRV-823 contains:

  • None

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 9.2.15

  • 9.3.0

Please check the Fix Version/s of CLDSRV-823, or the target
branch of this pull request.

@DarkIsDude DarkIsDude changed the title 🎨 Async/Await migration 🎨 Async/Await migration on bucketGet Jan 15, 2026
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 92.38095% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.34%. Comparing base (c022d57) to head (4e7d644).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/api/bucketGet.js 90.27% 7 Missing ⚠️
lib/api/objectGetLegalHold.js 96.96% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
lib/api/objectGetLegalHold.js 95.74% <96.96%> (ø)
lib/api/bucketGet.js 94.32% <90.27%> (-1.83%) ⬇️
@@                 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     
Flag Coverage Δ
file-ft-tests 67.39% <90.47%> (-0.01%) ⬇️
kmip-ft-tests 28.10% <3.80%> (-0.02%) ⬇️
mongo-v0-ft-tests 68.62% <90.47%> (-0.03%) ⬇️
mongo-v1-ft-tests 68.63% <90.47%> (-0.03%) ⬇️
multiple-backend 35.31% <38.09%> (+0.02%) ⬆️
sur-tests 35.62% <38.09%> (-0.78%) ⬇️
sur-tests-inflights 37.44% <38.09%> (-0.01%) ⬇️
unit 69.95% <77.14%> (+<0.01%) ⬆️
utapi-v2-tests 34.32% <38.09%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch from 16402cf to 4e7d644 Compare January 15, 2026 12:17
@DarkIsDude DarkIsDude requested review from a team, anurag4DSB, delthas and maeldonn and removed request for a team January 16, 2026 09:03
@DarkIsDude DarkIsDude marked this pull request as ready for review January 16, 2026 09:03
@DarkIsDude DarkIsDude requested review from a team and removed request for anurag4DSB January 16, 2026 09:03
@DarkIsDude DarkIsDude changed the title 🎨 Async/Await migration on bucketGet 🎨 Async/Await migration on bucketGet and objectGetLegalHold Jan 16, 2026
@bert-e
Copy link
Contributor

bert-e commented Jan 16, 2026

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

* @return {Promise<object>} - object containing xml and additionalResHeaders
*/
function objectGetLegalHold(authInfo, request, log, callback) {
async function objectGetLegalHold(authInfo, request, log, callback) {
Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link
Contributor

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?

@bert-e
Copy link
Contributor

bert-e commented Jan 19, 2026

Incorrect fix version

The Fix Version/s in issue CLDSRV-823 contains:

  • 9.2.15

  • 9.3.0

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 9.2.16

  • 9.3.0

Please check the Fix Version/s of CLDSRV-823, or the target
branch of this pull request.

@bert-e
Copy link
Contributor

bert-e commented Jan 20, 2026

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

Comment on lines +98 to +102
return callback(null, xml, additionalResHeaders);
} catch (err) {
const additionalResHeaders = collectCorsHeaders(request.headers.origin, request.method, bucket);
err.additionalResHeaders = additionalResHeaders;
return callback(err);
Copy link
Contributor

@delthas delthas Jan 20, 2026

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.

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.

5 participants