src/helpers.bend relies on unsafe/foreign
raw source on the hub · import bend-kube-runtime@0.5.3.0/src/helpers.bend as Helpers
12 imports
import Base import ./json.bend as J import ./core.bend as C import ./config.bend as K import ./client.bend as Cl import ./queue.bend as Q import ./finalizer.bend as F import ./control.bend as X import ./sys.bend as Y import ./time.bend as T import ./log.bend as L import ./utf8.bend as U
Types
type Stamp source · line 150 · raw
Data
When, a unique suffix, and who reports (the pod: HOSTNAME, else the controller's name).
Stamp@now:String -> @id:String -> @inst:String -> Stamp
Definitions
def Fin.added source · line 23 · raw
@r:Result<&2, &2, 0x4b19fea9f3c794558ea41a0289840d6a/src/client.KErr, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
def Fin.removed source · line 32 · raw
@a:0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action -> @r:Result<&2, &2, 0x4b19fea9f3c794558ea41a0289840d6a/src/client.KErr, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
def Fin.cleaned.go source · line 42 · raw
@+cfg:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> @api:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Api -> @name:String -> @patch:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+a:0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action -> @keep:Bool -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
After a cleanup: a failed one (Retry, RetryIn) or an unfinished one (Hold) keeps the finalizer and runs again; a finished one removes it, through a patch that tests it is still ours.
def Fin.cleaned source · line 51 · raw
@+cfg:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> @api:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Api -> @name:String -> @patch:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+a:0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
def Event.note source · line 103 · raw
@note:String -> String
The note, cut to the API's 1 kB (by UTF-8 bytes; a character cut in two becomes U+FFFD).
def Event.regarding source · line 106 · raw
@+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+r:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Res -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json
def Event.kind source · line 111 · raw
@warn:Bool -> String
def Event.ns.go source · line 118 · raw
@ns:String -> @empty:Bool -> String
def Event.ns source · line 126 · raw
@+ns:String -> String
Cluster-scoped objects record their events in "default".
def Event.body source · line 131 · raw
@+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+r:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Res -> @warn:Bool -> @reason:String -> @action:String -> @note:String -> @+controller:String -> @+now:String -> @id:String -> @inst:String -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json
The Event is named "<object>.<unix microseconds>", as client-go names them "<object>.<unix nanoseconds in hex>".
def Event.sent source · line 141 · raw
@r:Result<&2, &2, 0x4b19fea9f3c794558ea41a0289840d6a/src/client.KErr, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> IO(Unit)
def Event.inst source · line 153 · raw
@h:Result<&1, &1, Pair(U32, String), String> -> @+controller:String -> String
def Event.stamp source · line 160 · raw
@+w:0x4b19fea9f3c794558ea41a0289840d6a/src/time.Wall -> @inst:String -> Stamp
def Event.post source · line 163 · raw
@+cfg:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> @+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+r:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Res -> @warn:Bool -> @reason:String -> @action:String -> @note:String -> @controller:String -> @st:Stamp -> IO(Unit)
def Event.publish source · line 174 · raw
@+cfg:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> @+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+r:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Res -> @warn:Bool -> @reason:String -> @action:String -> @note:String -> @+controller:String -> IO(Unit)
Records an Event about o (of resource r). A failure is logged, never raised: events are best effort, as client-go's are.
def Metrics.send source · line 184 · raw
@m:Maybe<&2, Chan(0x4b19fea9f3c794558ea41a0289840d6a/src/control.Meter)> -> @x:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Meter -> IO(Unit)
def Metrics.add source · line 194 · raw
@c:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> @name:String -> @labels:String -> @n:U32 -> IO(Unit)
Adds n to the controller's counter name (labels: the inside of the
braces, as kind="x", "" for none); /metrics serves it beside
bend-kube's own.
def Metrics.drop source · line 200 · raw
@c:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> @name:String -> @labels:String -> IO(Unit)
Drops one series (by name and labels), as when the object its labels name is deleted: series labeled by object live until dropped, so drop them to keep /metrics bounded by the live objects.
def Metrics.set source · line 204 · raw
@c:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> @name:String -> @labels:String -> @v:U32 -> IO(Unit)
Sets the controller's gauge name.
Templates
template Fin.run.go source · line 54 · raw
@-apply:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @-cleanup:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @+cfg:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> @+api:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Api -> @+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @s:0x4b19fea9f3c794558ea41a0289840d6a/src/finalizer.FState -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
template Finalizer.run source · line 70 · raw
@-apply:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @-cleanup:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @+cfg:0x4b19fea9f3c794558ea41a0289840d6a/src/config.Config -> @+api:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Api -> @name:String -> @+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
Reconciles o under the finalizer called name (kube-runtime's finalizer): apply while it lives, cleanup once it is deleted. Both must be idempotent; a cleanup that answers Retry keeps the object alive.
template Fin.ctl.go source · line 75 · raw
@-apply:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @-cleanup:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @+ctx:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> @+api:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Api -> @+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @s:0x4b19fea9f3c794558ea41a0289840d6a/src/finalizer.FState -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
template Finalizer.control source · line 93 · raw
@-apply:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @-cleanup:(@_:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @_:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)) -> @+ctx:0x4b19fea9f3c794558ea41a0289840d6a/src/control.Ctx -> @+api:0x4b19fea9f3c794558ea41a0289840d6a/src/core.Api -> @name:String -> @+o:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> IO(0x4b19fea9f3c794558ea41a0289840d6a/src/queue.Action)
Finalizer.run for Kube.control: apply and cleanup get the reconcile context (config, caches, failure count). Adding the finalizer changes metadata.finalizers, which every predicate passes, so the reconcile that follows sees it even under X.PGeneration.