From 6a0dbe5a04043706642d7f88e44bad69586c81c8 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 8 Oct 2026 15:05:53 +0200 Subject: [PATCH] Say a pending new login in the same words everywhere, without 'session' (issue 318 review) --- cmd/mesh-controller/module_health.go | 8 ++++++-- cmd/mesh-controller/plain_words.go | 2 +- cmd/mesh-controller/plain_words_test.go | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/mesh-controller/module_health.go b/cmd/mesh-controller/module_health.go index b40c6818..17f83ec4 100644 --- a/cmd/mesh-controller/module_health.go +++ b/cmd/mesh-controller/module_health.go @@ -388,6 +388,10 @@ func moduleUnhealthyObservation(module, node string, rs []inventory.ResourceHeal // reasonWords is why a resource is unhealthy, as a person reads it. func reasonWords(r inventory.ResourceHealth) string { + // An account waiting for a new login (ADR 0252) is said in the mesh's words, not the engine's. + if r.Kind == link.KindAccount && strings.HasPrefix(r.Reason, link.ReasonRelogin) { + return fmt.Sprintf("waits for a new login of %s, which is in the group and logged in before it was", accountOf(r)) + } switch r.Reason { case "restarting": return fmt.Sprintf("keeps restarting (%d restart(s) counted)", r.Restarts) @@ -452,11 +456,11 @@ func personWait(module, machine string, rs []inventory.ResourceHealth) (string, } } said := fmt.Sprintf("relogin needed on %s: %s waits for a new login of %s, which is in its group and whose "+ - "running session began before it was; log out of every session and in again, or reboot", machine, module, + "login began before it was; log out of %[1]s completely and log in again, or restart it", machine, module, strings.Join(accounts, ", ")) if len(units) > 0 { sort.Strings(units) - said += fmt.Sprintf(" (until then %s cannot run in that session)", strings.Join(units, ", ")) + said += fmt.Sprintf(" (until then %s cannot run)", strings.Join(units, ", ")) } return said, true } diff --git a/cmd/mesh-controller/plain_words.go b/cmd/mesh-controller/plain_words.go index 75746ed8..6a8d3b26 100644 --- a/cmd/mesh-controller/plain_words.go +++ b/cmd/mesh-controller/plain_words.go @@ -664,7 +664,7 @@ func moduleNeeds(node string, rs []inventory.ResourceHealth) string { // reloginNeeds is what an account waiting for its groups needs (ADR 0252). func reloginNeeds(node string) string { - return fmt.Sprintf("log out of every session on %s and log in again.", node) + return fmt.Sprintf("log out of %s completely and log in again, or restart it.", node) } // stalledWords are the plain words of a delivery held past its bound, as mesh-delivery says it. diff --git a/cmd/mesh-controller/plain_words_test.go b/cmd/mesh-controller/plain_words_test.go index 16c6747e..6e4b8f69 100644 --- a/cmd/mesh-controller/plain_words_test.go +++ b/cmd/mesh-controller/plain_words_test.go @@ -94,7 +94,7 @@ func TestAModuleUnhealthyAsksForARestartInWords(t *testing.T) { // An account waiting for a new login (ADR 0252) asks for the login, held to the plain rule. o = moduleUnhealthyObservation("openrazer", "g14", []inventory.ResourceHealth{{Kind: "account", Resource: "operator-in-group", Target: "jochen", Reason: "relogin needed: the account is in the group"}}) - if o.Needs != "log out of every session on g14 and log in again." || len(o.Actions) != 0 { + if o.Needs != "log out of g14 completely and log in again, or restart it." || len(o.Actions) != 0 { t.Errorf("relogin: %q %+v", o.Needs, o.Actions) } w := conditions.Words{Headline: o.Headline, Explanation: o.Explanation, Resolved: o.Resolved, Needs: o.Needs} @@ -107,6 +107,9 @@ func TestAModuleUnhealthyAsksForARestartInWords(t *testing.T) { if why, ok := conditions.PlainWords(rw, "g14"); !ok || rw.Needs == "" || len(rw.Actions) != 0 { t.Errorf("relogin-needed: %s %+v", why, rw) } + if strings.Contains(o.Summary, "session") || !strings.Contains(o.Summary, "waits for a new login of jochen") { + t.Errorf("relogin summary: %q", o.Summary) + } } // **Failed units on a machine**: "shanks's service manager is degraded: 3 failed unit(s) no module places —