Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly set roles for a node #848

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -53,12 +53,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 @@ -385,6 +379,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 @@ -458,6 +462,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 @@ -560,6 +565,7 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
SystemStateInfo.ClearTenants();
SystemStateInfo.AddTenants(ev->Get()->Tenant);
SystemStateInfo.SetChangeTime(ctx.Now().MilliSeconds());
SetRole("Tenant");
}
}

Expand Down
Loading