seaweed-block: failover keeps exit 3 for a caller deadline before send

A failover whose caller deadline passed before the request was sent
(e.g. a master that never completes the handshake) is Recover under the
failover contract, so the command prints result=unknown and asks the
operator to read the current line. The canonical projection gave it
exit 1, which the help text reserves for a definite answer, while
v1.1.x returned 3. Add the failover legacy row next to the unsent
remote-failure one so the exit matches the printed outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 13:44:09 -08:00
1 parent 46f2f80e80
commit 20e7f5fa9a
3 files changed
+42 -1

No files matched your search

@@ -11,6 +11,7 @@ import (
"encoding/pem"
"errors"
"math/big"
"net"
"os"
"os/exec"
"path/filepath"
@@ -170,6 +171,42 @@ func TestOpsFailoverReportsAnUnknownOutcome(t *testing.T) {
}
}
// A master that never answers the handshake leaves the call unsent when the
// caller's deadline passes; the operator must still read the line first.
func TestOpsFailoverUnsentCallerDeadlineIsUnknown(t *testing.T) {
cert, key, ca := writeClientIdentity(t, t.TempDir())
t.Setenv(link.EnvTLSCert, cert)
t.Setenv(link.EnvTLSKey, key)
t.Setenv(link.EnvTLSCA, ca)
silent, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
held := make(chan net.Conn, 16)
go func() {
for {
conn, err := silent.Accept()
if err != nil {
close(held)
return
}
held <- conn
}
}()
t.Cleanup(func() {
silent.Close()
for conn := range held {
conn.Close()
}
})
args := failoverArgs("--timeout", "300ms")
args[3] = silent.Addr().String()
var out, errb bytes.Buffer
if rc := run(args, &out, &errb); rc != 3 || !strings.Contains(out.String(), "result=unknown") {
t.Fatalf("rc=%d stdout=%q stderr=%q; want 3 and result=unknown", rc, out.String(), errb.String())
}
}
// The admin command never dials without a complete, valid client identity:
// unset, partial or unreadable TLS settings are refused locally (exit 2, no
// call); a valid identity makes the call.
@@ -23,6 +23,7 @@ type LegacyExit struct {
var legacyExits = []LegacyExit{
{Failover, "remote_unavailable", 3, "docs/standalone-deployment.md", "Failover requires reading the current authority line before another move even when its RPC was unsent.", "v1.2"},
{Failover, "deadline_exceeded", 3, "docs/standalone-deployment.md", "A caller deadline before sending also requires reading the current authority line before another move.", "v1.2"},
{ChunkVerify, "outcome_unknown", 1, "docs/standalone-deployment.md", "Incomplete verification must not share exit 3 with a completed scan containing findings; JSON retains the failure class.", "v1.2"},
{VolumeCreate, "bad_request", 78, "docs/standalone-deployment.md", "Create documents server refusal as 78; local argument parsing remains 2.", "v1.2"},
{VolumeResolve, "bad_request", 78, "docs/standalone-deployment.md", "Resolve documents definite server refusal as 78; local argument parsing remains 2.", "v1.2"},
@@ -48,7 +48,7 @@ func TestCanonicalExitProjectionGrid(t *testing.T) {
if contract == answer.ChunkVerify && row.name == "unknown" {
want = 1
}
if contract == answer.Failover && row.name == "unsent" {
if contract == answer.Failover && (row.name == "unsent" || row.name == "caller-deadline") {
want = 3
}
if (contract == answer.VolumeCreate || contract == answer.VolumeResolve) && row.name == "unknown" {
@@ -69,6 +69,8 @@ func TestCanonicalExitProjectionGrid(t *testing.T) {
}
func TestEveryLegacyExitHasADocumentedGridRow(t *testing.T) {
expired, cancel := context.WithTimeout(context.Background(), -time.Second)
defer cancel()
expected := []struct {
contract answer.Contract
err error
@@ -76,6 +78,7 @@ func TestEveryLegacyExitHasADocumentedGridRow(t *testing.T) {
exit int
}{
{answer.Failover, answer.Record(answer.Unsent, refusedDial(t)), answer.Unsent, 3},
{answer.Failover, answer.RecordContext(expired, answer.Unsent, expired.Err()), answer.Unsent, 3},
{answer.ChunkVerify, resetConnection(t), answer.PossiblyAdmitted, 1},
{answer.VolumeCreate, status.Error(codes.InvalidArgument, "server refused"), answer.PossiblyAdmitted, 78},
{answer.VolumeResolve, status.Error(codes.InvalidArgument, "server refused"), answer.PossiblyAdmitted, 78},