Repository navigation
Permanent ids for what berth keeps - #74
Merged
Merged
Conversation
…ries, secrets and keys Names are labels, and what refers to a thing or belongs to it uses its id. The ninth import converts a store once, and a provisioner is given no secret it does not own.
…e constraint PostgreSQL refused
… id shapes end to end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gives every host, provisioner, resource, registry, secret and key a permanent id. Names become labels: a rename changes the label alone, and everything that refers to a thing or belongs to it uses its id. The page for API consumers is
docs/content/docs/(guide)/reference/ids.mdx.Ids
berth_api::ids). Replies, the store and logs use this form.host_,prov_,res_,reg_,sec_andkey_prefixes are accepted and stripped. A prefix of another kind is refused with a 400. The hyphenated UUID form is accepted on input.r-…resource ids are converted to new ids; provisioners only read the label's presence.Store layout
I kept the layout from the design note rather than an
entitiestable.stategets alabelcolumn withUNIQUE (kind, scope, label) WHERE label IS NOT NULL; the key stays(kind, scope, name)andnameholds the id.berth store copy, reseal and the sealing context keep handling one table. Rows are sealed under the id, so a rename needs no reseal.UPDATE(Backend::relabel).COALESCE), so code that rewrites a value cannot drop it.What belongs to a thing is a row without a label whose name is the owner's id or
ID/…:credentials,access,tailnetnamed by its id, and secretsID/sshandID/sudoID/loginID/SECRETspecnamed by its idID/pendingBatch::forget_owned(scope, id)deletes them in the same transaction as the owner.Backend::change_statestakes oneChange, applied in this order: removals, owners, writes, then the host and job moves. It replacesrename_hostand #71'srename_subject.References
provisionerandhostare ids. A host in a file keeps its path.nodeis the node's id.subjectandhostare ids.locks/ID.lock.registries,secrets[].nameandaccess.auth = key:….Place::loadgives names andPlace::savetakes names or ids (profiles::refs). Export, edit, profile files and the profile a host keeps of itself show names.Secrets
Owned secrets keep their addresses on the wire:
registry/NAME,ssh/HOST,sudo/HOSTandprovisioner/NAME/SECRET. NAME may be a name or an id, and the server resolves the owner. Setting one for an owner that does not exist is a 404.secrets.listkeepsnamesand addssecrets: [{id, name}]for the global ones.The fallback from a provisioner's secret to a global one of the same name is gone, in
provision::secretsand innode::said_same. A node's provisioner gets its own copy of the client certificate its feature trusts at each registration. A type such asincus/vmstill names the single provisioner registered of that type.API and CLI
jobs.listandinbox.listfilters resolve to ids.ididis now the id, besidenameandnode_idprovisioner_id,host_ididin each entryidsubjectby id;subject_nameandhost_idaddedhost_id/provisioner_idregistries.renameandsecrets.rename, withberth registry renameandberth secret rename.renameaction (from Rename a provisioner, filter jobs, inbox done from the CLI #71) is a label change now. Host rename stays, includinghostname=yesand the tailnet device rename from feat(serve): remove a destroyed host's tailnet device and rename it with the host #72.Migration
A new schema step on both backends adds the column and index. Then the ninth import,
import:ids, runs in one transaction after the copy berth makes before converting:The step is idempotent: labelled rows and rows named
IDorID/…are left alone. Tests cover the 0.5.2 fixture and a new 0.6.0-rc.4 fixture (made with that tag's berth plus rows of its layout), and the store suite runs the conversion and renames on both backends.The host's kept profile is format 4 and carries its
id.berth host adoptreuses that id when no host here has it.For consumers
idused to be its name; readnameinstead.subjectholds ids;subject_namesays it by name.