~/bend-docscommunity

src/control.bend checks

raw source on the hub · import bend-kube-runtime@0.3.0.0/src/control.bend as Control

6 imports
import Base
import ./json.bend as J
import ./core.bend as C
import ./config.bend as K
import ./watcher.bend as W
import ./store.bend as S

Types

type Pred source · line 39 · raw

Data

type Rel source · line 105 · raw

Data

type Fold source · line 233 · raw

Data

A batch of outputs folded into a cache: the cache after them, the keys they trigger, and the keys deleted.

type Sec source · line 345 · raw

Data

A related watch: what to watch (and its label selector), and how its objects map to primaries.

type Spec source · line 352 · raw

Data

A controller (kube-runtime's Controller::new(..).owns(..).watches(..)): the primary with its label and field selectors, the predicates its changes pass, the related watches, how many reconciles run at once, and how long one may run (timeout ms, 0 for no limit).

type Ctx source · line 512 · raw

Data

cfg: the client config; idx: the controller's index (0 for a lone controller); store: the primary's cache; caches: each related watch's, in the order they were added (Ctx.cache(c, 1) is the first); fails: how many times in a row this key's reconcile has failed (0 after a success), so a reconcile can escalate or give up.

Definitions

def Pred.part.gen source · line 46 · raw

@+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @g:String -> @none:Bool -> String

The part of an object a predicate looks at.

def Pred.part source · line 53 · raw

@p:Pred -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> String

def Pred.print.go source · line 64 · raw

@ps:List<&2, Pred> -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> String

def Pred.deleting source · line 71 · raw

@d:Bool -> String

def Pred.print source · line 82 · raw

@ps:List<&2, Pred> -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> String

What the predicates see of an object, its deletion and finalizers included: a finalizer added or removed (by this controller or another) always passes, so a controller that adds its finalizer and waits for the change is woken by it.

def Pred.changed source · line 86 · raw

@+ps:List<&2, Pred> -> @old:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+new:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> Bool

def Pred.passes source · line 95 · raw

@ps:List<&2, Pred> -> @old:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+new:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> Bool

Whether a change to the primary reconciles it: always without predicates; with them, when what they see differs from the cached object.

def Ref.names.any source · line 112 · raw

@xs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+name:String -> Bool

A field names the object: the string itself, or a list holding it.

def Ref.names source · line 121 · raw

@v:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+name:String -> Bool

def Rel.near source · line 132 · raw

@+p:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+ns:String -> Bool

A primary can relate to the object: one in the object's namespace, or any primary when either is cluster-scoped.

def Rel.ref.put source · line 136 · raw

@+p:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @hit:Bool -> @rest:List<&2, String> -> List<&2, String>

def Rel.refs source · line 143 · raw

@ps:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+path:List<&2, String> -> @+ns:String -> @+name:String -> List<&2, String>

def Rel.all source · line 152 · raw

@ps:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+ns:String -> List<&2, String>

def Rel.key.go source · line 161 · raw

@+ns:String -> @+name:String -> @namespaced:Bool -> String

The key of a primary named name, related to an object in namespace ns: in that namespace for a namespaced primary, by name alone otherwise.

def Rel.key source · line 168 · raw

@+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+ns:String -> @+name:String -> String

def Rel.label source · line 172 · raw

@m:Maybe<&2, String> -> @+ns:String -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> List<&2, String>

The primary a label names.

def Ref.group.go source · line 180 · raw

@ps:List<&2, String> -> String

The group of an apiVersion: "apps" of "apps/v1", "" of "v1".

def Ref.group source · line 187 · raw

@av:String -> String

def Ref.is_owner source · line 191 · raw

@+r:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> Bool

Whether an owner reference names the primary's kind, in its group.

def Rel.owner.put source · line 195 · raw

@+r:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+ns:String -> @hit:Bool -> @rest:List<&2, String> -> List<&2, String>

def Rel.owner.go source · line 203 · raw

@rs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+ns:String -> List<&2, String>

def Rel.owners source · line 212 · raw

@+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> List<&2, String>

The primaries an object's owner references name (kube-runtime's trigger_owners): the primary's kind in its API group.

def Rel.keys source · line 217 · raw

@r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> List<&2, String>

The primary keys a related object triggers; res is the primary's resource (its kind, group and scope).

def Fold.put source · line 236 · raw

@+key:String -> @hit:Bool -> @ks:List<&2, String> -> List<&2, String>

def Out.obj source · line 243 · raw

@o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

def Fold.prim.one source · line 254 · raw

@+ps:List<&2, Pred> -> @o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> @f:Fold -> Fold

def Fold.prim source · line 273 · raw

@+ps:List<&2, Pred> -> @outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> @f:Fold -> Fold

The primary's outputs: each applied or initially listed object reconciles when it passes the predicates, against the cache as it was before it. A deleted object, and one a relist no longer has, is gone: the queue forgets it.

def Fold.rel.keys source · line 280 · raw

@+r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @m:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> List<&2, String>

def Fold.rel.with source · line 288 · raw

@+r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @ks:List<&2, String> -> @m:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> Fold

def Fold.rel.dropped source · line 301 · raw

@+r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @ds:List<&2, String> -> @+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> List<&2, String>

The primaries of related objects a relist drops (deleted while the watch was down), by their cached versions.

def Fold.rel.one.go source · line 310 · raw

@+r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @ks:List<&2, String> -> @done:Bool -> Fold

def Out.is_done source · line 319 · raw

@o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> Bool

def Fold.rel.one source · line 326 · raw

@+r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @+o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @f:Fold -> Fold

def Fold.rel source · line 333 · raw

@+r:Rel -> @+res:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res -> @outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> @+prim:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @f:Fold -> Fold

A related watch's outputs: every change triggers the primaries its relation maps the object to, as cached before and as it is now.

def Spec.of source · line 358 · raw

@primary:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> Spec

A controller for primary: every change, no related watches, 8 at once, no timeout.

def Spec.label source · line 361 · raw

@s:Spec -> @l:String -> Spec

def Spec.field source · line 367 · raw

@s:Spec -> @f:String -> Spec

The primary's field selector (for example "metadata.name=x").

def Spec.filter source · line 372 · raw

@s:Spec -> @ps:List<&2, Pred> -> Spec

def Spec.max source · line 378 · raw

@s:Spec -> @n:U32 -> Spec

At least 1.

def Spec.timeout source · line 386 · raw

@s:Spec -> @ms:U32 -> Spec

A reconcile still running after ms is treated as failed (retried with backoff) and its key freed; the late run is not cancelled, so it must stay idempotent.

def Spec.watches_where source · line 393 · raw

@s:Spec -> @a:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @label:String -> @field:String -> @r:Rel -> Spec

Adds a related watch with label and field selectors ("" for none); the n-th one added is cache n (Ctx.cache).

def Spec.watches source · line 398 · raw

@s:Spec -> @a:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @r:Rel -> Spec

def Spec.owns source · line 403 · raw

@s:Spec -> @a:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> Spec

Objects of a's kind that the primary owns (ownerReferences to the primary's kind and group).

def Spec.primary source · line 406 · raw

@s:Spec -> 0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api

def Spec.res source · line 411 · raw

@s:Spec -> 0xd9b268abd125fd306c83ea43554e4f2c/src/core.Res

def Spec.kind source · line 416 · raw

@s:Spec -> String

def Spec.preds source · line 419 · raw

@s:Spec -> List<&2, Pred>

def Spec.secs source · line 424 · raw

@s:Spec -> List<&2, Sec>

def Spec.max_of source · line 429 · raw

@s:Spec -> U32

def Spec.label_of source · line 434 · raw

@s:Spec -> String

def Spec.field_of source · line 439 · raw

@s:Spec -> String

def Spec.timeout_of source · line 444 · raw

@s:Spec -> U32

def Sec.rel source · line 449 · raw

@s:Sec -> Rel

def Sec.drop source · line 454 · raw

@s:Sec -> List<&2, String>

def Secs.set_last source · line 459 · raw

@ss:List<&2, Sec> -> @+d:List<&2, String> -> List<&2, Sec>

def Spec.drop source · line 473 · raw

@s:Spec -> @fields:List<&2, String> -> Spec

Drops top-level fields (for example "data" and "stringData" of Secrets) from the objects of the related watch added last, before they are cached: a controller that only needs to know a referenced Secret changed then holds no Secret's data. Reconcile reads what it needs with Client.get.

def Out.trim.obj source · line 478 · raw

@fs:List<&2, String> -> @+x:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

def Out.trim source · line 485 · raw

@+fs:List<&2, String> -> @o:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out -> 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out

def Out.trim_all source · line 497 · raw

@+fs:List<&2, String> -> @os:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out>

A related watch's outputs with its dropped fields removed.

def Ctx.cfg source · line 515 · raw

@c:Ctx -> 0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config

def Ctx.idx source · line 520 · raw

@c:Ctx -> U32

def Ctx.store source · line 525 · raw

@c:Ctx -> 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store

def Ctx.with_fails source · line 530 · raw

@c:Ctx -> @n:U32 -> Ctx

def Ctx.fails source · line 535 · raw

@c:Ctx -> U32

def Ctx.get source · line 541 · raw

@c:Ctx -> @key:String -> Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

The cached primary under a key ("ns/name", or "name").

def Ctx.list source · line 545 · raw

@c:Ctx -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

Every cached primary.

def Ctx.nth source · line 548 · raw

@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @n:Nat -> 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store

def Ctx.cache source · line 558 · raw

@c:Ctx -> @n:U32 -> 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store

The cache of the n-th related watch (from 1); empty if there is none.

def Ctx.find source · line 564 · raw

@c:Ctx -> @n:U32 -> @key:String -> Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

A cached related object under a key.

def Ctx.all source · line 568 · raw

@c:Ctx -> @n:U32 -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

Every cached object of the n-th related watch.

def Owned.ctl source · line 571 · raw

@j:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> Bool

def Owned.uid.any source · line 578 · raw

@rs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+uid:String -> Bool

def Owned.by source · line 588 · raw

@+o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+uid:String -> Bool

Whether o's controller (the owner reference with controller: true) has this uid (metav1.IsControlledBy).

def Owned.keep source · line 591 · raw

@+x:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @hit:Bool -> @rest:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

def Owned.pick source · line 598 · raw

@xs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @+uid:String -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

def Ctx.children source · line 607 · raw

@c:Ctx -> @n:U32 -> @+owner:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json>

The cached objects of the n-th related watch that owner controls (by uid, with controller: true).