Repository navigation
Conversation
deploy.approved_tag marks a set whose every master carries it as approved for self-service sessions. A deploy with approved_only is refused unless its set is approved, at submission and at the worker's re-plan. [practice] holds the session interface's settings (pods, principal, listen, key); unset, the interface is off.
With [practice] set, serve opens a second listener for five calls: list approved sets (with templates, config digests and one pod's size), list a session pod's VMs, submit a deploy or teardown, and read or cancel a job the interface submitted. Each call carries practice.key and a Proxmox ticket of practice.principal, which Proxmox proves by renewing it. internal/web/testdata/practice records one exchange per call for the practice app's client tests.
…s origin Review findings on the session interface, resolved: - Approval has one authority, internal/pods/approved.go. The tag counts only as one of Proxmox's registered tags, a session deploy takes exactly its set's masters rather than a name pattern's matches, and it clones built templates without building any. MasterSet no longer counts approvals, so the status poller is as it was. - jobs.origin (migration 020) says what submitted a job. The interface reads and cancels its own by that, and a volunteer is a job's starter only on jobs from the volunteer pages. - GET /v1/sets sizes a pod from its built templates, with every disk counted, reports battleship's own digest of each template's config, and marks a template it can't read instead of failing every set. - An outage while planning answers 502 or 504, not a 409 refusal, and each call has a deadline shorter than the listener's write timeout. - Both listeners shut down together. - The commented-out manifest blocks are gone; deploy/README.md says how to turn the interface on. practice.listen is documented as plain HTTP.
Second review round on the session interface: - GET /v1/sets plans a deploy of each approved set and lists the planner's templates, with what it blocks and why, so the listing can't show a template a deploy would refuse. The separate model of a set's templates is gone. - The approval tag is matched in its exact spelling, on the masters and in Proxmox's registered tags, and a set with no masters is not approved. The fake Proxmox shows the registered tags only to Sys.Audit on /, as Proxmox does; the principal needs that right. - MasterSets and approval group masters by set through one function. - Planning errors need no classifying: the request is refused only as not approved, and anything else is Proxmox's failure or the store's. - A pod's disk is the boot-disk figure the capacity estimate uses. - serve keeps its listeners in one slice.
…ts as the job plans them Proxmox checks a tag as typed and then stores it lower-cased unless tag-style is case-sensitive, so under the default settings anyone may set a variant of the registered approval tag. approvalTag now refuses unless tag-style is case-sensitive, the tag has no letters, or user-allow is not free (a list holding no variant). TagAccess reads tag-style, and Allows looks a tag up as typed, as Proxmox does. GET /v1/sets plans each set through jobs.BuildPlan, so it applies the principal's privileges and lists as blocked a template it could not clone. The digest comes from the planner's own read (TemplateSpec.Digest); the second config read and its error go, and one timeout bounds each set's plan. A submission reads the reserved keys before planning, so a store failure is told apart without a flag. THREAT_MODEL records the case-variant rule, the tag copy on clone, Sys.Audit granted at / without propagation, and that a volunteer's retry needs it too.
…g's privilege check
…k the clone right of each listed template user-allow=existing also allows the allow-list and the tags on guests the reader sees, so it is no safer than list. TagAccess.AllowsVariantOf decides on allowed-tags in every mode but free, through Allows, and approvalTag calls it. GET /v1/sets asks VM.Clone of each template itself (pods.Unclonable), since a first session pod that already holds the set clones nothing and its plan checks no clone right. Sets still unplanned 5 s before the call's deadline answer with their own error instead of turning the whole call into a 504.
…ets through the job plan again Under existing each user may also set the tags on guests it audits, which no one reader sees whole, so AllowsVariantOf allows a variant unless tag-style is case-sensitive, the tag has no letters, user-allow is none, or a list holds no unregistered variant. GET /v1/sets plans through jobs.BuildPlan again, so the first pod's pool, storage, network and tag rights show in the listing, and still asks VM.Clone of each template itself.
TagAccess's case-sensitive and the agent's exec-status exited each parsed the same RawMessage by hand.
… accurate approval and credential claims
…vedOnly DeployRequest takes ApprovedOnly and keeps Pattern, which deployMasters parses once with SetOfPattern, in place of ApprovedSet and the rewrite in jobs; the no-master message names the pattern either way. deployMasters no longer guards a nil Access, which NewPlanner never leaves and BlockUnpermitted refuses.
…e the listing POST /v1/jobs takes the digests GET /v1/sets listed, by template name, and refuses a deploy without them (422 bad_digests). jobs.Inputs keeps them (only with ApprovedOnly) and DeployRequest.Digests blocks a template whose digest differs or is missing, so the submission answers 409 blocked. An approved-set plan's template digests are in the fingerprint, so a template rebuilt in place before the worker claims the job ends it stale.
… clones, teardown digests and body cap
cloneNeeds is the one definition of what a clone asks (VM.Clone on the source, VM.Allocate in the pool, Datastore.AllocateSpace, SDN.Use on the source's vnet bridges, Mapping.Use for a custom CPU); itemNeeds' clone step and pods.Uncloneable both use it. GET /v1/sets asks it for the first session pod whether or not that pod already holds the set, in place of Unclonable's VM.Clone alone.
pods.PodFootprint sums a pod's clones of the reused templates, counting boot disks through cloneDisk, which EstimateCapacity now shares: a full clone copies the boot disk, a linked clone (deploy.linked, the default) counts as none. GET /v1/sets reports it in place of practiceSize's own sum of MaxDisk.
practiceAnswerMargin's earlier deadline duplicated the slack the listener's write timeout already leaves, and nothing reads the context after the plans. A test pins that sets the call runs out of time for carry their errors in a 200.
A clone asks SDN.Use on every NIC of its source, plain bridges under zone localnetwork and VLAN tags on their path; a template build asks it as the clone it is. An env-edit label step that adds or removes a tag user-tag-access refuses asks Sys.Modify on /.
BlockChanged runs after BlockUnpermitted on unblocked templates only, so a blocked template keeps its reason. The fingerprint drops Digest: the re-plan blocks a changed template, and Blocked is fingerprinted. Every plan records a reused template's digest.
…terface's checks Name the SDN.Use the principal needs on the networks approved templates' NICs sit on as an accepted risk (task 2.11), the root@pam ticket exception, the env-edit's Sys.Modify ask, the listing's deadline, and the digest check after the privilege checks.
- sdnUse asks SDN.Use only for bridges in a zone Battleship knows (environments.sdn_zone, images.edit_zone, proxmox.sdn_zone) and leaves any other bridge to Proxmox; vnetPaths follows check_vnet_access (tag, each trunk VLAN, bare bridge with neither). Clones and both network steps use it, the network steps on the NIC values they write (Item.NICsWas). - tagChanges compares tags as typed, as a multiset diff; sameTags is no changes, and hostTags keeps the VM's spelling. - Every label and tag-set planner records TagsChanged from the tags as read; the retire step asks for the deprecated tag; tagNeeds treats deploy.approved_tag as registered. - BlockChanged skips a template whose items are all blocked already.
- Source, TemplateSpec and Item hold one AsRead map (tags and netN, the clone source's under StepClone, else the VM's own); stepEdits replays NICChanges/NetworkChanges, LabelChanges, SetTagChanges and AddTag on it for the tags and NICs each step changes. Bridges, NICsWas, TagsChanged, the TemplateSpec side channels, withSetTag and nicsOf go. Fingerprints are unchanged; old stored keys are ignored. - A deploy reads each pod VM it keeps, so its network step starts from the VM's own NICs; the network steps ask SDN.Use on each written netN value and on the value it replaces, as update_vm checks both. - vnetPath asks only <bridge>/<tag> or the bare vnet; trunk VLANs are left to Proxmox, so trunk ranges are no longer parsed. - respellTags re-spells wanted tags as the VM has them for env-create and env-edit; hostTags drops its own copy. - tagNeeds counts deploy.approved_tag as registered only when TagAccess shows no registered tags.
…ept VM - Item.AsRead holds only a kept VM's own config; stepEdits starts from the clone source's (cloneSource, shared with itemNeeds) under StepClone, and the planners no longer copy it. AsRead is json:"-": rights are checked on a fresh plan, so stored plans drop it; fingerprints are unchanged. - StepChanges maps a network, label, tag-set or retire step to its change function, used by apply.runStep and stepEdits. The retire step's tag edit is [deprecated], so Supersedes no longer carries its tags, and the tag diff is taken before and after each replayed step (tagEdit goes). - Deploy reads its kept pod VMs with readConfigs, which now reports each VM's error: an unreadable VM blocks only its item, one gone since the listing is blocked as gone, and the VM's own cloud-init drive decides its network step's VM.Config.Cloudinit. keepVMs still narrows after planning: it runs in jobs on every team kind's plan.
…ribed - Recommend tag-style case-sensitive, or user-allow list holding every tag Battleship writes and no case variant of the approval tag; drop none, under which the principal's set-<set> tag step is blocked (THREAT_MODEL, design decision 5, task 1.5). - Uncloneable asks SDN.Use on the tag path or bare vnet in known zones; an unregistered approved_tag asks Sys.Modify when user-tag-access refuses it.
…k step asRead keeps the cloud-init drive and stepEdits records whether the network step regenerates it, replacing Item.CloudInit and TemplateSpec.CloudInit. StepChanges takes the template and returns nil for a network step with neither NICs nor a template, which the executor fails; retire is inline in runStep again. TemplateSpec.CPU is no longer stored in plans. A deploy cancelled while reading its kept VMs returns the cancellation instead of blocking them.
RegeneratesCloudInit decides it for stepEdits' replay and the executor's network step, which now regenerates itself; applyConfig loses its cloudInit parameter. isCloudInitDrive serves HasCloudInit and CDROMChanges. AsRead holds the config as read, without asRead's filter; docs and a test comment are reworded.
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.
Draft: group 2 of
openspec/changes/self-service-team-playis built and reviewed. The real-cluster checks are still to do (see "Left to do").What it adds
internal/web/practice.go): served on its own listener ([practice] listen) and off unless[practice]is set. Each call presents the session principal's Proxmox ticket plusBATTLESHIP_PRACTICE_KEY. Routes:GET /v1/sets: the approved sets, each with its templates' VMIDs and config digests, one pod's footprint, and whether it can deploy now.GET /v1/pods/{pod}/vmsPOST /v1/jobs: deploy or teardown to a session pod (51–59).GET /v1/jobs/{id}POST /v1/jobs/{id}/canceldeploy.approved_tag,internal/pods/approved.go). A set is approved when every master carries the tag spelled exactly as configured. Approval is refused where a case variant could forge it:existingnever approves.GET /v1/setslisted. A missing digest is refused 422bad_digests. A template changed since the listing is blocked (409), at submission and again at the worker's re-plan.jobs.origincolumn (migration 020) records which jobs the interface submitted.SDN.Useon each clone source NIC's tag path or bare vnet, in zones Battleship knows from config. Trunk VLANs and other bridges are left to Proxmox at run time.Sys.Modifyon/for any step that adds or removes a tag that user-tag-access refuses.deploy.approved_tagcounts as registered when the reader is shown no registered tags.self-service-team-play(proposal, design, threat model, tasks) andpractice-ai-addon.Behaviour changes for existing users
SDN.Useon the source's known-zone NIC networks (dev-slot and edit vnets for templates). Proxmox's clone already checks this, so the plan now refuses up front what used to fail at clone.Sys.Modifyon/for label, tag-set and retire steps that change a tag user-tag-access refuses.SDN.Useon a NIC's old vnet when a network step moves it.deploy.approved_taganddeploy.master_tagare trimmed once at config load.Tagsto the VM's spelling. A job like that queued across the upgrade ends stale and has to be submitted again.Accepted risk
The session principal needs
SDN.Useon the dev-slot networks that approved templates' NICs sit on. WithVM.Config.Networkon the session pools, a compromised practice app could attach a session VM to a staff dev network. This is recorded in THREAT_MODEL.md and design.md decision 5. Task 2.11 removes it.Left to do
Review
The lenses ran from round 6 onward on the rebased branch (the ledgers from rounds 1–5 were lost to a VM reboot). Each round reviewed the previous round's fixes. All 7 lenses ran whenever the structure changed.
origin/main..36cb9ebSDN.Useon dev-slot networks)Main fixes across the rounds:
check_bridge_accessasks them, without guessing zones and without expanding trunk ranges, which cost 4,099 Proxmox calls for one trunked NIC in a scratch run.pods.StepChangesis shared by the executor and the rights replay.Checks on the pushed head:
b24fa63: gofmt is clean andgo vet ./...passes.CI=true go test -race -count=1 ./...passes against Postgres.-race(headless Chrome).openspec validate --all --strict: 2 passed. The INFO notes are pre-existing:practice-ai-addonmodifies specs that don't exist yet.