Skip to content

Commit

Permalink
correctly set roles for a node (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
adameat authored Jan 4, 2024
1 parent 6ce7c12 commit 30e9736
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion ydb/core/mind/local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,6 @@ class TDomainLocal : public TActorBootstrapped<TDomainLocal> {
info.Attributes.emplace(std::make_pair(attr.GetKey(), attr.GetValue()));
RunningTenants.emplace(std::make_pair(task.Info.TenantName, info));
const TActorId whiteboardServiceId(NNodeWhiteboard::MakeNodeWhiteboardServiceId(SelfId().NodeId()));
Send(whiteboardServiceId, new NNodeWhiteboard::TEvWhiteboard::TEvSystemStateAddRole("Tenant"));
Send(whiteboardServiceId, new NNodeWhiteboard::TEvWhiteboard::TEvSystemStateSetTenant(task.Info.TenantName));
for (TTabletId hId : hiveIds) {
LOG_DEBUG_S(ctx, NKikimrServices::LOCAL,
Expand Down
18 changes: 12 additions & 6 deletions ydb/core/tablet/node_whiteboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
*versionCounter->GetCounter("version", false) = 1;
}

// TODO(t1mursadykov): Add role for static nodes with sys tablets only
if (AppData(ctx)->DynamicNameserviceConfig) {
if (SelfId().NodeId() <= AppData(ctx)->DynamicNameserviceConfig->MaxStaticNodeId)
ctx.Send(ctx.SelfID, new TEvWhiteboard::TEvSystemStateAddRole("Storage"));
}

SystemStateInfo.SetStartTime(ctx.Now().MilliSeconds());
ProcessStats.Fill(getpid());
if (ProcessStats.CGroupMemLim != 0) {
Expand Down Expand Up @@ -386,6 +380,16 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
return modified;
}

void SetRole(TStringBuf roleName) {
for (const auto& role : SystemStateInfo.GetRoles()) {
if (role == roleName) {
return;
}
}
SystemStateInfo.AddRoles(TString(roleName));
SystemStateInfo.SetChangeTime(TActivationContext::Now().MilliSeconds());
}

STRICT_STFUNC(StateFunc,
HFunc(TEvWhiteboard::TEvTabletStateUpdate, Handle);
HFunc(TEvWhiteboard::TEvTabletStateRequest, Handle);
Expand Down Expand Up @@ -459,6 +463,7 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
if (CheckedMerge(pDiskStateInfo, ev->Get()->Record) >= 100) {
pDiskStateInfo.SetChangeTime(ctx.Now().MilliSeconds());
}
SetRole("Storage");
}

void Handle(TEvWhiteboard::TEvVDiskStateUpdate::TPtr &ev, const TActorContext &ctx) {
Expand Down Expand Up @@ -561,6 +566,7 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
SystemStateInfo.ClearTenants();
SystemStateInfo.AddTenants(ev->Get()->Tenant);
SystemStateInfo.SetChangeTime(ctx.Now().MilliSeconds());
SetRole("Tenant");
}
}

Expand Down

0 comments on commit 30e9736

Please sign in to comment.