Skip to content

Commit

Permalink
Added checkbox to show only recently broken placements groups as brok…
Browse files Browse the repository at this point in the history
…en (#1053)

* Added checkbox to show only recently broken placements groups as broken

* removed unnecessary tags

---------

Co-authored-by: Dmitry Razumov <[email protected]>
  • Loading branch information
dvrazumov and Dmitry Razumov authored Apr 26, 2024
1 parent d57bc58 commit 278fb2c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class TDiskRegistryActor final
void RenderDisksToNotify(IOutputStream& out) const;
void RenderUserNotifications(IOutputStream& out) const;
void RenderPlacementGroupList(IOutputStream& out, ui32 limit) const;
void RenderPlacementGroupTable(IOutputStream& out, bool showRecent) const;
void RenderRacks(IOutputStream& out, ui32 limit) const;
void RenderPoolRacks(IOutputStream& out, const TString& poolName) const;
void RenderAgentList(TInstant now, IOutputStream& out, ui32 limit) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ void GenerateVolumeActionsJS(IOutputStream& out)
)html";
}

void OnShowRecentPGCheckboxClickedActionsJS(IOutputStream& out)
{
out << R"html(
<script type='text/javascript'>
function onShowRecentPGCheckboxClicked() {
var checkBox = document.getElementById("showRecentPGCheckbox");
document.getElementById("TotalPGTable").hidden = checkBox.checked;
document.getElementById("RecentPGTable").hidden = !checkBox.checked;
}
</script>
)html";
}

void DumpSize(IOutputStream& out, size_t size)
{
if (size) {
Expand Down Expand Up @@ -1514,16 +1528,44 @@ void TDiskRegistryActor::RenderPlacementGroupList(
return;
}

auto brokenGroups = State->GatherBrokenGroupsInfo(
Now(),
Config->GetPlacementGroupAlertPeriod());

HTML(out) {
TAG(TH3) {
out << "PlacementGroups";
DumpSize(out, State->GetPlacementGroups());
}

OnShowRecentPGCheckboxClickedActionsJS(out);
DIV() {
TAG_ATTRS(
TInput,
{{"type", "checkbox"},
{"id", "showRecentPGCheckbox"},
{"onclick", "onShowRecentPGCheckboxClicked()"}})
{}
LABEL() {
auto period = Config->GetPlacementGroupAlertPeriod();
out << "Treat only recently broken partitions as broken"
<< " (period=" << period.ToString() << ")";
}
}
TAG_ATTRS(TDiv, {{"id", "TotalPGTable"}}) {
RenderPlacementGroupTable(out, false);
}
TAG_ATTRS(TDiv, {{"id", "RecentPGTable"}, {"hidden", "true"}}) {
RenderPlacementGroupTable(out, true);
}
}
}

void TDiskRegistryActor::RenderPlacementGroupTable(
IOutputStream& out,
bool showRecent) const
{
auto brokenGroups = State->GatherBrokenGroupsInfo(
Now(),
Config->GetPlacementGroupAlertPeriod());

HTML(out) {
TABLE_SORTABLE_CLASS("table table-bordered") {
TABLEHEAD() {
TABLER() {
Expand All @@ -1542,9 +1584,12 @@ void TDiskRegistryActor::RenderPlacementGroupList(
strategy == NProto::PLACEMENT_STRATEGY_PARTITION;

auto brokenGroupInfo = brokenGroups.FindPtr(groupId);
const size_t brokenPartitionsCount = brokenGroupInfo
size_t brokenPartitionsCount = 0;
if (brokenGroupInfo) {
brokenPartitionsCount = showRecent
? brokenGroupInfo->Recently.GetBrokenPartitionCount()
: 0;
: brokenGroupInfo->Total.GetBrokenPartitionCount();
}

TABLED() {
const auto* color = brokenPartitionsCount == 0
Expand Down Expand Up @@ -1617,7 +1662,7 @@ void TDiskRegistryActor::RenderPlacementGroupList(
}

const auto brokenDisks = brokenGroupInfo
? brokenGroupInfo->Recently.GetBrokenDisks()
? brokenGroupInfo->Total.GetBrokenDisks()
: THashSet<TString>();

const auto sortedDisks =
Expand Down
1 change: 1 addition & 0 deletions library/cpp/monlib/service/pages/templates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ namespace NMonitoring {
extern const char DListTag[] = "dl";
extern const char DTermTag[] = "dt";
extern const char DDescTag[] = "dd";
extern const char InputTag[] = "input";

}
2 changes: 2 additions & 0 deletions library/cpp/monlib/service/pages/templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ namespace NMonitoring {
extern const char DListTag[3];
extern const char DTermTag[3];
extern const char DDescTag[3];
extern const char InputTag[6];

typedef TTag<HtmlTag> THtml;
typedef TTag<HeadTag> THead;
Expand Down Expand Up @@ -259,4 +260,5 @@ namespace NMonitoring {
typedef TTag<DListTag> DLIST;
typedef TTag<DTermTag> DTERM;
typedef TTag<DDescTag> DDESC;
typedef TTag<InputTag> TInput;
}

0 comments on commit 278fb2c

Please sign in to comment.