Give a service's held state its own field and key, so main compiles again
#64/#65 and #66 each added Applied.Declared: a directory's declared owner and
mode (string) and a service's held state (*FoundUnit), both under the JSON key
"declared". The directory's is already on nodes, written by d28ca95, so it
keeps the name and key; the service's becomes DeclaredUnit, "declared_unit".
#66 never deployed, so no node holds a record under the new key.
This commit is contained in:
+25
-25
@@ -728,25 +728,25 @@ func ApplyMindingWindows(
|
||||
Origin: origin,
|
||||
ID: resource.Identity(), Type: string(resource.Kind()),
|
||||
Target: outcome.Target, AppliedAt: time.Now().UTC(),
|
||||
Wrote: outcome.wrote,
|
||||
Into: outcome.into,
|
||||
Kept: kept,
|
||||
KeptMode: keptMode,
|
||||
KeptOwner: keptOwner,
|
||||
Reads: outcome.reads,
|
||||
Stateless: outcome.stateless,
|
||||
Scope: outcome.scope,
|
||||
User: outcome.user,
|
||||
Found: outcome.found,
|
||||
Declared: outcome.declared,
|
||||
Shell: outcome.shell,
|
||||
Linger: outcome.linger,
|
||||
Groups: outcome.groups,
|
||||
Unpacked: outcome.unpacked,
|
||||
AsFound: outcome.asFound,
|
||||
Declared: outcome.asFoundDeclared,
|
||||
FoundAt: outcome.asFoundAt,
|
||||
Holds: holds(resource),
|
||||
Wrote: outcome.wrote,
|
||||
Into: outcome.into,
|
||||
Kept: kept,
|
||||
KeptMode: keptMode,
|
||||
KeptOwner: keptOwner,
|
||||
Reads: outcome.reads,
|
||||
Stateless: outcome.stateless,
|
||||
Scope: outcome.scope,
|
||||
User: outcome.user,
|
||||
Found: outcome.found,
|
||||
DeclaredUnit: outcome.declared,
|
||||
Shell: outcome.shell,
|
||||
Linger: outcome.linger,
|
||||
Groups: outcome.groups,
|
||||
Unpacked: outcome.unpacked,
|
||||
AsFound: outcome.asFound,
|
||||
Declared: outcome.asFoundDeclared,
|
||||
FoundAt: outcome.asFoundAt,
|
||||
Holds: holds(resource),
|
||||
})
|
||||
if outcome.found != nil {
|
||||
known.DropFound(resource.Identity())
|
||||
@@ -2847,9 +2847,9 @@ func giveUnitBack(ctx context.Context, sys system.System, a store.Applied, run R
|
||||
// mesh's doing outliving the mesh — a pool whose distribution scrub timer a module stopped would have
|
||||
// no schedule at all once the module went. A unit stopped for any other reason is not known to have
|
||||
// been stopped by the mesh, and is left as before.
|
||||
if !made && a.Declared != nil && (a.Declared.Unit == "" || a.Declared.Unit == a.Target) {
|
||||
start := a.Found.State == "running" && a.Declared.State == "stopped"
|
||||
enable := a.Found.Boot == "enabled" && a.Declared.Boot == "disabled"
|
||||
if !made && a.DeclaredUnit != nil && (a.DeclaredUnit.Unit == "" || a.DeclaredUnit.Unit == a.Target) {
|
||||
start := a.Found.State == "running" && a.DeclaredUnit.State == "stopped"
|
||||
enable := a.Found.Boot == "enabled" && a.DeclaredUnit.Boot == "disabled"
|
||||
if start || enable {
|
||||
return startUnitBack(ctx, sys, a, run, start, enable)
|
||||
}
|
||||
@@ -2953,9 +2953,9 @@ func startUnitBack(ctx context.Context, sys system.System, a store.Applied, run
|
||||
errRemovalWaits, a.Target, err)
|
||||
}
|
||||
}
|
||||
if state != a.Declared.State || (a.Declared.Boot != "" && boot != a.Declared.Boot) {
|
||||
if state != a.DeclaredUnit.State || (a.DeclaredUnit.Boot != "" && boot != a.DeclaredUnit.Boot) {
|
||||
return "forgotten", fmt.Sprintf("it is %s and %s at boot, not the %s and %s the mesh held it to: somebody "+
|
||||
"changed it since, so it is left as it is", state, boot, a.Declared.State, orUnset(a.Declared.Boot)), nil
|
||||
"changed it since, so it is left as it is", state, boot, a.DeclaredUnit.State, orUnset(a.DeclaredUnit.Boot)), nil
|
||||
}
|
||||
var did []string
|
||||
if enable {
|
||||
@@ -3027,7 +3027,7 @@ func foundAs(ctx context.Context, sys system.System, r *declaration.Service, run
|
||||
// Given back as if undeclared, never as the mesh's own: whether the mesh wrote the old
|
||||
// unit's file is known to the removal of orphans, and that file's own record goes with it.
|
||||
action, detail, err := removeService(ctx, sys,
|
||||
store.Applied{Type: string(declaration.TypeService), Target: unit, Found: f, Declared: previous.Declared,
|
||||
store.Applied{Type: string(declaration.TypeService), Target: unit, Found: f, DeclaredUnit: previous.DeclaredUnit,
|
||||
Scope: previous.Scope, User: previous.User}, run, false)
|
||||
switch {
|
||||
case errors.Is(err, errRemovalWaits):
|
||||
|
||||
@@ -125,14 +125,14 @@ func Plan(d *declaration.Declaration, known store.State, origin string) []Step {
|
||||
case f == nil:
|
||||
step.Verb, step.Why = "forget", "no longer declared; recorded before the host kept what it "+
|
||||
"found, so it is left as it is"
|
||||
case orphan.Declared != nil && ((f.State == "running" && orphan.Declared.State == "stopped") ||
|
||||
(f.Boot == "enabled" && orphan.Declared.Boot == "disabled")):
|
||||
case orphan.DeclaredUnit != nil && ((f.State == "running" && orphan.DeclaredUnit.State == "stopped") ||
|
||||
(f.Boot == "enabled" && orphan.DeclaredUnit.Boot == "disabled")):
|
||||
// startUnitBack's words (novox/hq ADR 0269): what the mesh's declaration stopped goes back.
|
||||
var back []string
|
||||
if f.State == "running" && orphan.Declared.State == "stopped" {
|
||||
if f.State == "running" && orphan.DeclaredUnit.State == "stopped" {
|
||||
back = append(back, "started")
|
||||
}
|
||||
if f.Boot == "enabled" && orphan.Declared.Boot == "disabled" {
|
||||
if f.Boot == "enabled" && orphan.DeclaredUnit.Boot == "disabled" {
|
||||
back = append(back, "enabled at boot")
|
||||
}
|
||||
// A preview: whether it is still as the mesh held it is read when the removal runs, and a
|
||||
|
||||
Reference in New Issue
Block a user