Let platform manifests go only on a confirmed collect, and copy again what a sweep took
An unrecorded index or a copy in progress can name a platform the records do not see, so only a person's collect, after its dry run, takes an index's platforms, and only once every kept index of each repository it touches was read. A copy missing a platform is copied again, and a copy a build holds again is no longer recorded as collected (review of #144).
This commit is contained in:
@@ -179,3 +179,33 @@ func TestTheCopiesTheRecordsAlreadyNameAreRecorded(t *testing.T) {
|
||||
t.Fatalf("recorded %s by %s", reference, build)
|
||||
}
|
||||
}
|
||||
|
||||
// A copy let go of and copied again by a later build is held again: its record is back, and the sweep
|
||||
// decides about it as before.
|
||||
func TestACopyLetGoOfAndCopiedAgainIsHeldAgain(t *testing.T) {
|
||||
inv := fresh(t)
|
||||
ctx := context.Background()
|
||||
holding(t, inv, "proxy")
|
||||
golang := mirrorRef("upstream/docker.io/library/golang", 1)
|
||||
builtOn(t, inv, "b01", "proxy", 1, []string{golang}, golang)
|
||||
if err := inv.MarkCollected(ctx, []string{golang}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if s := stateOf(t, inv, golang); s.State != ArtifactCollected {
|
||||
t.Fatalf("a let-go copy reads %+v", s)
|
||||
}
|
||||
builtOn(t, inv, "b02", "proxy", 2, []string{golang}, golang)
|
||||
if s := stateOf(t, inv, golang); s.State != ArtifactKept || !slices.Equal(s.Why, []string{KeptStoodOn}) {
|
||||
t.Fatalf("a copy copied again reads %+v; want kept again", s)
|
||||
}
|
||||
// A person's record never undoes a collection: only a build that copied it says it is there.
|
||||
if err := inv.MarkCollected(ctx, []string{golang}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := inv.RecordMirrored(ctx, "", "again", []string{golang}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if s := stateOf(t, inv, golang); s.State != ArtifactCollected {
|
||||
t.Fatalf("a person's record brought a collected copy back: %+v", s)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user