Skip to content

Commit

Permalink
Add option to restart PDisk without any checks (#13155)
Browse files Browse the repository at this point in the history
(cherry picked from commit 2490271)
  • Loading branch information
SammyVimes authored Jan 3, 2025
1 parent 518ba6d commit 7bd4196
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 19 deletions.
4 changes: 3 additions & 1 deletion ydb/core/blobstorage/base/blobstorage_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,11 @@ namespace NKikimr {

struct TEvBlobStorage::TEvAskWardenRestartPDisk : TEventLocal<TEvAskWardenRestartPDisk, EvAskWardenRestartPDisk> {
const ui32 PDiskId;
const bool IgnoreChecks;

TEvAskWardenRestartPDisk(const ui32& pdiskId)
TEvAskWardenRestartPDisk(const ui32 pdiskId, const bool ignoreChecks)
: PDiskId(pdiskId)
, IgnoreChecks(ignoreChecks)
{}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) {

runtime.RegisterService(pdiskServiceId, pdiskActorId);

runtime.Send(new IEventHandle(nodeWarden, pdiskActorId, new TEvBlobStorage::TEvAskWardenRestartPDisk(pdiskId), 0, cookie), nodeId);
runtime.Send(new IEventHandle(nodeWarden, pdiskActorId, new TEvBlobStorage::TEvAskWardenRestartPDisk(pdiskId, false), 0, cookie), nodeId);

auto responseEvent = new TEvBlobStorage::TEvControllerConfigResponse();

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/nodewarden/node_warden_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ void TNodeWarden::Handle(TEvBlobStorage::TEvAskWardenRestartPDisk::TPtr ev) {

PDiskRestartRequests[requestCookie] = pdiskId;

AskBSCToRestartPDisk(pdiskId, requestCookie);
AskBSCToRestartPDisk(pdiskId, ev->Get()->IgnoreChecks, requestCookie);
}

void TNodeWarden::Handle(TEvBlobStorage::TEvNotifyWardenPDiskRestarted::TPtr ev) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/nodewarden/node_warden_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace NKikimr::NStorage {

TIntrusivePtr<TPDiskConfig> CreatePDiskConfig(const NKikimrBlobStorage::TNodeWardenServiceSet::TPDisk& pdisk);
void StartLocalPDisk(const NKikimrBlobStorage::TNodeWardenServiceSet::TPDisk& pdisk);
void AskBSCToRestartPDisk(ui32 pdiskId, ui64 requestCookie);
void AskBSCToRestartPDisk(ui32 pdiskId, bool ignoreDegradedGroups, ui64 requestCookie);
void OnPDiskRestartFinished(ui32 pdiskId, NKikimrProto::EReplyStatus status);
void DestroyLocalPDisk(ui32 pdiskId);

Expand Down
13 changes: 11 additions & 2 deletions ydb/core/blobstorage/nodewarden/node_warden_pdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,19 @@ namespace NKikimr::NStorage {
SendToController(std::move(report));
}

void TNodeWarden::AskBSCToRestartPDisk(ui32 pdiskId, ui64 requestCookie) {
void TNodeWarden::AskBSCToRestartPDisk(ui32 pdiskId, bool ignoreDegradedGroups, ui64 requestCookie) {
auto ev = std::make_unique<TEvBlobStorage::TEvControllerConfigRequest>();

NKikimrBlobStorage::TRestartPDisk* cmd = ev->Record.MutableRequest()->AddCommand()->MutableRestartPDisk();
NKikimrBlobStorage::TConfigRequest* request = ev->Record.MutableRequest();

NKikimrBlobStorage::TRestartPDisk* cmd = request->AddCommand()->MutableRestartPDisk();

if (ignoreDegradedGroups) {
request->SetIgnoreGroupFailModelChecks(true);
request->SetIgnoreDegradedGroupsChecks(true);
request->SetIgnoreDisintegratedGroupsChecks(true);
request->SetIgnoreGroupSanityChecks(true);
}

auto targetPDiskId = cmd->MutableTargetPDiskId();
targetPDiskId->SetNodeId(LocalNodeId);
Expand Down
14 changes: 8 additions & 6 deletions ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> {
}

Send(ev->Sender, new TEvBlobStorage::TEvNotifyWardenPDiskRestarted(PDisk->PDiskId, NKikimrProto::EReplyStatus::NOTREADY));

return;
}

Expand All @@ -1017,7 +1017,7 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> {
NPDisk::TMainKey newMainKey = ev->Get()->MainKey;

SecureWipeBuffer((ui8*)ev->Get()->MainKey.Keys.data(), sizeof(NPDisk::TKey) * ev->Get()->MainKey.Keys.size());

LOG_NOTICE_S(*TlsActivationContext, NKikimrServices::BS_PDISK, "PDiskId# " << PDisk->PDiskId
<< " Going to restart PDisk since received TEvAskWardenRestartPDiskResult");

Expand All @@ -1031,7 +1031,7 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> {
TIntrusivePtr<TPDiskConfig> actorCfg = std::move(Cfg);

auto& newCfg = ev->Get()->Config;

if (newCfg) {
Y_VERIFY_S(newCfg->PDiskId == pdiskId,
"New config's PDiskId# " << newCfg->PDiskId << " is not equal to real PDiskId# " << pdiskId);
Expand All @@ -1046,7 +1046,7 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> {
TGenericExecutorThread& executorThread = actorCtx.ExecutorThread;

PassAway();

CreatePDiskActor(executorThread, counters, actorCfg, newMainKey, pdiskId, poolId, nodeId);

Send(ev->Sender, new TEvBlobStorage::TEvNotifyWardenPDiskRestarted(pdiskId));
Expand Down Expand Up @@ -1125,10 +1125,12 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> {
}
}
if (cgi.Has("restartPDisk")) {
bool ignoreChecks = "true" == cgi.Get("ignoreChecks");

ui32 cookieIdxPart = NextRestartRequestCookie++;
ui64 fullCookie = (((ui64) PDisk->PDiskId) << 32) | cookieIdxPart; // This way cookie will be unique no matter the disk.
ui64 fullCookie = (((ui64) PDisk->PDiskId) << 32) | cookieIdxPart; // This way cookie will be unique regardless of the disk.

Send(NodeWardenServiceId, new TEvBlobStorage::TEvAskWardenRestartPDisk(PDisk->PDiskId), fullCookie);
Send(NodeWardenServiceId, new TEvBlobStorage::TEvAskWardenRestartPDisk(PDisk->PDiskId, ignoreChecks), fullCookie);
// Send responce later when restart command will be received.
PendingRestartResponse = [this, actor = ev->Sender] (bool restartAllowed, TString& details) {
TStringStream jsonBuilder;
Expand Down
58 changes: 52 additions & 6 deletions ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,32 @@ void TPDisk::RenderState(IOutputStream &str, THttpInfo &httpInfo) {
}
}
function toggleButtonColor() {
var checkbox = document.getElementById("ignoreChecks");
var okButton = document.getElementById("restartOkButton");
if (checkbox.checked) {
okButton.classList.remove("btn-primary");
okButton.classList.add("btn-danger");
} else {
okButton.classList.remove("btn-danger");
okButton.classList.add("btn-primary");
}
}
function sendRestartRequest() {
let ignoreChecks = document.getElementById("ignoreChecks").checked;
let requestData = "restartPDisk=";
if (ignoreChecks) {
requestData += "&ignoreChecks=true";
}
$.ajax({
url: "",
data: "restartPDisk=",
data: requestData,
method: "POST",
success: reloadPage
});
$('#restartModal').modal('hide');
}
function sendStopRequest() {
Expand All @@ -127,11 +146,38 @@ void TPDisk::RenderState(IOutputStream &str, THttpInfo &httpInfo) {
}
</script>
)___";
str << "<button onclick='sendRestartRequest()' name='restartPDisk' class='btn btn-default' ";
str << "style='background:LightGray; margin:5px' ";
str << ">";
str << "Restart";
str << "</button>";

str << R"___(
<button type="button" class="btn btn-default" style="background: LightGray; margin: 5px"
data-toggle="modal" data-target="#restartModal">
Restart
</button>
<div id="restartModal" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Confirm Restart</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to restart?</p>
<div class="checkbox">
<label>
<input type="checkbox" id="ignoreChecks" onchange="toggleButtonColor()"> Ignore all checks
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="restartOkButton" onclick="sendRestartRequest()">Restart</button>
</div>
</div>
</div>
</div>
)___";

if (Cfg->SectorMap) {
str << "<button onclick='sendStopRequest()' name='stopPDisk' class='btn btn-default' ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ void TTestChunkUnlockRestart::TestFSM(const TActorContext &ctx) {
SignalDoneEvent();
break;
}
ctx.Send(NodeWardenId, new TEvBlobStorage::TEvAskWardenRestartPDisk(LastResponse.whiteboardPDiskResult->Record.GetPDiskId()));
ctx.Send(NodeWardenId, new TEvBlobStorage::TEvAskWardenRestartPDisk(LastResponse.whiteboardPDiskResult->Record.GetPDiskId(), false));
break;
case 30:
TEST_RESPONSE(EvHarakiri, OK);
Expand Down

0 comments on commit 7bd4196

Please sign in to comment.