A service may omit its state, so unassigning an uplink module never stops the machine's network manager (hq ADR 0117)
This commit is contained in:
+12
-5
@@ -80,6 +80,9 @@ func Plan(d *declaration.Declaration, known store.State, origin string) []Step {
|
||||
for _, orphan := range known.Orphans(declared, origin) {
|
||||
step := Step{Verb: "remove", Type: orphan.Type, ID: orphan.ID, Target: orphan.Target,
|
||||
Why: "recorded here and no longer declared"}
|
||||
if orphan.Stateless {
|
||||
step.Verb, step.Why = "forget", "no longer declared; its unit's state was never the mesh's and is left as it is"
|
||||
}
|
||||
if d.Adoption == nil && strings.HasPrefix(orphan.ID, declaration.AdoptionPrefix) {
|
||||
step.Why = "what protected this node while adopted; removed last, once everything else applied"
|
||||
protecting = append(protecting, step)
|
||||
@@ -139,11 +142,9 @@ func planned(r declaration.Resource, d *declaration.Declaration, known store.Sta
|
||||
}
|
||||
}
|
||||
}
|
||||
// A file written into replaces nothing that was found, so it is never held (ADR 0102).
|
||||
into := false
|
||||
if f, ok := r.(*declaration.File); ok && f.Into != "" {
|
||||
into = true
|
||||
}
|
||||
// A file written into, or a service whose lifecycle is the machine's, replaces nothing that
|
||||
// was found, so it is never held (ADR 0102, ADR 0117).
|
||||
into := replacesNothing(r)
|
||||
h, held := known.HeldAt(r.Identity())
|
||||
module, untaken := d.Adoption.UntakenModuleOf(r.Identity())
|
||||
switch {
|
||||
@@ -182,6 +183,12 @@ func planned(r declaration.Resource, d *declaration.Declaration, known store.Sta
|
||||
return step
|
||||
}
|
||||
|
||||
if svc, ok := r.(*declaration.Service); ok && svc.Stateless() {
|
||||
// Nothing is created: the unit and whether it runs are the machine's (novox/hq ADR 0117).
|
||||
step.Verb, step.Why = "check", "its lifecycle is the machine's; reloaded or restarted only if "+
|
||||
"running when what it reflects changes"
|
||||
return step
|
||||
}
|
||||
was, recorded := known.Find(r.Identity())
|
||||
if !recorded {
|
||||
step.Verb, step.Why = "create", "no record of it on this node"
|
||||
|
||||
Reference in New Issue
Block a user