Skip to content

Conversation

leif-scality
Copy link
Contributor

@leif-scality leif-scality commented Oct 6, 2025

Add GetBucketLogging and PutBucketLogging endpoints

  • The package.json changes will be reverted before change

@bert-e
Copy link
Contributor

bert-e commented Oct 6, 2025

Hello leif-scality,

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 Oct 6, 2025

Incorrect fix version

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

  • None

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

  • 9.1.5

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

Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.47%. Comparing base (a432e79) to head (b08e0a2).

Files with missing lines Patch % Lines
lib/api/bucketPutLogging.js 97.67% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
lib/api/api.js 89.79% <100.00%> (+0.10%) ⬆️
lib/api/bucketGetLogging.js 100.00% <100.00%> (ø)
lib/api/bucketPutLogging.js 97.67% <97.67%> (ø)

... and 2 files with indirect coverage changes

@@                 Coverage Diff                 @@
##           development/9.0    #5966      +/-   ##
===================================================
+ Coverage            83.40%   83.47%   +0.06%     
===================================================
  Files                  189      191       +2     
  Lines                12198    12271      +73     
===================================================
+ Hits                 10174    10243      +69     
- Misses                2024     2028       +4     
Flag Coverage Δ
unit 67.79% <98.63%> (+0.23%) ⬆️
utapi-v2-tests 33.28% <21.91%> (-0.11%) ⬇️

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.

@leif-scality leif-scality changed the base branch from development/9.1 to development/9.0 October 6, 2025 18:51
@bert-e
Copy link
Contributor

bert-e commented Oct 6, 2025

Incorrect fix version

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

  • None

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

  • 9.0.31

  • 9.1.5

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

return callback(err);
}

return callback(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return callback(null);
return 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.

done

const request = createGetLoggingRequest(bucketName);

bucketGetLogging(authInfo, request, log, (err, xml) => {
assert.strictEqual(err, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert.strictEqual(err, null);
assert.ifError(err);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced the strict equal with ifError in both test files

const putRequest = createLoggingRequest(bucketName, loggingXML);

// First enable logging
bucketPutLogging(authInfo, putRequest, log, err => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: you may want to use async.series or async.waterfall to reduce nesting levels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to waterfall to handle logging and metrics in only one place

});
});

it('should handle multiple get requests consistently', done => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if this test is really useful, but no problem to keep it if you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

bucketPutLogging(authInfo, request, log, err => {
assert(err);
// Missing body should trigger XML parsing error
assert(err.is.MalformedXML || err.code === 'MalformedXML');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to support both error types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, removed the string check

Copy link
Contributor

@dvasilas dvasilas left a comment

Choose a reason for hiding this comment

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

Looks good.

We should also add monitoring to these APIs:

monitoring.promMetrics('PUT', bucketName, '200', 'bucketPutACL');

@leif-scality
Copy link
Contributor Author

Looks good.

We should also add monitoring to these APIs:

monitoring.promMetrics('PUT', bucketName, '200', 'bucketPutACL');

added metrics

@leif-scality leif-scality force-pushed the improvement/CLDSRV-754-bucket-put-get-logging branch from 856c74c to 3402063 Compare October 7, 2025 17:43
@dvasilas
Copy link
Contributor

dvasilas commented Oct 8, 2025

I think you need to remove logging from unsupportedQueries in constants because currently the API returns NotImplemented:

'logging',

request,
};

return waterfall([
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if the target bucket exists? Do you know if AWS returns an error if it does not exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An error occurred (InvalidTargetBucketForLogging) when calling the PutBucketLogging operation: The target bucket for logging does not exist

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a check and functional tests

@leif-scality leif-scality force-pushed the improvement/CLDSRV-754-bucket-put-get-logging branch 4 times, most recently from 5993699 to 951dd9c Compare October 13, 2025 08:20
@leif-scality leif-scality force-pushed the improvement/CLDSRV-754-bucket-put-get-logging branch from 951dd9c to 28ee88f Compare October 13, 2025 17:02
lib/api/api.js Outdated
Comment on lines 385 to 386
bucketPutLogging,
bucketGetLogging,
Copy link
Contributor

Choose a reason for hiding this comment

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

follow alphabetical order here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see them moved.
I see the alphabetical order is not strictly enforced, but at lost move thise next to the other bucket actions

lib/api/api.js Outdated
Comment on lines 78 to 80
const bucketPutLogging = require('./bucketPutLogging');
const bucketGetLogging = require('./bucketGetLogging');

Copy link
Contributor

Choose a reason for hiding this comment

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

same, follow alphabetical order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@leif-scality leif-scality force-pushed the improvement/CLDSRV-754-bucket-put-get-logging branch from 029a87c to b08e0a2 Compare October 14, 2025 16:39
Bucket: bucketName,
BucketLoggingStatus: validLoggingConfig,
}, err => {
assert.strictEqual(err, null,
Copy link
Contributor

@BourgoisMickael BourgoisMickael Oct 14, 2025

Choose a reason for hiding this comment

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

Use ifError if possible

Suggested change
assert.strictEqual(err, null,
assert.ifError(err)

_testPutBucketLoggingError(s3, validLoggingConfigWithGrants, 501, 'NotImplemented', done);
});

it('should disable logging with empty BucketLoggingStatus', done => {
Copy link
Contributor

@BourgoisMickael BourgoisMickael Oct 14, 2025

Choose a reason for hiding this comment

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

It can be difficult to read with many nested callbacks.

I'd prefer if possible now to use async await instead of done callback in tests.

You can use await s3.putBucketLogging({...}).promise().

We started using that on new test files

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