Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CRR/ReplicationStatusUpdater.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const crypto = require('crypto');
const {
doWhilst, eachSeries, eachLimit, waterfall,
} = require('async');
Expand Down Expand Up @@ -72,6 +73,14 @@ class ReplicationStatusUpdater {
this.forceUsingConfiguration = forceUsingConfiguration;
this.log = log;

// Random replicationGroupId (7 chars) and instanceId (6 chars) for
// microVersionId generation: this tool bypasses CloudServer's
// configured values, so per-instance random tokens prevent
// collisions with concurrent writers. Sizes match LENGTH_RG and
// LENGTH_ID in arsenal's VersionID module.
this.replicationGroupId = crypto.randomBytes(4).toString('hex').slice(0, 7);
this.instanceId = crypto.randomBytes(3).toString('hex').slice(0, 6);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No unit test verifies the format of the generated replicationGroupId (7 hex chars) or instanceId (6 hex chars), or that updateMicroVersionId receives them. Since these sizes must match arsenal's LENGTH_RG and LENGTH_ID constants for cascaded CRR loop detection to work, a simple test asserting the lengths and hex-only content would catch regressions if the generation logic is ever refactored.


this._setupClients();

this.logProgressInterval = setInterval(this._logProgress.bind(this), LOG_PROGRESS_INTERVAL_MS);
Expand Down Expand Up @@ -193,7 +202,7 @@ class ReplicationStatusUpdater {
return process.nextTick(next);
}

objMD.updateMicroVersionId();
objMD.updateMicroVersionId(this.instanceId, this.replicationGroupId);
const md = objMD.getSerialized();
return this.cloudserverclient.putMetadata({
Bucket: bucket,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3utils",
"version": "1.18.0",
"version": "1.19.0",
"engines": {
"node": ">= 22"
},
Expand Down
Loading