Asking what the mesh would send must not change it
`status` hung. It composes a declaration for every node to answer *is this machine running what I would send it*, and composing one assigns each module a machine port — so the question wrote to the database, and wrote to the same rows as the machine it was asking about. `port_assignment` is unique on (node, machine). Two transactions inserting the same port do not race, they queue: the second waits on the index until the first commits. A status polled every two seconds while a node applies is two writers on those rows, and the poll stopped returning rather than returning something wrong — which is the better failure of the two, and still a failure. The latent version of this was there before anything polled: two compositions running at once could both allocate. So allocation belongs to the send path alone. The mesh chooses a port when it commits to sending one; every other caller reads what was chosen. A module with nothing assigned has never been sent, which is precisely what "waiting" means — the read needs no number to be right about that, and inventing one would make the answer worse. Named rather than passed as a bare bool: at three call sites, `true` and `false` say nothing about which of these two things is meant. Checked by the lab, which now polls status throughout an apply.
This commit is contained in:
@@ -265,7 +265,7 @@ func pushCommand(ctx context.Context, args []string) error {
|
||||
// The private network is in here with everything else. It used to be composed separately
|
||||
// and prepended, which meant every machine with an address was on it and no machine could
|
||||
// be kept off. It is a module now, so it arrives the way a module does.
|
||||
resources, err := declarationWith(ctx, open, n.Name, plan, settings, gens)
|
||||
resources, err := declarationWith(ctx, open, n.Name, plan, settings, gens, Allocating)
|
||||
if err != nil {
|
||||
refusals = append(refusals, fmt.Sprintf("%s:\n%v", n.Name, err))
|
||||
continue
|
||||
@@ -335,7 +335,7 @@ func sendTo(ctx context.Context, open *stores, names []string) error {
|
||||
refusals = append(refusals, fmt.Sprintf("%s:\n%v", name, err))
|
||||
continue
|
||||
}
|
||||
resources, err := declarationWith(ctx, open, name, plan, settings, gens)
|
||||
resources, err := declarationWith(ctx, open, name, plan, settings, gens, Allocating)
|
||||
if err != nil {
|
||||
refusals = append(refusals, fmt.Sprintf("%s:\n%v", name, err))
|
||||
continue
|
||||
@@ -399,7 +399,7 @@ func wouldSend(ctx context.Context, open *stores,
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
resources, err := declarationWith(ctx, open, n.Name, plan, settings, gens)
|
||||
resources, err := declarationWith(ctx, open, n.Name, plan, settings, gens, Reading)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user