mesh-delivery-builder: a standing version-unreleased keeps its words past the bound (issue 1984, review round 1)
The past-bound branch of arm is reached at every look, and raised version-unreleased again each time as "nothing within 10m0s of its build", writing over the words it was left with (a holder's refusal, ADR 0674 §3; design 47 G A-490j). Once the bound has passed it now raises only when the held writer holds no version-unreleased of the module (Held, design 47 G A-38). Builds: issue 1984 note 8 (1984/AC5), design 47 G §369, A-38, A-490j
This commit is contained in:
@@ -19,10 +19,11 @@ import (
|
|||||||
// A-29); its `findings-asked` subject is the seat's, from the generated contract (A-17).
|
// A-29); its `findings-asked` subject is the seat's, from the generated contract (A-17).
|
||||||
type heldWriter = views.HeldWriter[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]
|
type heldWriter = views.HeldWriter[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]
|
||||||
|
|
||||||
// findingWriter is the part of the held writer the builder's findings use.
|
// findingWriter is the part of the held writer the builder's findings use; Held answers the findings it holds (design 47 G A-38).
|
||||||
type findingWriter interface {
|
type findingWriter interface {
|
||||||
Write(ctx context.Context, f mcseat.Finding) error
|
Write(ctx context.Context, f mcseat.Finding) error
|
||||||
Clear(ctx context.Context, scope, id, kind, why string) error
|
Clear(ctx context.Context, scope, id, kind, why string) error
|
||||||
|
Held() []mcseat.Finding
|
||||||
}
|
}
|
||||||
|
|
||||||
// findings writes the builder's findings through its held finding writer (design 47 G §689, A-29): a finding written before the
|
// findings writes the builder's findings through its held finding writer (design 47 G §689, A-29): a finding written before the
|
||||||
@@ -113,6 +114,19 @@ func (f *findings) raise(ctx context.Context, fd finding) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stands says whether the writer holds the finding of kind about scope and id (design 47 G A-38): it is raised and not cleared.
|
||||||
|
func (f *findings) stands(kind, scope, id string) bool {
|
||||||
|
if f.w == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, x := range f.w.Held() {
|
||||||
|
if x.Kind == kind && x.Scope == scope && x.ID == keyID(id) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// clear clears the finding of kind about scope and id; one not there is nothing to clear.
|
// clear clears the finding of kind about scope and id; one not there is nothing to clear.
|
||||||
func (f *findings) clear(ctx context.Context, kind, scope, id string) {
|
func (f *findings) clear(ctx context.Context, kind, scope, id string) {
|
||||||
if f.w == nil {
|
if f.w == nil {
|
||||||
|
|||||||
@@ -534,6 +534,17 @@ func (m *memFindings) Write(_ context.Context, f mcseat.Finding) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Held answers the findings kept, as the held writer answers those it holds.
|
||||||
|
func (m *memFindings) Held() []mcseat.Finding {
|
||||||
|
var out []mcseat.Finding
|
||||||
|
for _, v := range m.vals {
|
||||||
|
if f, err := decodeFinding(v); err == nil {
|
||||||
|
out = append(out, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// Clear deletes the finding of scope, id and kind.
|
// Clear deletes the finding of scope, id and kind.
|
||||||
func (m *memFindings) Clear(_ context.Context, scope, id, kind, _ string) error {
|
func (m *memFindings) Clear(_ context.Context, scope, id, kind, _ string) error {
|
||||||
delete(m.vals, views.FindingKey(scope, id, kind))
|
delete(m.vals, views.FindingKey(scope, id, kind))
|
||||||
|
|||||||
@@ -246,13 +246,14 @@ func (rv *reservations) now() time.Time {
|
|||||||
|
|
||||||
// arm arms a built reservation's publish's bound, a key of the state bounds with its own time to live, counted from its build's
|
// arm arms a built reservation's publish's bound, a key of the state bounds with its own time to live, counted from its build's
|
||||||
// end (BuiltAt): its end with the reservation standing is version-unreleased. One armed already stands; at a look or the start
|
// end (BuiltAt): its end with the reservation standing is version-unreleased. One armed already stands; at a look or the start
|
||||||
// after the bound passed, a reservation left with an artifact unpublished is version-unreleased at once and its bound is not armed
|
// after the bound passed, a reservation left with an artifact unpublished is version-unreleased at once, unless the module's
|
||||||
// again (issue 1984 note 8, 1984/AC5); one with every artifact published waits for its version-released.
|
// version-unreleased stands already, which keeps the words it was raised with (ADR 0674 §3), and its bound is not armed again
|
||||||
|
// (issue 1984 note 8, 1984/AC5); one with every artifact published waits for its version-released.
|
||||||
func (rv *reservations) arm(ctx context.Context, v versions.ReservedVersion) {
|
func (rv *reservations) arm(ctx context.Context, v versions.ReservedVersion) {
|
||||||
ends := v.BuiltAt.Add(rv.bound)
|
ends := v.BuiltAt.Add(rv.bound)
|
||||||
left := ends.Sub(rv.now())
|
left := ends.Sub(rv.now())
|
||||||
if left <= 0 {
|
if left <= 0 {
|
||||||
if len(v.Missing()) > 0 {
|
if len(v.Missing()) > 0 && !rv.found.stands(versions.VersionUnreleased, meshconditionsclient.ScopeModule, v.Module) {
|
||||||
rv.unreleased(ctx, v, fmt.Sprintf("nothing within %s of its build", rv.bound))
|
rv.unreleased(ctx, v, fmt.Sprintf("nothing within %s of its build", rv.bound))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -512,19 +512,28 @@ func TestABuiltReservationIsTakenInFromItsState(t *testing.T) {
|
|||||||
for _, when := range []string{"a look", "the start"} {
|
for _, when := range []string{"a look", "the start"} {
|
||||||
module := map[string]string{"a look": "pastlook", "the start": "paststart"}[when]
|
module := map[string]string{"a look": "pastlook", "the start": "paststart"}[when]
|
||||||
v := recordedLost(module, now.Add(-versions.UnreleasedBound-time.Minute))
|
v := recordedLost(module, now.Add(-versions.UnreleasedBound-time.Minute))
|
||||||
if when == "a look" {
|
takeIn := func() {
|
||||||
if err := rv.Built(ctx, module, v.Version, v.Artifacts, nil); err != nil {
|
if when == "a look" {
|
||||||
t.Fatal(err)
|
if err := rv.Built(ctx, module, v.Version, v.Artifacts, nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rv.releasedAtStart(ctx)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
rv.releasedAtStart(ctx)
|
|
||||||
}
|
}
|
||||||
|
takeIn()
|
||||||
if got := unreleased(module); !strings.Contains(got, module+":b unpublished") || !strings.Contains(got, v.Version) {
|
if got := unreleased(module); !strings.Contains(got, module+":b unpublished") || !strings.Contains(got, v.Version) {
|
||||||
t.Errorf("at %s, a built reservation left unmarked past its bound raised %q, want version-unreleased naming %s:b of %s", when, got, module, v.Version)
|
t.Errorf("at %s, a built reservation left unmarked past its bound raised %q, want version-unreleased naming %s:b of %s", when, got, module, v.Version)
|
||||||
}
|
}
|
||||||
if bounds.keys[versions.ReservedBoundKey(module, "0.1")] {
|
if bounds.keys[versions.ReservedBoundKey(module, "0.1")] {
|
||||||
t.Errorf("at %s, the bound of a reservation past it was armed again", when)
|
t.Errorf("at %s, the bound of a reservation past it was armed again", when)
|
||||||
}
|
}
|
||||||
|
// One standing is left as it was raised: the next take-in does not write it again over the holder's words (ADR 0674 §3).
|
||||||
|
rv.unreleasedWords(ctx, v, "the holder refused the publish again: no space left")
|
||||||
|
takeIn()
|
||||||
|
if got := unreleased(module); !strings.Contains(got, "no space left") || strings.Contains(got, "nothing within") {
|
||||||
|
t.Errorf("at %s again, version-unreleased reads %q, want the holder's words it was left with", when, got)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user