resource to disable remote wipe#294
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a runtime configuration switch to disable remote wipe operations in the remote server handlers, with wipe being disabled by default unless explicitly enabled via config/environment.
Changes:
- Add
fdbWipeEnabled;$FDB_WIPE_ENABLEDresource flag (defaultfalse) to gate wipe-related control messages. - Reject wipe-related control messages when wipe is disabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/fdb5/remote/server/StoreHandler.cc | Adds a wipeEnabled resource flag and blocks wipe-related control messages when disabled. |
| src/fdb5/remote/server/CatalogueHandler.cc | Adds the same wipeEnabled resource flag and blocks wipe-related control messages when disabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case Message::Wipe: // Initial wipe request | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| finaliseWipeState(clientID, requestID, payload); | ||
| return Handled::Replied; | ||
|
|
||
| case Message::DoWipeURIs: // request to delete data marked for wipe | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeURIs(clientID, requestID, payload); | ||
| return Handled::Yes; | ||
|
|
||
| case Message::DoWipeFinish: // request to delete empty databases and finish the wipe. | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeFinish(clientID, requestID, payload); | ||
| return Handled::Yes; |
There was a problem hiding this comment.
This can deadlock clients waiting for the control response. Write the control ack first, then send the error, and return Handled::Replied to avoid duplicate acks/errors.
@danovaro , is this true?
| case Message::DoWipeUnknowns: // request to delete unknown URIs as part of a wipe | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeUnknowns(clientID, requestID, payload); | ||
| return Handled::Yes; | ||
|
|
||
| case Message::DoUnsafeFullWipe: // request to delete full database and content | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doUnsafeFullWipe(clientID, requestID, payload); | ||
| return Handled::Replied; |
|
|
||
| Handled StoreHandler::handleControl(Message message, uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload) { | ||
|
|
||
| static bool wipeEnabled = Resource<bool>("fdbWipeEnabled;$FDB_WIPE_ENABLED", false); |
| case Message::Wipe: // Initial wipe request | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| wipe(clientID, requestID, std::move(payload)); | ||
| return Handled::Yes; | ||
|
|
||
| case Message::DoMaskIndexEntries: | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| // doit! We expect DoMaskIndexEntries, doWipeURIs, DoWipeUnknowns and doWipeEmptyDatabase in succession | ||
| doMaskIndexEntries(clientID, requestID, std::move(payload)); | ||
| return Handled::Yes; |
| case Message::DoWipeURIs: // Do the wipe on our currentWipeState | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeURIs(clientID, requestID, std::move(payload)); | ||
| return Handled::Yes; | ||
|
|
||
| case Message::DoWipeFinish: // Finish wipe by deleting empty DBs | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeEmptyDatabase(clientID, requestID, std::move(payload)); | ||
| return Handled::Yes; |
| case Message::DoWipeUnknowns: // Wipe a set of unknown URIs | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeUnknowns(clientID, requestID, std::move(payload)); | ||
| return Handled::Yes; | ||
|
|
||
| case Message::DoUnsafeFullWipe: // wipe a full database including its content | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doUnsafeFullWipe(clientID, requestID, std::move(payload)); | ||
| return Handled::Replied; |
| Handled CatalogueHandler::handleControl(Message message, uint32_t clientID, uint32_t requestID, | ||
| eckit::Buffer&& payload) { | ||
|
|
||
| static bool wipeEnabled = Resource<bool>("fdbWipeEnabled;$FDB_WIPE_ENABLED", false); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #294 +/- ##
===========================================
- Coverage 71.06% 70.93% -0.14%
===========================================
Files 370 370
Lines 23455 23490 +35
Branches 2463 2472 +9
===========================================
- Hits 16669 16663 -6
- Misses 6786 6827 +41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| case Message::Wipe: // Initial wipe request | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| finaliseWipeState(clientID, requestID, payload); | ||
| return Handled::Replied; | ||
|
|
||
| case Message::DoWipeURIs: // request to delete data marked for wipe | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeURIs(clientID, requestID, payload); | ||
| return Handled::Yes; | ||
|
|
||
| case Message::DoWipeFinish: // request to delete empty databases and finish the wipe. | ||
| if (!wipeEnabled) { | ||
| error("Wipe functionality is not enabled", clientID, requestID); | ||
| return Handled::No; | ||
| } | ||
| doWipeFinish(clientID, requestID, payload); | ||
| return Handled::Yes; |
There was a problem hiding this comment.
This can deadlock clients waiting for the control response. Write the control ack first, then send the error, and return Handled::Replied to avoid duplicate acks/errors.
@danovaro , is this true?
Description
Contributor Declaration
By opening this pull request, I affirm the following:
🌈🌦️📖🚧 Documentation FDB 🚧📖🌦️🌈
https://sites.ecmwf.int/docs/fdb/pull-requests/PR-294