Skip to content
~/supporterino

Three of six Kener resources have no stable key

3 min read

typescript · cli

← all posts

kener-ctl manages a Kener status page from YAML, and three of the six resource types cannot be found again by name. That one asymmetry decided the CLI's design.

What the API hands back

A monitor carries a tag, a page carries a path, an alert trigger carries a name. Those come from the manifest, so apply looks up the remote object by that key and patches it. There is no local state, and a fresh clone with the same manifests behaves identically to my laptop:

kind: Monitor
metadata:
  tag: gitlab
spec:
  name: GitLab
  type: API
  cronSchedule: "*/5 * * * *"
  typeData:
    _type: API
    url: https://git.example.internal/health
    method: GET
    timeout: 10000
    eval: response.status === 200

Alert configs, incidents and maintenances are created with an integer ID and addressed by that ID. The create call returns id: 12, and nothing in my manifest holds 12.

The two options

Recreate on every apply, or remember the mapping. Recreating means the status page gets a new incident instead of the one that is still open, with a new timeline and a new start time, which is the opposite of what an incident record is for.

So the CLI writes ~/.config/kener-ctl/state/<context>.json, mapping manifest name to remote ID. apply maintains it; I never touch it. Contexts are separate files because staging and production assign different IDs to the same manifest.

What the mapping buys

A second apply patches the incident it created the first time. plan can tell "this manifest changed" from "this resource is new", which is the difference between a diff I can read in review and one I have to re-derive by hand.

The manifest above is the whole interface: kener-ctl plan prints what would change, kener-ctl apply does it, and kener-ctl pull walks the other way when an instance was built in the UI before it had manifests.

What it costs

The mapping is per machine and per context, and it is not in git. A clean CI runner has none of it, so an apply step in a pipeline needs the file restored as an artifact, which makes the pipeline stateful in a way kubectl apply never is. That is the price I have not paid yet: today the CLI runs from my laptop, so the state file and I are in the same place.

Losing the file is survivable but not free. The instance survives, and pull exports its current resources back into manifests, so the manifests can always be rebuilt from the server. What is gone with the file is the name-to-ID history, and git never had it.

Editing through the UI moves the two sides apart. plan shows the difference and apply closes it, which is the behaviour I want, and it also means the UI is only ever a read view of anything I intend to keep.

What I would do differently

I would ask Kener for a natural key on those three types — a slug I choose, sent on create. Every alternative on my side is a cache of something the server already knows, and caches go stale in ways that look like drift.

Until Kener lets me pick a key for those three types, every apply carries a piece of memory git cannot see, and moving that memory into a pipeline is the next piece of work.