Add CRR Cascaded capabilities#6179
Conversation
Hello sylvainsenechal,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Review by Claude Code |
There was a problem hiding this comment.
all these worked locally, need to wait for the bumps now
c15fb2b to
7912480
Compare
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
7912480 to
973261a
Compare
|
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
The following reviewers are expecting changes from the author, or must review again: |
|
Removing myself as reviewer since alrdy covered by 2 people; and quite complex. Re-add me if needed. |
dc58e7d to
f54b101
Compare
f54b101 to
14aa3a0
Compare
|
Btw I will deal with prettier at the end |
| } | ||
|
|
||
| const incomingVersionIdEncoded = request.headers['x-scal-version-id']; | ||
| if (incomingVersionIdEncoded != null && incomingVersionIdEncoded !== '') { |
There was a problem hiding this comment.
should we not check incomingVersionIdEncoded against undefined to detect the absence/presence of field ?
There was a problem hiding this comment.
I don't have a big opinion on this.
VersionID was already always passed from backbeat before, what's sure is right here for the collision check we need it
But I don't really know whether this function should work without a versionID provided.
What I know is In cloudserverClient, version id header field is not mandatory, and in backbeat, the api is called in only one place with the versionId (and I doubt it's used anywhere else)
| current !== null && | ||
| (incoming === null || incoming > current); |
There was a problem hiding this comment.
kind of hard to read (and validate that it works), would be best not to see this: i.e. use existing compareVersionId...
There was a problem hiding this comment.
looking at the code of compare versionId in arsenal : it seems that function does not support comparing "null" versionID → should be reworked to support that case
Will need to standardize on what "null" is: null, '' or falsish... Falsish is more flexible (does not require null coalescence after loading document...) but means there may not be an actual equality when the function return 0 (null != undefined)
There was a problem hiding this comment.
We have this doc, although its not referenced directly in the code 🤔 https://scality.atlassian.net/wiki/spaces/OS/pages/edit-v2/4141449224
| omVal.isDeleteMarker && | ||
| omVal.replicationInfo && | ||
| omVal.replicationInfo.status === 'REPLICA' && | ||
| (omVal.replicationInfo.isReplica === true || omVal.replicationInfo.status === 'REPLICA') && |
There was a problem hiding this comment.
nit: should we introduce a helper function? or maybe "standardize" omVal.replicationInfo.isReplica after the JSON.parse() call on line 658 ?
try {
omVal = JSON.parse(payload);
omVal.replicationInfo.isReplica ||= omVal.replicationInfo.status === 'REPLICA';
} catch {
return callback(errors.MalformedPOSTRequest);
}| status: '', | ||
| backends: [], | ||
| content: [], | ||
| destination: '', | ||
| storageClass: '', | ||
| role: '', | ||
| storageType: '', | ||
| dataStoreVersionId: '', |
There was a problem hiding this comment.
nit: do we need to put an empty replicationInfo? can't we keep the field undefined?
There was a problem hiding this comment.
Prefer to keep, anyways we will always have at least
omVal.replicationInfo.isReplica = true;
8526cd3 to
7888d79
Compare
7888d79 to
f1f8e09
Compare
| const isIncomingOlderThanCurrent = (incoming, current) => { | ||
| if (current === null) { // nothing to be stale against | ||
| return false; | ||
| } | ||
| // null incoming : source has no cascade revision => oldest possible state | ||
| // larger string = older revision (reverse-chronological order) | ||
| return incoming === null || incoming > current; | ||
| }; |
There was a problem hiding this comment.
is this not compareMicroVersionId ? Or is that "refactor" moved to later commit?
(still quite hard to read, even with the comments... but somehow can't see the original comment about this...)
| request.resume(); | ||
| return _respondWithHeaders( | ||
| response, | ||
| { code: MicroVersionIdAlreadyStoredException.name, | ||
| message: 'incoming microVersionId already at destination' }, | ||
| {}, | ||
| log, | ||
| callback, | ||
| 409, | ||
| ); |
There was a problem hiding this comment.
there is a bit of duplication everywhere:
- 2x 10 lines here (as initially pointed by Mael)
- matching 2 different errors in backbeat
- doing 2 separate comparison (== then strict older)
code here may be dedup by using compareVersionId, something like:
const diff = compareVersionId(current, incoming):
if (diff <= 0) {
const err := diff === 0 ? MicroVersionIdAlreadyStoredException.name : StaleMicroVersionIdException.name;
log.debug(....)
request.resume();
return _respondWithHeaderCrrConflict( ..., err, ... )
}
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
f1f8e09 to
7e1eeb1
Compare
|
|
||
| try { | ||
| omVal = JSON.parse(payload); | ||
| if (omVal.replicationInfo.status === 'REPLICA') { |
There was a problem hiding this comment.
Accessing omVal.replicationInfo.status inside the JSON.parse() try/catch means a missing replicationInfo field throws TypeError, which the catch converts to MalformedPOSTRequest. The payload is valid JSON — the error is misleading and will make debugging harder. Use optional chaining so only actual parse failures trigger MalformedPOSTRequest.
| if (omVal.replicationInfo.status === 'REPLICA') { | |
| if (omVal.replicationInfo?.status === 'REPLICA') { |
7e1eeb1 to
5bc97d1
Compare
5bc97d1 to
e65838c
Compare
|
/approve |
|
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
This pull request did not target the following hotfix branch(es) so they
Please check the status of the associated issue CLDSRV-897. Goodbye sylvainsenechal. The following options are set: approve |
ISSUE : CLDSRV-897
Crr cascaded design : https://github.com/scality/citadel/pull/349
Related PRs :
Arsenal : scality/Arsenal#2628
CloudserverClient : scality/cloudserverclient#24
Backbeat : scality/backbeat#2747
S3utils : scality/s3utils#395