Skip to content

Commit

Permalink
CLDSRV-514: add logs when potential oprhans are created
Browse files Browse the repository at this point in the history
Some APIs will delete the metadata before the storage side:
in this case, we log a specific warning with the associated
information, as a first way to keep track of such objects.
Future work will persist this information , to be processed
by some background service.
  • Loading branch information
williamlardier committed Mar 6, 2024
1 parent 5301589 commit e215e4a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/api/multiObjectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request,
objMD, authInfo, canonicalID, null, request,
deleteInfo.newDeleteMarker, null, overheadField, log,
's3:ObjectRemoved:DeleteMarkerCreated', (err, result) =>
callback(err, objMD, deleteInfo, result.versionId));
callback(err, objMD, deleteInfo, result?.versionId));
},
], (err, objMD, deleteInfo, versionId) => {
if (err === skipError) {
Expand Down Expand Up @@ -428,7 +428,15 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request,
}

return async.each(chunks, (chunk, done) => data.batchDelete(chunk, null, null,
logger.newRequestLoggerFromSerializedUids(log.getSerializedUids()), done),
logger.newRequestLoggerFromSerializedUids(log.getSerializedUids()), err => {
if (err) {
log.warn('potential orphan in storage', {
error: err,
objects: chunk,
});
}
return done();
}),
err => {
if (err) {
log.error('error deleting objects from data backend', { error: err });
Expand Down
16 changes: 14 additions & 2 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,24 @@ const services = {
}

if (!Array.isArray(objectMD.location)) {
data.delete(objectMD.location, deleteLog);
return cb(null, res);
return data.delete(objectMD.location, deleteLog, err => {
if (err) {
log.warn('potential orphan in storage', {
object: objectMD.location,
error: err,
});
return cb(err);
}
return cb(null, res);
});
}

return data.batchDelete(objectMD.location, null, null, deleteLog, err => {
if (err) {
log.warn('potential orphan in storage', {
objects: objectMD.location,
error: err,
});
return cb(err);
}
return cb(null, res);
Expand Down

0 comments on commit e215e4a

Please sign in to comment.