hub v0.162.0 (built, not deployed): no repeat mail after a restart for a known-down host or an already-reported stale restore test (R-1001); the Day-0 agent list leaves out packages without the felhom-agent file, a vouch of one is refused (R-1011); an absent tunnel reads 'none set up' (R-1070)
gates / gates (push) Successful in 7m20s
gates / gates (push) Successful in 7m20s
This commit is contained in:
1 parent
a28f162c66
commit
5f31da04bc
16 files changed
+443
-17
No files matched your search
@@ -23,9 +23,10 @@ import (
|
||||
// fakeGitea serves the two endpoints the client uses, with a controllable per-request delay so
|
||||
// "concurrent" is measurable rather than asserted.
|
||||
type fakeGitea struct {
|
||||
versions []string
|
||||
delay time.Duration
|
||||
failVer string // this version's /files call 500s
|
||||
versions []string
|
||||
delay time.Duration
|
||||
failVer string // this version's /files call 500s
|
||||
bundleOnly string // R-1011: this version's package holds only the config bundle (an agent step bundle)
|
||||
|
||||
inFlight int32
|
||||
maxSeen int32
|
||||
@@ -58,6 +59,10 @@ func (f *fakeGitea) start(t *testing.T) *gitea.Client {
|
||||
}
|
||||
}
|
||||
ver := versionFromFilesPath(r.URL.Path)
|
||||
if f.bundleOnly != "" && ver == f.bundleOnly {
|
||||
fmt.Fprintf(w, `[{"name":"felhom-config-bundle.json","sha256":"bundle-%s"}]`, ver)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, `[{"name":"felhom-agent","sha256":"sha-%s"}]`, ver)
|
||||
return
|
||||
}
|
||||
@@ -246,3 +251,25 @@ func TestArtifactChoices_CacheIsPerPackage(t *testing.T) {
|
||||
t.Error("precondition")
|
||||
}
|
||||
}
|
||||
|
||||
// R-1011: the Day-0 agent list shows only versions whose package holds the felhom-agent file. A step bundle
|
||||
// (`0.156.1-step1`, only felhom-config-bundle.json) is left out — never listed with the bundle's sha.
|
||||
//
|
||||
// COMPANION RED-PROOF (observed 2026-10-19): with FileSHA256's pre-fix fallback to the first file, it fails with
|
||||
//
|
||||
// artifact_choices_test.go: the list offers 0.156.1-step1 (sha "bundle-0.156.1-step1"), a package with no agent binary
|
||||
//
|
||||
// Restored.
|
||||
func TestArtifactChoices_R1011_StepBundleIsNotAnAgentVersion(t *testing.T) {
|
||||
f := &fakeGitea{versions: []string{"0.157.0", "0.156.1-step1", "0.156.1"}, bundleOnly: "0.156.1-step1"}
|
||||
s := newTestWebServer(t, f.start(t))
|
||||
got := s.artifactChoices(context.Background(), "felhom-agent", "felhom-agent")
|
||||
for _, c := range got {
|
||||
if c.Version == "0.156.1-step1" {
|
||||
t.Fatalf("the list offers %s (sha %q), a package with no agent binary", c.Version, c.SHA256)
|
||||
}
|
||||
}
|
||||
if len(got) != 2 || got[0].SHA256 != "sha-0.157.0" || got[1].Version != "0.156.1" || got[1].SHA256 != "sha-0.156.1" {
|
||||
t.Fatalf("the release versions must stay, each with its own binary's sha: %+v", got)
|
||||
}
|
||||
}
|
||||
@@ -51,8 +51,12 @@ func (f *fakeRegistry) start(t *testing.T) *gitea.Client {
|
||||
if f.shaless[seg[5]+"/"+seg[6]] {
|
||||
sha = ""
|
||||
}
|
||||
name := seg[5] // the agent's file is named after its package …
|
||||
if name == pkgGolden {
|
||||
name = fileGolden // … the golden's is not (R-1011: the hub now asks for exactly that file)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`[{"name":"` + seg[5] + `","sha256":"` + sha + `"}]`))
|
||||
_, _ = w.Write([]byte(`[{"name":"` + name + `","sha256":"` + sha + `"}]`))
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
||||
@@ -1589,6 +1589,7 @@ func (s *Server) handleSetArtifacts(w http.ResponseWriter, r *http.Request) {
|
||||
//
|
||||
// artifact_version_missing — the registry answered 404 for that version
|
||||
// artifact_sha_missing — the version exists but the registry listed no sha256
|
||||
// artifact_file_missing — the version exists but its package holds no such file (an agent step bundle, R-1011)
|
||||
// artifact_unverifiable — the registry did not answer usefully (network error, 5xx)
|
||||
// artifact_sha_invalid — a hand-typed sha is not 64 hex characters (manual path only)
|
||||
func (s *Server) resolveArtifactSHA(ctx context.Context, pkg, file, version, submittedSHA string) (string, string) {
|
||||
@@ -1602,6 +1603,8 @@ func (s *Server) resolveArtifactSHA(ctx context.Context, pkg, file, version, sub
|
||||
switch {
|
||||
case gitea.IsNotFound(err):
|
||||
flash = "artifact_version_missing"
|
||||
case errors.Is(err, gitea.ErrNoFile):
|
||||
flash = "artifact_file_missing"
|
||||
case errors.Is(err, gitea.ErrNoSHA):
|
||||
flash = "artifact_sha_missing"
|
||||
}
|
||||
|
||||
@@ -47,8 +47,10 @@ func TestArtifactSave_FlashNamesTheCause(t *testing.T) {
|
||||
}{
|
||||
{"version not found", http.StatusNotFound, "", "artifact_version_missing"},
|
||||
{"registry failing", http.StatusBadGateway, "", "artifact_unverifiable"},
|
||||
{"no sha listed", http.StatusOK, `[{"name":"x","sha256":""}]`, "artifact_sha_missing"},
|
||||
{"healthy", http.StatusOK, `[{"name":"x","sha256":"` + sha + `"}]`, "artifacts_set"},
|
||||
{"no sha listed", http.StatusOK, `[{"name":"felhom-agent","sha256":""},{"name":"golden.tar.zst","sha256":""}]`, "artifact_sha_missing"},
|
||||
// R-1011: a step bundle — files, but not the agent binary — is refused by name, never another file's sha.
|
||||
{"no agent binary (a step bundle)", http.StatusOK, `[{"name":"felhom-config-bundle.json","sha256":"` + sha + `"}]`, "artifact_file_missing"},
|
||||
{"healthy", http.StatusOK, `[{"name":"felhom-agent","sha256":"` + sha + `"},{"name":"golden.tar.zst","sha256":"` + sha + `"}]`, "artifacts_set"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
s, _ := newTestServer(t)
|
||||
@@ -81,6 +83,7 @@ func TestArtifactFlashes_EachRendersItsOwnText(t *testing.T) {
|
||||
for flash, want := range map[string]string{
|
||||
"artifact_version_missing": "the registry has no such version",
|
||||
"artifact_sha_missing": "no checksum for a chosen version",
|
||||
"artifact_file_missing": "holds no artifact",
|
||||
"artifact_unverifiable": "could not verify",
|
||||
"artifact_sha_invalid": "a checksum you typed is not valid",
|
||||
} {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/subtle"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
@@ -385,7 +386,14 @@ func (s *Server) artifactChoices(ctx context.Context, pkg, file string) []artifa
|
||||
wg.Wait()
|
||||
|
||||
out := make([]artifactChoice, 0, len(vers))
|
||||
var noFile []string
|
||||
for i, v := range vers {
|
||||
if errors.Is(errs[i], gitea.ErrNoFile) {
|
||||
// R-1011: a version whose package does not hold the artifact (an agent step bundle) is not an agent
|
||||
// version — left out of the dropdown, one INFO line per resolve rather than a WARN per version.
|
||||
noFile = append(noFile, v)
|
||||
continue
|
||||
}
|
||||
if errs[i] != nil {
|
||||
// unchanged behaviour: a failed lookup drops THAT version, never the whole list
|
||||
s.logger.Printf("[WARN] artifact sha (%s/%s): %v", pkg, v, errs[i])
|
||||
@@ -394,6 +402,10 @@ func (s *Server) artifactChoices(ctx context.Context, pkg, file string) []artifa
|
||||
out = append(out, artifactChoice{Version: v, SHA256: shas[i]})
|
||||
}
|
||||
|
||||
if len(noFile) > 0 {
|
||||
s.logger.Printf("[INFO] artifact choices (%s): %d version(s) without %s left out (R-1011): %s", pkg, len(noFile), file, strings.Join(noFile, ", "))
|
||||
}
|
||||
|
||||
// Only a SUCCESSFUL resolve is cached. A Gitea blip must not pin an empty list in front of the
|
||||
// operator for a minute — the earlier returns leave the cache untouched, and so does this one
|
||||
// when every version's sha lookup failed.
|
||||
|
||||
@@ -298,6 +298,10 @@ func buildSystemRows(lines []osupdates.FleetLine, facts map[string]sysfacts.Syst
|
||||
switch l.Tunnel {
|
||||
case "running":
|
||||
r.Tunnel = plain("running")
|
||||
case "absent":
|
||||
// R-1070 (agent with the `absent` state): no cloudflared container — a box with no tunnel set up (a test
|
||||
// or LAN-only box). Not a fault; the hub's tunnel alarm counts not_running only.
|
||||
r.Tunnel = cell{Text: "none set up", Title: "no cloudflared container in the guest (agent state: absent)"}
|
||||
case "not_running", "inactive":
|
||||
r.Tunnel = cell{Text: l.Tunnel, Class: "bad"}
|
||||
default:
|
||||
|
||||
@@ -272,3 +272,19 @@ func TestSystemPage_KernelCells(t *testing.T) {
|
||||
t.Fatalf("an older agent: %+v %+v", d, step)
|
||||
}
|
||||
}
|
||||
|
||||
// R-1070: the agent's new `absent` tunnel state (no cloudflared container — no tunnel set up) reads as a plain fact,
|
||||
// not as a warning; not_running stays red, an unknown state stays amber.
|
||||
func TestSystemRows_R1070_AbsentTunnelIsNotAWarning(t *testing.T) {
|
||||
lines := []osupdates.FleetLine{{HostID: "a", Tunnel: "absent"}, {HostID: "b", Tunnel: "not_running"}, {HostID: "c", Tunnel: "unknown"}}
|
||||
rows := buildSystemRows(lines, nil, nil, time.Hour, time.Hour, time.Hour, time.Now())
|
||||
if len(rows) != 3 {
|
||||
t.Fatalf("rows: %d", len(rows))
|
||||
}
|
||||
if rows[0].Tunnel.Class != "" || rows[0].Tunnel.Text != "none set up" {
|
||||
t.Errorf("absent: %+v, want a plain „none set up\"", rows[0].Tunnel)
|
||||
}
|
||||
if rows[1].Tunnel.Class != "bad" || rows[2].Tunnel.Class != "warn" {
|
||||
t.Errorf("not_running %+v must stay bad, unknown %+v warn", rows[1].Tunnel, rows[2].Tunnel)
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,9 @@
|
||||
{{if eq .Flash "artifact_unverifiable"}}
|
||||
<div class="flash flash-error"><strong>Refused: could not verify — this does not mean anything is missing.</strong> The registry did not answer, so the hub cannot tell whether that version is installable. It refuses rather than saving with a warning, because a warning beside a success reads as a success. Manifest unchanged. Check that Gitea is up, then try again. There is deliberately no override: the registry is on your own server, so if it is unreachable the vouch can wait.</div>
|
||||
{{end}}
|
||||
{{if eq .Flash "artifact_file_missing"}}
|
||||
<div class="flash flash-error"><strong>Refused: that version's package holds no artifact.</strong> It has files, but not the agent binary (<code>felhom-agent</code>) or the golden (<code>golden.tar.zst</code>) — an agent step bundle such as <code>0.156.1-step1</code> carries only the config bundle. Vouching it would point fresh installs at a package with no binary. Manifest unchanged. Choose the release version.</div>
|
||||
{{end}}
|
||||
{{if eq .Flash "artifact_sha_missing"}}
|
||||
<div class="flash flash-error"><strong>Refused: no checksum for a chosen version.</strong> The hub records the sha256 it reads from Gitea, and that lookup came back empty — so saving would vouch bytes nobody verified. Manifest unchanged.</div>
|
||||
{{end}}
|
||||
|
||||
Reference in new issue
Block a user