mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
A fleet view needs one thing this package did not expose: the ability to ask a
live process what it loaded, at which version, and whether it is still up.
Deployment config answers what was INTENDED; only the process knows what is
TRUE — which is exactly the difference that matters mid-rollout, when the two
disagree by design.
for _, p := range app.Plugins() {
// Name, Prefix, Source, Version, Addr, PID, Running, Since, Reloads
}
Version is the artifact's SHA-256 for a URL-installed plugin — the only version
identifier that cannot drift from the bits running, because it IS the bits.
Since resets on Reload, so it reports the age of what is running rather than of
the mount, and Reloads climbing on one host and not its peers is the signal that
a rollout is uneven. An Unloaded plugin stays listed with Running=false, because
"deployed but down" and "not deployed" are different states and its routes are
still registered answering 503.
Remote (Addr) mounts are recorded too. They took an early return and were
invisible before; a fleet view that silently omits part of the surface is worse
than none.
Two fixes found by having the tests exercise this:
Shutdown now waits for instances a Reload or Unload is still draining. Those
retire asynchronously so the caller is not blocked for the drain window, which
let a child outlive the host that spawned it — and since children inherit the
host's stdout, the process appeared to hang after main returned. The suite
showed it as "Test I/O incomplete 1m0s after exiting"; it now finishes in 22s
instead of 74s.
Tests no longer hardcode ports. A fixed 19653 meant an unrelated process on the
box made TestListen_ZAP fail with 404 rather than a connection error, because
the port answers — it is just answering for someone else. That reads as a
routing bug and is not one.
Co-authored-by: Hanzo Dev <[email protected]>
27 lines
786 B
Go
27 lines
786 B
Go
package zip_test
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
// freeAddr returns a loopback address nothing is listening on.
|
|
//
|
|
// These tests used fixed ports, which is fine in isolation and wrong on a
|
|
// shared machine: an unrelated process holding 19653 makes TestListen_ZAP fail
|
|
// with a 404 rather than a connection error, because the port answers — it is
|
|
// just answering for someone else. That reads as a routing bug and is not one.
|
|
//
|
|
// Binding :0 and releasing has a race window, but it is bounded by the next
|
|
// line of the test rather than by whatever else lives on the box.
|
|
func freeAddr(t *testing.T) string {
|
|
t.Helper()
|
|
l, err := net.Listen("tcp", "127.0.0.1:0")
|
|
if err != nil {
|
|
t.Fatalf("reserve a port: %v", err)
|
|
}
|
|
addr := l.Addr().String()
|
|
_ = l.Close()
|
|
return addr
|
|
}
|