Watchman: say needs-operator from mesh-provisioner's provisions in waits, so the row the haves could not carry has its facts on the bus (issue 1954 D2)
Pins mesh-sdk 4a96793.
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
"git.novox.be/novox/mesh-sdk/go/provisions"
|
||||
|
||||
"mesh-delivery-watchman/internal/socket"
|
||||
"mesh-delivery-watchman/internal/watch"
|
||||
@@ -297,6 +298,29 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
if err := w.Rebuild(ask); err != nil {
|
||||
return err
|
||||
}
|
||||
// The seat mesh-provisioner's provisions (ADR 0570 §7): a provision in waits is needs-operator. Read before the findings are
|
||||
// reconciled when the bucket is there; bound once it appears when it is not (mesh-provisioner comes in its own delivery).
|
||||
provisionsWatch := func(kv jetstream.KeyValue) (jetstream.KeyWatcher, error) {
|
||||
return settle(ctx, kv, func(e jetstream.KeyValueEntry) { w.Provision(e.Key(), e.Value(), opOf(e)) })
|
||||
}
|
||||
var provWatch jetstream.KeyWatcher
|
||||
if kv, err := js.KeyValue(ctx, provisions.ProvisionsBucket); err == nil {
|
||||
if provWatch, err = provisionsWatch(kv); err != nil {
|
||||
process.NotWatched(logger.Printf, provisions.ProvisionsBucket, err, "no provision waiting for the operator is said until the watchman starts again")
|
||||
}
|
||||
} else {
|
||||
process.AwaitBucket(ctx, js, conn, provisions.ProvisionsBucket, "no provision waiting for the operator is said",
|
||||
logger.Printf).Ready(func(kv jetstream.KeyValue) {
|
||||
pw, err := provisionsWatch(kv)
|
||||
if err != nil {
|
||||
process.NotWatched(logger.Printf, provisions.ProvisionsBucket, err, "no provision waiting for the operator is said until the watchman starts again")
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
_ = follow(ctx, pw, func(e jetstream.KeyValueEntry) { w.Provision(e.Key(), e.Value(), opOf(e)) })
|
||||
}()
|
||||
})
|
||||
}
|
||||
dead := &deadKeeper{ctx: ctx, js: js, w: w, logf: logger.Printf}
|
||||
w.SetRecount(dead.count)
|
||||
dead.count()
|
||||
@@ -309,6 +333,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
}
|
||||
|
||||
errs := make(chan error, 8)
|
||||
if provWatch != nil {
|
||||
go func() {
|
||||
errs <- follow(ctx, provWatch, func(e jetstream.KeyValueEntry) { w.Provision(e.Key(), e.Value(), opOf(e)) })
|
||||
}()
|
||||
}
|
||||
if kvs.lease != nil {
|
||||
lw, err := kvs.lease.Watch(ctx, buscompose.ControllerLeaseKey)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user