Repository navigation
bab 0.4.25
Changed
-
An agent keeps one Datadog application key, where bab has somewhere to keep it. A lease
was a new application key, so Datadog recorded a key made and a key deleted every hour for
every agent, and told the service account's owner each time. Datadog's keys do not expire,
and the hour was always bab's: the lease. So with a key store configured (below), an agent
has one key per Datadog connection, namedbab-<agent>, and each lease on everything it
holds there hands out that same key. Nothing else about a lease changes: it is an hour, it
is a row in the ledger, and when it runs out the next call asks for another. The key is
deleted, and the next one made with the new scopes, when what the agent may do there
changes: a permission approved, a grant revoked or lapsed, the agent removed, Datadog
disconnected. A revoke still deletes the key in the agent's hand at once. A key Datadog
refuses to delete at that moment is never handed out again. Every kept key is checked
against the ledger after a lease is given (any agent's lease, at most every five minutes,
after the answer is sent, so a slow Datadog never slows a lease) and onPOST /sweep: one whose delete was
refused, or that carries a scope its agent no longer holds because a grant ran out while
the agent was not asking, is deleted then. A
lease that names its permissions (permissionsonPOST /leases) still gets a key of its
own, deleted with the lease. The wait for Datadog to accept a new key (below) is now paid
once per key, not once an hour.Without a key store nothing changes: a key per lease, as before. bab does not keep a
secret in its ledger, and a key held only in memory would be remade for every agent at
each restart, with the old ones left behind.
Added
-
A key store: bab keeps a vendor key in the room's secret store (sero). Four settings
turn it on, all or none:BAB_SERO_URL,BAB_SERO_AUDIENCE(the audience sero's machine
lane pins to bab's own identity; it needs one of its own, not another caller's),
BAB_SERO_NAMESPACE(the namespace that caller is pinned to) andBAB_SERO_ACTING_EMAIL
(the address sero records beside each write; no person is behind these writes, so name the
service's own). bab writes each agent's key as one value atapps/bab/datadog-keys
(BAB_SERO_APPrenames the application) and asks sero once to deliver that path to its own
namespace as the Secretbab-datadog-keys, re-read every minute. sero never returns a
value, so bab reads its keys back from that Secret, mounted atBAB_DATADOG_KEYS_DIR
(default/etc/bab/datadog-keys; mount itoptional: true, it does not exist before the
first key). bab only needs the mount after a restart. A key read from it is checked with
Datadog once before it is handed out, because the mount lags a delete by about a minute.
A key the store would not take is used for its one lease and deleted with it. bab tells
sero the namespace it runs in when it asks for the delivery, and asks again (at most once
a minute) whenever the store holds a key the mount does not show, so a delivery that was
refused once does not leave a kept key out of reach.An agent never has two kept keys. Only its record knows a kept key's id, so a second one
would leave the first in Datadog for good. Datadog itself keeps one application key per
name on a service account (a second create answers 409; measured). So whenever bab cannot
tell whether a kept key is already standing, the lease gets a key of its own, deleted
with the lease, and the log says why once: after a restart until the mount shows the
store's record, while the store does not answer, while Datadog will not say whether a key
read back is still there, and when Datadog already has a key under that name that bab
does not hold. A connection moved to another service account deletes the kept keys on the
old one while its management key still can, and names them in the log when it cannot. An
agent with a dot in its name gets a key per lease.Limits. One bab process, as the lease cache already assumes. A kept key is checked
against the ledger only when some lease is asked for, or on a sweep. A key under an
agent's kept name that bab does not hold has to be deleted in Datadog by a person; the
log names it. Two rooms that mint on one Datadog service account and each have an agent
of the same name share that agent's kept name, and the second room's agent gets a key per
lease. -
A lease is checked against the grants again once it is recorded. A revoke or an
approval that landed while the credential was made found no lease to end, and the one
made a moment later carried what had just been taken back (for a kept Datadog key, for as
long as the key was kept), or was a key the approval had just deleted. Now the grants, and
for Datadog whether the key is still one to hand out, are asked again after the lease is
recorded; a change from then on finds the lease and ends it. When the answer changed the
lease is ended at once and refused (409, "no lease: access changed while this lease was
made; ask again"), and the ledger recordslease.failed.
When the store cannot answer the second check the lease is refused with 503. This holds
for every vendor.
Fixed
- A Datadog lease is not handed out before Datadog accepts its key. Datadog refuses a new
application key for a moment after it creates it: measured from the service's own pod, five
keys of five answered 403 for 0.7 to 1.8 seconds after the create returned (3.1 in a later run), then 200, and
never 403 again. A lease handed out inside that moment failed the agent's first call, and
read as a missing permission. The minter now reads with the new key until Datadog answers
200, then hands it out. The read is one the key's own scopes allow (monitors_read,
events_readortimeseries_query); a key that carries none of those is held for 2.5
seconds instead. The wait is bounded at 6 seconds. A key Datadog still has not accepted by
then is handed out anyway, with a note on the lease and a warning in the log, so a slow
Datadog never costs an agent its lease. A Datadog lease request now takes 1 to 3 seconds
longer the first time in each hour; a caller that waits less than that on a lease should
wait longer. - Two Datadog keys made for one agent in the same minute no longer collide. A key made
for one lease is named for its agent and the minute, and Datadog refuses a second key
under a name. The second now carries a short suffix.
Image: ghcr.io/tenishai/bab@sha256:eae2e63fbe5908ee97a83e3e1559154800a87ba674dbc78cb26e0e4d15436205 (tags v0.4.25, e63b475; linux/amd64, linux/arm64)