Files
ilkerandClaude Opus 5 6dc2826c17 hpcod: the life of an application, carried past the moment it is published
Publishing worked; everything after it did not. Four things were wrong
and each was silent in its own way.

Versions were compared as text, so asking for "gromacs" with 2024.9 and
2024.10 published returned 2024.9. The whole meaning of an unversioned
reference is "the newest one", and it was a wrong answer rather than a
missing one - invisible until somebody noticed they had spent a week on
last year's build.

A recipe could hold one version while the catalogue could hold many, so
an update either destroyed what it replaced or grew a parallel
directory sharing nothing with the first. Recipes now carry a list, and
the single-version form is read into the same shape, so nothing
downstream knows which was written.

An image was named by a mutable tag. Whoever repushes gromacs:2024.4
changed what every rebuilt cluster received, silently, and the record
meant to freeze the cluster froze only its opinion of it. Two hashes
are now recorded because they are checkable in different places: the
manifest digest answers "has this moved" from the control plane, and
the SIF hash is the only one a head can check with no network and no
credential - which matters, because the head is where a wrong image
does harm. Pulling by digest is deliberately not done: whether this
Apptainer accepts an @sha256: reference is not established, and a
provision failing at its last task over untested syntax would be worse
than the problem.

Module and binaries had been in the catalogue since it was written and
were read by nothing - Module was referenced nowhere in the program. So
a tenant was handed /opt/apps/gromacs.sif and left to work out
Apptainer. They now become a wrapper per binary and an Lmod modulefile,
and the answer is `module load gromacs`. Whether to pass --nv is
decided on the node at run time: passing it without a driver fails
outright, and omitting it where there is one leaves the job on the CPU
saying nothing at all, which is the dangerous one.

Four states replace `published:`. A withdrawn entry stays in the
catalogue file, because dropping it would make it indistinguishable
from one that never existed - and that difference is what an operator
needs when a cluster is found still holding it. A pinned reference to
one is refused with the recorded reason instead of "no application",
which would send the user hunting for a typo in a correct name.

The portal re-reads the catalogue when it changes, so publishing an
application no longer needs a restart - the step that is invisible when
forgotten. C20 ships the catalogue, which nothing did.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 10:25:54 +02:00

89 lines
2.8 KiB
Go

package catalog
import (
"strings"
"testing"
)
func withdrawnCatalogue() *Catalog {
return &Catalog{Apps: []App{
{Name: "gromacs", Version: "2024.4", Image: "oras://r/g:2024.4", StatusField: "deprecated",
StatusNote: "superseded by 2025.1"},
{Name: "gromacs", Version: "2024.9", Image: "oras://r/g:2024.9", StatusField: "withdrawn",
StatusNote: "CVE-2025-0001 in the bundled FFTW"},
{Name: "gromacs", Version: "2023.1", Image: "oras://r/g:2023.1"}, // no status: available
{Name: "busybox", Version: "musl", Image: "oras://r/b:musl"},
}}
}
// Withdrawing the newest build must not be undone by the next person who
// types the bare name.
func TestAnUnversionedReferenceSkipsAWithdrawnVersion(t *testing.T) {
c := withdrawnCatalogue()
got, ok := c.Lookup("gromacs")
if !ok {
t.Fatal("gromacs did not resolve at all")
}
if got.Version != "2024.4" {
t.Errorf("gromacs resolved to %q; 2024.9 is withdrawn and 2024.4 is the newest offered",
got.Version)
}
}
// Deprecated is offered. It means a newer one exists, not that this one has
// stopped working, and refusing it would break every deliberate pin.
func TestADeprecatedVersionCanStillBeAskedForByName(t *testing.T) {
c := withdrawnCatalogue()
apps, _, err := c.Resolve([]string{"gromacs:2024.4"})
if err != nil {
t.Fatalf("a deprecated version was refused: %v", err)
}
if len(apps) != 1 || apps[0].Version != "2024.4" {
t.Errorf("resolved to %+v", apps)
}
}
// A withdrawn version is refused, and the refusal says why. "No such
// application" would send the user hunting for a typo in a correct name.
func TestAWithdrawnVersionIsRefusedWithItsReason(t *testing.T) {
c := withdrawnCatalogue()
_, _, err := c.Resolve([]string{"gromacs:2024.9"})
if err == nil {
t.Fatal("a withdrawn version was accepted")
}
for _, want := range []string{"withdrawn", "CVE-2025-0001"} {
if !strings.Contains(err.Error(), want) {
t.Errorf("the refusal does not mention %q: %v", want, err)
}
}
if strings.Contains(err.Error(), "no application") {
t.Errorf("the refusal reads as a missing name rather than a withdrawal: %v", err)
}
}
// Every catalogue generated before status existed says nothing at all.
// Reading that as "not offered" would empty the plan page the moment this
// shipped.
func TestNoStatusMeansAvailable(t *testing.T) {
a := App{Name: "busybox", Version: "musl"}
if a.Status() != StatusAvailable {
t.Errorf("an entry with no status is %q, want available", a.Status())
}
if !a.Offered() {
t.Error("an entry with no status is not offered")
}
}
func TestWithdrawnAndDraftAreNotOffered(t *testing.T) {
for _, s := range []string{"withdrawn", "draft"} {
if (App{StatusField: s}).Offered() {
t.Errorf("%s is offered", s)
}
}
for _, s := range []string{"available", "deprecated", ""} {
if !(App{StatusField: s}).Offered() {
t.Errorf("%q is not offered", s)
}
}
}