Land feature 57's controller work on its release branch
The controller plans config, templates and moved providers' provisions, hands bus accounts to the vault and judges the new manifest words, on the feature's SDK and node-engine validator (feature 57, config and provisioning).
This commit is contained in:
+32
-8
@@ -375,6 +375,13 @@ func ReadCheckBuilds(ctx context.Context, js *broker.JetStream, seat string, pul
|
||||
for _, p := range pulls {
|
||||
wanted[p] = true
|
||||
}
|
||||
return readCheckBuilds(ctx, js, seat, since, func(p PullRef, _ CheckBuilt) bool { return wanted[p] })
|
||||
}
|
||||
|
||||
// readCheckBuilds is every build the seat's checks said they made, or kept, that wanted takes. A kept build is named
|
||||
// as the check's that built it (novox/hq issue 703): the record under its key is that check's.
|
||||
func readCheckBuilds(ctx context.Context, js *broker.JetStream, seat string, since time.Time,
|
||||
wanted func(PullRef, CheckBuilt) bool) ([]CheckedBuild, error) {
|
||||
subject := BuildOutcomeOf(seat)
|
||||
sub, err := js.Context().PullSubscribe(subject, "",
|
||||
nats.BindStream(broker.EventsStream), nats.StartTime(since), nats.AckNone())
|
||||
@@ -402,12 +409,13 @@ func ReadCheckBuilds(ctx context.Context, js *broker.JetStream, seat string, pul
|
||||
continue
|
||||
}
|
||||
pull := PullRef{Owner: r.Checked.Owner, Repo: r.Checked.Repo, Number: r.Checked.Number}
|
||||
if !wanted[pull] {
|
||||
continue
|
||||
}
|
||||
for _, b := range r.Check.Built {
|
||||
if b.NotBuilt == "" && b.Key != "" {
|
||||
out = append(out, CheckedBuild{Pull: pull, Check: r.ID, Built: b})
|
||||
if b.NotBuilt == "" && b.Key != "" && wanted(pull, b) {
|
||||
check := r.ID
|
||||
if b.Kept != "" {
|
||||
check = b.Kept
|
||||
}
|
||||
out = append(out, CheckedBuild{Pull: pull, Check: check, Head: r.Check.Head, Built: b})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -609,13 +617,29 @@ func PausedSaid(js *broker.JetStream, seat string, nodes []string) (map[string]H
|
||||
// (design 33 §4: a mesh seat's verb carries no machine), and reads its answer (novox/hq ADR 0239: the
|
||||
// delivery's owner's `stalled` and `close`).
|
||||
func AskMeshSeatTool(ctx context.Context, conn *nats.Conn, seat, verb string, args any, timeout time.Duration) (Answer, error) {
|
||||
return askMeshSeatToolAt(ctx, conn, SeatToolSubject(seat, verb), seat, verb, args, timeout)
|
||||
}
|
||||
|
||||
// AskMeshSeatToolAs is AskMeshSeatTool in the caller's own name: on the subject that names its caller (novox/hq
|
||||
// issue 365), which the bus lets only that user publish, so the holder knows who asks from the subject alone —
|
||||
// how the vault takes a value from the controller and nobody else (design 57's V2, issue 675).
|
||||
func AskMeshSeatToolAs(ctx context.Context, conn *nats.Conn, caller, seat, verb string, args any,
|
||||
timeout time.Duration) (Answer, error) {
|
||||
subject := broker.CalledSubject(SeatToolSubject(seat, verb), caller)
|
||||
if subject == "" {
|
||||
return Answer{}, fmt.Errorf("%q cannot ask %s.%s in its own name: it is not a bus user's name", caller, seat, verb)
|
||||
}
|
||||
return askMeshSeatToolAt(ctx, conn, subject, seat, verb, args, timeout)
|
||||
}
|
||||
|
||||
func askMeshSeatToolAt(ctx context.Context, conn *nats.Conn, subject, seat, verb string, args any,
|
||||
timeout time.Duration) (Answer, error) {
|
||||
body, err := json.Marshal(args)
|
||||
if err != nil {
|
||||
return Answer{}, err
|
||||
}
|
||||
asking, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
subject := SeatToolSubject(seat, verb)
|
||||
refused, stop := refusalsOf(conn, subject)
|
||||
defer stop()
|
||||
type replied struct {
|
||||
@@ -633,8 +657,8 @@ func AskMeshSeatTool(ctx context.Context, conn *nats.Conn, seat, verb string, ar
|
||||
reply, err = r.msg, r.err
|
||||
case why := <-refused:
|
||||
cancel()
|
||||
return Answer{}, fmt.Errorf("the bus refused the controller asking %s.%s — its grants do not name %s: %v",
|
||||
seat, verb, subject, why)
|
||||
return Answer{}, fmt.Errorf("%w: the bus refused the controller asking %s.%s — its grants do not name %s: %v",
|
||||
ErrGrantRefused, seat, verb, subject, why)
|
||||
}
|
||||
switch {
|
||||
case errors.Is(err, nats.ErrNoResponders):
|
||||
|
||||
Reference in New Issue
Block a user