From 0948d3f539e61bdcfc83a49cf1b3a38fd2cb417e Mon Sep 17 00:00:00 2001 From: Scot Schuchert-Wells <6007097+scotwells@users.noreply.github.com> Date: Mon, 16 Nov 2026 05:28:36 +0000 Subject: [PATCH] fix(compute): report the backends stage for a live URL with no healthy member Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com> --- internal/cmd/compute/url/publish.go | 21 ++++++++++++++++-- internal/cmd/compute/url/publish_test.go | 27 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/internal/cmd/compute/url/publish.go b/internal/cmd/compute/url/publish.go index 085b60bc..8ad7cda9 100644 --- a/internal/cmd/compute/url/publish.go +++ b/internal/cmd/compute/url/publish.go @@ -221,8 +221,13 @@ func (p *progress) check(ctx context.Context, c client.Client, workloadName stri return nil, false, nil } - if info.Backends.Healthy > 0 { - p.line("Backends", fmt.Sprintf("%d healthy across %s", info.Backends.Healthy, strings.Join(servingCities(info), ", "))) + // Report the backends stage whenever a NetworkService backs the URL, even + // with nothing healthy yet. A redeploy of an already-live URL can return on + // the first poll, before the new instance registers, so the healthy count + // can be zero here. The line still belongs in the output, which a caller + // such as a rollout gate reads. + if info.Service != nil { + p.line("Backends", backendsStage(info)) } if info.EdgeProgrammed { p.line("Edge", "programmed") @@ -241,6 +246,18 @@ func (p *progress) check(ctx context.Context, c client.Client, workloadName stri return nil, false, nil } +// backendsStage renders the backends progress value: how many members are +// healthy and the cities taking traffic. The cities are dropped when the +// platform has reported no location yet, so the value never ends in a bare +// "across". +func backendsStage(info *Info) string { + stage := fmt.Sprintf("%d healthy", info.Backends.Healthy) + if cities := servingCities(info); len(cities) > 0 { + stage += " across " + strings.Join(cities, ", ") + } + return stage +} + // line prints one progress row, skipping rows already printed with the same // value. A count that changes as instances register is worth reprinting; a // repeat of the same fact is not. diff --git a/internal/cmd/compute/url/publish_test.go b/internal/cmd/compute/url/publish_test.go index 1c5b1049..d9131fae 100644 --- a/internal/cmd/compute/url/publish_test.go +++ b/internal/cmd/compute/url/publish_test.go @@ -140,6 +140,33 @@ func TestPublishReturnsWhenTheURLIsLive(t *testing.T) { } } +// TestPublishReportsBackendsBeforeAnyRegister pins the output a redeploy owes. +// The URL is already live from the previous deploy, so the wait returns on its +// first poll while the NetworkService still reports no healthy member. The +// backends line must still appear, because a caller such as a rollout gate +// reads the deploy output for it. +func TestPublishReportsBackendsBeforeAnyRegister(t *testing.T) { + c := newFakeClient(t, + publishedProxy(testWorkloadName, testCanonical), + publishedService(testWorkloadName, 8080, location("DFW", 1, 0, false)), + ) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + var out bytes.Buffer + info, err := Publish(ctx, &out, c, workloadNamed(testWorkloadName), testPortName, 8080, false, nil) + if err != nil { + t.Fatalf("Publish returned error: %v", err) + } + if info == nil || !info.Live() { + t.Fatalf("info = %+v, want the live URL left by the previous deploy", info) + } + if got := out.String(); !strings.Contains(got, "Backends 0 healthy across DFW") { + t.Errorf("output missing the backends line:\n%s", got) + } +} + func TestPublishUpdatesAChangedPort(t *testing.T) { rec := &recorder{} c := interceptor.NewClient(newFakeClient(t,