~/bend-docscommunity

src/control.bend checks

raw source on the hub · import bend-kube-runtime@0.5.1.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 106 · raw

Data

type Fold source · line 234 · 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 346 · raw

Data

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

type Spec source · line 353 · 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 Meter source · line 512 · raw

Data

What a reconcile tells the meter: add n to a counter, set a gauge, or (the health server) ask for every series in the Prometheus text format. labels is the inside of the braces, as kind="x",phase="y" ("" for none).

type Ctx source · line 527 · 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; meter: where the controller's own metrics go (Metrics.add, Metrics.set), None outside Kube.control.

Definitions

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

@+o:0x4c2d28cc22034a4133c2ab77cd30309e/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:0x4c2d28cc22034a4133c2ab77cd30309e/src/json.Json -> String

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

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

def Pred.deleting source · line 71 · raw

@d:Bool -> String

def Pred.print source · line 83 · raw

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

What the predicates see of an object, its uid, deletion and finalizers included: an object deleted and recreated under the same name (a new uid) always passes, whatever its generation; 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 87 · raw

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

def Pred.passes source · line 96 · raw

@ps:List<&2, Pred> -> @old:Maybe<&2, 0x4c2d28cc22034a4133c2ab77cd30309e/src/json.Json> -> @+new:0x4c2d28cc22034a4133c2ab77cd30309e/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 113 · raw

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

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

def Ref.names source · line 122 · raw

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

def Rel.near source · line 133 · raw

@+p:0x4c2d28cc22034a4133c2ab77cd30309e/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 137 · raw

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

def Rel.refs source · line 144 · raw

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

def Rel.all source · line 153 · raw

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

def Rel.key.go source · line 162 · 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 169 · raw

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

def Rel.label source · line 173 · raw

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

The primary a label names.

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

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

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

def Ref.group source · line 188 · raw

@av:String -> String

def Ref.is_owner source · line 192 · raw

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

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

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

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

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

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

def Rel.owners source · line 213 · raw

@+o:0x4c2d28cc22034a4133c2ab77cd30309e/src/json.Json -> @+res:0x4c2d28cc22034a4133c2ab77cd30309e/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 218 · raw

@r:Rel -> @+res:0x4c2d28cc22034a4133c2ab77cd30309e/src/core.Res -> @+o:0x4c2d28cc22034a4133c2ab77cd30309e/src/json.Json -> @+prim:0x4c2d28cc22034a4133c2ab77cd30309e/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 237 · raw

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

def Out.obj source · line 244 · raw

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

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

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

def Fold.prim source · line 274 · raw

@+ps:List<&2, Pred> -> @outs:List<&2, 0x4c2d28cc22034a4133c2ab77cd30309e/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 281 · raw

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

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

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

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

@+r:Rel -> @+res:0x4c2d28cc22034a4133c2ab77cd30309e/src/core.Res -> @ds:List<&2, String> -> @+s:0x4c2d28cc22034a4133c2ab77cd30309e/src/store.Store -> @+prim:0x4c2d28cc22034a4133c2ab77cd30309e/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 311 · raw

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

def Out.is_done source · line 320 · raw

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

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

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

def Fold.rel source · line 334 · raw

@+r:Rel -> @+res:0x4c2d28cc22034a4133c2ab77cd30309e/src/core.Res -> @outs:List<&2, 0x4c2d28cc22034a4133c2ab77cd30309e/src/watcher.Out> -> @+prim:0x4c2d28cc22034a4133c2ab77cd30309e/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 359 · raw

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

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

def Spec.label source · line 362 · raw

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

def Spec.field source · line 368 · raw

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

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

def Spec.filter source · line 373 · raw

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

def Spec.max source · line 379 · raw

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

At least 1.

def Spec.timeout source · line 388 · raw

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

A reconcile still running after ms is hung: the process logs it and exits (status 1), so the pod restarts, as a crash would. A reconcile in Bend cannot be cancelled, and freeing its key while it still runs would let the same key run twice.

def Spec.watches_where source · line 395 · raw

@s:Spec -> @a:0x4c2d28cc22034a4133c2ab77cd30309e/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 400 · raw

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

def Spec.owns source · line 405 · raw

@s:Spec -> @a:0x4c2d28cc22034a4133c2ab77cd30309e/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 408 · raw

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

def Spec.res source · line 413 · raw

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

def Spec.kind source · line 418 · raw

@s:Spec -> String

def Spec.preds source · line 421 · raw

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

def Spec.secs source · line 426 · raw

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

def Spec.max_of source · line 431 · raw

@s:Spec -> U32

def Spec.label_of source · line 436 · raw

@s:Spec -> String

def Spec.field_of source · line 441 · raw

@s:Spec -> String

def Spec.timeout_of source · line 446 · raw

@s:Spec -> U32

def Sec.rel source · line 451 · raw

@s:Sec -> Rel

def Sec.drop source · line 456 · raw

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

def Secs.set_last source · line 461 · raw

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

def Spec.drop source · line 475 · 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 480 · raw

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

def Out.trim source · line 487 · raw

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

def Out.trim_all source · line 499 · raw

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

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

def Ctx.cfg source · line 531 · raw

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

def Ctx.idx source · line 536 · raw

@c:Ctx -> U32

def Ctx.store source · line 541 · raw

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

def Ctx.with_fails source · line 546 · raw

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

def Ctx.meter source · line 551 · raw

@c:Ctx -> Maybe<&2, Chan(Meter)>

def Ctx.fails source · line 556 · raw

@c:Ctx -> U32

def Ctx.get source · line 562 · raw

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

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

def Ctx.list source · line 566 · raw

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

Every cached primary.

def Ctx.nth source · line 569 · raw

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

def Ctx.cache source · line 579 · raw

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

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

def Ctx.find source · line 585 · raw

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

A cached related object under a key.

def Ctx.all source · line 589 · raw

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

Every cached object of the n-th related watch.

def Owned.ctl source · line 592 · raw

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

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

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

def Owned.by source · line 609 · raw

@+o:0x4c2d28cc22034a4133c2ab77cd30309e/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 612 · raw

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

def Owned.pick source · line 619 · raw

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

def Ctx.children source · line 628 · raw

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

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