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 84.81013% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.43%. Comparing base (a76859f) to head (b6e1ad0).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/api/objectGetLegalHold.js 82.05% 7 Missing ⚠️
lib/api/bucketGet.js 85.29% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
lib/metadata/metadataUtils.js 90.65% <100.00%> (+0.31%) ⬆️
lib/api/bucketGet.js 92.54% <85.29%> (-0.27%) ⬇️
lib/api/objectGetLegalHold.js 84.61% <82.05%> (-4.75%) ⬇️

... and 1 file with indirect coverage changes

@@                 Coverage Diff                 @@
##           development/9.3    #6045      +/-   ##
===================================================
- Coverage            84.44%   84.43%   -0.02%     
===================================================
  Files                  206      206              
  Lines                13186    13205      +19     
===================================================
+ Hits                 11135    11149      +14     
- Misses                2051     2056       +5     
Flag Coverage Δ
file-ft-tests 67.62% <79.74%> (+<0.01%) ⬆️
kmip-ft-tests 28.14% <6.32%> (-0.21%) ⬇️
mongo-v0-ft-tests 68.84% <79.74%> (-0.02%) ⬇️
mongo-v1-ft-tests 68.95% <79.74%> (-0.01%) ⬇️
multiple-backend 35.19% <29.11%> (+<0.01%) ⬆️
sur-tests 35.71% <29.11%> (-0.84%) ⬇️
sur-tests-inflights 37.58% <29.11%> (-0.04%) ⬇️
unit 69.67% <74.68%> (+0.01%) ⬆️
utapi-v2-tests 34.44% <29.11%> (-0.16%) ⬇️

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.

@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.

@francoisferrand francoisferrand self-requested a review January 20, 2026 20:34
@bert-e
Copy link
Contributor

bert-e commented Jan 22, 2026

Incorrect fix version

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

  • 9.2.18

  • 9.3.0

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

  • 9.2.19

  • 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 23, 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.

@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch 2 times, most recently from bafa722 to 08d8dc0 Compare January 23, 2026 17:17
@bert-e
Copy link
Contributor

bert-e commented Jan 23, 2026

Incorrect fix version

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

  • 9.2.20

  • 9.3.0

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

  • 9.2.21

  • 9.3.0

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

@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch 2 times, most recently from 474bad8 to 7a14efc Compare January 29, 2026 12:14
@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch from 7a14efc to c98d577 Compare February 4, 2026 06:31
@DarkIsDude DarkIsDude changed the base branch from development/9.2 to feature/CLDSRV-823/formatting-only February 4, 2026 06:31
@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch from c98d577 to 4f6b182 Compare February 4, 2026 06:50
@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/formatting-only branch from d6342e9 to 7559941 Compare February 4, 2026 06:50
@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/formatting-only branch 3 times, most recently from 7559941 to 99b9108 Compare February 4, 2026 17:29
@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch from 872cfa3 to 7bed447 Compare February 4, 2026 17:32
Base automatically changed from feature/CLDSRV-823/formatting-only to development/9.3 February 9, 2026 10:18
@bert-e
Copy link
Contributor

bert-e commented Feb 9, 2026

Conflict

There is a conflict between your branch feature/CLDSRV-823/async-await-start and the
destination branch development/9.3.

Please resolve the conflict on the feature branch (feature/CLDSRV-823/async-await-start).

git fetch && \
git checkout origin/feature/CLDSRV-823/async-await-start && \
git merge origin/development/9.3

Resolve merge conflicts and commit

git push origin HEAD:feature/CLDSRV-823/async-await-start

@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-823/async-await-start branch from 7b03be0 to b6e1ad0 Compare February 9, 2026 12:19
@bert-e
Copy link
Contributor

bert-e commented Feb 9, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

log.debug('error processing request', { err });
monitoring.promMetrics('GET', bucketName, err.code, 'listBucket');
throw err;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

not an issue for this PR, but I wonder if we can write this "more cleanly" (e.g. avoid the separate let variable, and make the exception "wrapping" more seamless) with a combination of promise and await? e.g. something like this:

const bucket = await standardMetadataValidateBucketPromised(metadataValParams, request.actionImplicitDenies, log).catch(err => {
	log.debug('error processing request', { err });
    monitoring.promMetrics('GET', bucketName, err.code, 'listBucket');
    throw err;
});

(ideally, I'd rather avoid such "exception wrapping", but may not be possible in every case...)

what do you think: Does it work? Is there some Is this a "pattern" we may or should use?
or should we rather a single try/catch over the whole function in such case (which would avoid the duplicated "catch" block for log & prometheus)?

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's a good question and it depends a lot on each case. I prefer for example the try/catch than the mix of promise/await but it's a pure personal opinion. IMO the industry try to move to a more try/catch approach but it's just a feeling. Anyway what you suggest should work.

It's a "migration". So some pattern can not be perfect... A good option to avoid the try/catch can be to type of errors and use that in one catch block (more or less what we did for AWS error). In that case I would suggest to keep the try/catch and don't try to complexify the migration. It's a well balanced between moving forward with the migration and improving our code.

const verCfg = bucket.getVersioningConfiguration();
additionalResHeaders['x-amz-version-id'] = getVersionIdResHeader(verCfg, objectMD);

return [xml, additionalResHeaders];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should explicitly add this corner-case in the TAD, to warn user when migrating functions which pass multiple values to callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

6 participants