Make Changes
Changing configuration and making it live are two separate steps in ConfigHub. You edit Units freely — nothing you do to a Unit reaches a cluster. Configuration goes live only when you publish a Release, which a GitOps operator then pulls.
That separation is what this workflow is built on. Between the change and the release sit the things you want there: grouping, validation, review, and approval.
This guide covers making, grouping, drafting, undoing, and merging changes within one variant. Publishing Releases covers making them live. Taking a named change out of a base and through dev, staging, and production, including review and approval along the way, is promotion.
Selecting Units
To make a configuration change and then release it, first identify a set of units. Typically it will be a variant, corresponding to a Space, or set of variants, deployed to a single Target cluster.
Use a where expression or a saved Filter to select the Spaces.
See the guide about managing sets of units for more details.
Change Sets
Create a ChangeSet with a Description. ChangeSets make it possible to group multiple related changes, in sequence and across units. ChangeSets can be used to refer to changes when restoring previous configurations and when merging configurations across units and "rebasing" prior changes on top of more recent changes. Each ChangeSet has a start tag and an end tag.
cub changeset create --space acme-home release-v452 --description "Release 452: Fix X. New feature Y. Upgrade Z."
Use bulk patch on the filtered set of units to add them to the change set, which "opens" it. A change set acts as a kind of lock, so if any units are in another change set, it will need to be removed (closed) first. Opening a ChangeSet changes nothing about the units: its start Tag goes on each unit's current head revision, which is the state to go back to, and no revision is created.
cub unit update --patch --space acme-dev --filter acme-home/acme-app --changeset acme-home/release-v452
cub variant changeset open does the same for the units of a variant: every unit not already in a change set, or those --where selects among them.
cub variant changeset open acme-dev acme-home/release-v452
A ChangeSet can be opened on units in more than one Space, and records each Space it was opened in, in InScopeSpaceIDs.
Now you can make modifications to the filtered Units, such as upgrades, and the revisions will be part of the change set. Every write that creates a revision of a unit in the change set has to name it with --changeset, or it is rejected: invoking functions, updating the unit's data, upgrades and other merges, restores, and the writes that create a revision without changing the data, cub unit set-guard, and cub unit conflicts or cub variant conflicts applying or dismissing merge conflicts. A write that names no change set, or another one, is told which change set holds the unit. Revisions ConfigHub makes on its own, such as resolving a Link after a change upstream, need not name it, and still belong to it.
cub function set --space acme-dev --changeset acme-home/release-v452 --filter acme-home/acme-app --change-desc "Update image ref to v452" set-container-image-reference ":v452"
To close the changeset, the units need to be patched again with a null ChangeSetID. That will add the ChangeSet EndTagID to the Head Revision of each of the Units. Taking the first unit out of a ChangeSet closes the whole of it, so take every unit it is open on out of it, in every Space: a unit left in a closed ChangeSet cannot be written until it is taken out.
cub unit update --patch --space "*" --where "ChangeSet.Slug = 'release-v452'" --changeset -
cub variant changeset close does that for you:
cub variant changeset close acme-dev acme-home/release-v452
A ChangeSet locks the Units it is open on, in whichever Spaces they are. It does not follow the change into other Spaces as it is promoted: that is a ChangeOrder's job, described in tracking and promoting changes. To promote or release what a ChangeSet changed, close it and create a ChangeOrder that ends at its end Tag, as shown in naming a change with a ChangeOrder. The Spaces the ChangeOrder is promoted into need no ChangeSet of their own, since the ChangeOrder records the change in each of them, unless their Units are already in an open ChangeSet, which the promotion then names with --changeset.
Reviewing a Change Set
An open ChangeSet is reviewed before it is closed, the way a pull request is reviewed before it is merged. Its page in the UI, under Explorers > ChangeSets, shows what it changed in each unit, who has approved it, and whose review it is waiting for.
Ask for a review when you create the ChangeSet, or later:
cub changeset create --space acme-home release-v452 --description "Release 452" --request-review alice
cub changeset update --space acme-home release-v452 --request-review bob
cub changeset update --space acme-home release-v452 --withdraw-review-request bob
A request is not cleared when the review is given: whether a reviewer has reviewed is read from the Attestations they recorded. An approval of the ChangeSet covers the latest revision it made of each unit while it is open, and its end once it is closed, so a change made after an approval leaves that approval out of date:
cub variant approve acme-dev --all --revision ChangeSet:acme-home/release-v452
cub changeset get shows who created the ChangeSet and whose reviews have been requested.
Gating the close with a ChangeWorkflow
A ChangeSet created with --change-workflow is governed by that ChangeWorkflow: it closes only when every prerequisite of the workflow's Final holds in every Space the ChangeSet was opened in. The workflow has no Stages, since a ChangeSet is not promoted, and its Final can name Validated, custom prerequisites, and attestation prerequisites, such as an approval by someone who did not write the change. The workflow is copied onto the ChangeSet when it is created, and cannot be changed afterwards.
cub changeworkflow create --space acme-workflows release-review --from-stdin <<EOF
Final:
Prerequisites: [Validated, reviewed]
AttestationPrerequisites:
- Name: reviewed
Description: one approval by someone who did not write the change
EOF
cub changeset create --space acme-home release-v452 --change-workflow acme-workflows/release-review
The gates are evaluated when the ChangeSet closes, against the latest revision it made of each unit. A Space where it changed nothing satisfies every gate. --dry-run reports the gates without closing anything. A close the gates refuse takes no unit out of the ChangeSet, and names each gate that does not hold, in each Space where it does not:
cub variant changeset close acme-dev acme-home/release-v452 --dry-run
The unit write that closes a governed ChangeSet cannot also change the unit's configuration, since the gates were evaluated on the revisions the ChangeSet made. Make the change first, then close it.
To close it although a gate does not hold, give a reason. Forcing it needs Edit permission on the ChangeSet, and who forced it, when, why, and which gates did not hold are recorded in its CloseOverride:
cub variant changeset close acme-dev acme-home/release-v452 --force-reason "approved in the incident channel"
cub unit update --changeset - takes --force-close with --force-reason to the same effect. The ChangeSet's page in the UI disables Close while a gate does not hold, lists the gates and the Spaces each does not hold in, and offers Force close with a reason.
When a unit in a Space of a Component that requires a ChangeWorkflow joins a ChangeSet, the ChangeSet has to be governed by one, and the workflow has to be one the Component allows. An upload into such a Space takes --change-workflow for the ChangeSet it records its writes in, and leaves a governed ChangeSet open for review rather than closing it:
cub variant upload --component acme --variant dev --change-workflow acme-workflows/release-review ./rendered/
Requiring a ChangeSet or ChangeOrder
A Component can require that every change to the configuration of its variants' units is made in a ChangeSet open on the unit, or under a ChangeOrder, so that every revision with new configuration belongs to a named change, the way a protected branch in Git or GitHub accepts changes only through a pull request. --require-change-tracking turns it on, and needs Manage permission on the Component:
cub component update --patch acme --require-change-tracking
With it on, a write that would change the configuration of a unit in one of the component's variants is refused unless the unit is in a ChangeSet or the write names a ChangeOrder. That covers creating a unit, empty or not, writing its data, cub unit update with --restore, --upgrade, --merge-source or --resolve, invoking functions, cub variant upload, cub variant create, cub variant promote and cub variant demote. A dry run is refused as the write would be. Writes that change only metadata, such as labels, are not affected.
A write counts as made under a ChangeOrder when it names one: cub variant promote --change-order and cub variant demote --change-order, which upgrade, resolve, clone, invoke or restore on its behalf, and cub unit update --upgrade, --resolve or --restore with --change-order. Otherwise, open a ChangeSet on the units first, as described in Change Sets, and pass it to the commands that take --changeset. cub variant upload records its writes in a ChangeSet of its own, so it needs nothing more.
Two kinds of write that ConfigHub makes on its own are exempt, since they follow a change made somewhere else: a Link resolved by the resolve queue, such as a NeedsProvides link filling in a namespace, and a backing unit created for or refreshed from the entity whose configuration it holds. Their revisions still belong to the ChangeSet open on the unit, if there is one.
Drafting a change in a Space of its own
A ChangeSet locks its units from the moment it is opened until it is closed, so nobody else can write them while the change is made and reviewed. A draft makes and reviews the change in a Space of its own instead, the way a Git branch and a pull request do, and locks the original units only while it lands. cub draft create clones some or all of a Space's units into a draft Space named <space>-draft-<name>, with a syncback Link from each original unit to its clone:
cub draft create acme-dev raise-memory --where "Slug = 'acme-app'"
The draft Space is in the original's Component, with the same labels except Stage=Draft and Draft=<name>, and selects the same Triggers, so functions, validation and Link resolution run in it as they do in the original. It has no release Target unless --release-target gives it one, for a preview deployment. The original Space keeps taking edits, upgrades and Releases while the draft is open, and a Space can have several drafts at once, which may change the same units. Since a draft Space is a variant like any other, a ChangeOrder of the original's changes that is not told where it is headed is headed for the draft too; leave drafts out with --where-space-field "Labels.Stage != 'Draft'".
Change the clones as you would any unit, with --guard Override=Upstream on each change. The guard is what keeps the draft's value at a path the original also changes, as described in syncing a draft.
cub function set --space acme-dev-draft-raise-memory --unit acme-app --guard Override=Upstream \
--change-desc "Raise web memory to 1Gi" set-container-resources web all "" 1Gi 1
cub draft list lists a Space's open drafts, cub draft get shows which of a draft's units have changes that have not landed, and cub draft diff shows what those changes are, path by path.
Proposing a draft for review
cub draft propose creates the ChangeSet the draft will land in, draft-<name> in the original Space, with a description and review requests, as in reviewing a Change Set. It is opened on no unit, so the original Space is still not locked. --change-workflow governs it with a ChangeWorkflow whose Final prerequisites gate landing, as in gating the close. An approval of the draft's units with cub variant approve counts on each original unit whose content lands as it was approved, if the approver may approve in the original Space. The authors, whose own approvals do not count, are those who changed the draft, not whoever lands it.
cub draft propose acme-dev/raise-memory --description "Raise the web container's memory to 1Gi" --request-review alice
Syncing a draft with the original
cub draft sync brings into the draft what the original has changed since the draft last took it, as cub variant promote does for a variant: each clone is upgraded from its original, and units created in the original since are cloned into the draft. Where the draft and the original both changed a path, the sync replaces the draft's value with the original's, unless the draft guards the path. With Override=Upstream on it, the original's change is withheld instead, and recorded as a conflict on the draft unit. The sync lists the units with conflicts outstanding.
cub draft sync acme-dev/raise-memory --dry-run
cub draft sync acme-dev/raise-memory
Decide each conflict in the draft Space with cub unit conflicts. Dismissing it keeps the draft's value, which landing then writes over the original's; applying it takes the original's value.
cub unit conflicts --space acme-dev-draft-raise-memory acme-app --dismiss
cub unit conflicts --space acme-dev-draft-raise-memory acme-app --apply --clearance Override=Upstream
Landing a draft
cub draft land merges the draft's changes into the original units, in the draft's ChangeSet, creating it if the draft was not proposed, and closes the ChangeSet. Like a GitHub branch protection rule that requires a branch to be up to date before merging, it refuses a draft whose units are behind their originals or have conflicts outstanding, among the units landing would change, so that landing does not write over a change to the original that nobody has looked at. The refusal names the units and locks nothing; sync, resolve the conflicts, and land again:
cub draft land acme-dev/raise-memory --dry-run
draft acme-dev-draft-raise-memory cannot land yet; these units have not taken what their originals changed since they last synced, which landing would write over: acme-app: syncing would withhold Guarded at spec.template.spec.containers.?name=web;@0.resources.limits.memory, Guarded at spec.template.spec.containers.?name=web;@0.resources.requests.memory. Sync the draft with "cub draft sync", and land again
Landing opens the ChangeSet on the original units the draft changed, and leaves the others alone and unlocked. Once the ChangeSet holds them, nothing else can change them, and landing checks again that the draft is in sync. It then replays each draft revision as a revision of its original unit, described as Replayed revision N of <draft-space>/<unit>, so the original's history says where the change came from. A guard set with --guard stays with the draft, while one set with --inherited-guard lands with the change. The original's own guards hold against landing: a draft change to a path guarded in the original is withheld, and recorded as a conflict on the original unit. Units created in the draft have no original to land in, and are reported.
The ChangeSet is closed once the Triggers and Link resolves that follow the landing have finished, so what they write is part of the change. The draft Space is then archived as the record of the change; cub draft list --include-hidden=Archived lists it. If the ChangeWorkflow's gates do not hold, or the original changed between the two checks, the ChangeSet stays open on the original units, holding them, and the draft is kept: satisfy the gates, or sync the draft, and land again. --force-reason closes the ChangeSet although its gates do not hold, as cub variant changeset close --force-reason does.
Once landed, the draft's ChangeSet is like any other. Release it, promote it with a ChangeOrder that ends at its end Tag, and undo it as in undoing a Change Set or reverting changes, naming it as ChangeSet:acme-dev/draft-raise-memory. cub draft abandon archives a draft without landing it, and changes nothing in the original Space.
Undoing a Change Set
To take back what a ChangeSet did and keep everything done since, revert it. cub variant revert finds the Units the ChangeSet changed, in whatever Spaces they are, and writes one new Revision of each that takes back the ChangeSet's change to it:
cub variant revert ChangeSet:acme-home/release-v452 --dry-run -o mutations
cub variant revert ChangeSet:acme-home/release-v452 --change-desc "Revert release 452"
To take each Unit back to what it was before the ChangeSet, dropping everything done after it as well, restore the Revisions before it instead. Restoring creates new head Revisions, and --tag marks them, so the rollback can be released and referred to:
cub tag create --space acme-home rollback-v452 --display-name "Rollback release 452"
cub unit update --patch --space acme-dev --filter acme-home/acme-app --restore "Before:ChangeSet:acme-home/release-v452" --tag acme-home/rollback-v452
Either way, publish a new Release to roll the undo out.
Reverting changes
A restore goes back to a revision. A revert takes out one change, or one range of revisions, and keeps everything that came after it, as git revert does. That is what you want when the change to undo is not the most recent one.
cub unit revert reverts in one Unit. cub variant revert reverts in every Unit a ChangeSet, Tag or Release marks, or, given a variant or Space, in its Units; --where narrows them. What to revert is one of:
- A revision number, such as
7, orHeadRevisionNumfor the latest change. Revision numbers differ from Unit to Unit, so onlycub unit reverttakes them. ChangeSet:<changeset>, the Revisions of a ChangeSet.Tag:<tag>, the Revision a Tag marks.- A range,
<from>..<to>: the Revisions after<from>, up to and including<to>, as with git.5..7is Revisions 6 and 7, andTag:pre..Tag:postis what was done between two Tags. Each end is a Revision as--restoretakes one, such asLastReleasedRevisionNum,Release:<number>orBefore:ChangeSet:<changeset>.
Bracket a change with tags so the range can be named without hardcoding revision numbers:
cub tag create --space acme-home tls-pre --display-name "Before the TLS annotation change"
cub unit tag --space acme-dev --filter acme-home/acme-app --revision HeadRevisionNum acme-home/tls-pre
cub function set --space acme-dev --filter acme-home/acme-app set-annotation acme.io/tls "strict"
cub tag create --space acme-home tls-post --display-name "After the TLS annotation change"
cub unit tag --space acme-dev --filter acme-home/acme-app --revision HeadRevisionNum acme-home/tls-post
Then revert what was done between them:
cub variant revert acme-dev Tag:acme-home/tls-pre..Tag:acme-home/tls-post --dry-run -o mutations
cub variant revert acme-dev Tag:acme-home/tls-pre..Tag:acme-home/tls-post --change-desc "Revert the TLS annotation change"
Only the paths that range touched are taken back. Changes made after tls-post, including changes to other fields of the same resource, survive. A range whose ends resolve the wrong way round on a Unit, such as two Tags named in the wrong order, is refused. A Unit the change marks but did not change gets no new Revision, and without --change-desc each new Revision is described by what it reverted, as "Reverted revisions 6-7".
A revert is a merge of the Unit with its own history, with the range running backwards: cub unit update --merge-source Self --squash, with --merge-base naming the end of the range and --merge-end the Revision before it. It uses the same machinery as merging and rebasing, and the same two rules decide what it may take back:
- An
Overrideguard does not stand in the way. It is about content arriving from another Unit, such as an upgrade or a merge from elsewhere. A revert is the Unit acting on its own history, so the field is the caller's own, the revert is cleared forOverrideguards, and it may take the value back. - Any other guard does. A guard names why a value is what it is, and an operation carrying no clearance for that reason does not write the path. The revert leaves the path as it is and reports a conflict naming the
--clearancethat would take it. Seecub unit set-guard.
Like a restore, a revert only changes configuration data. Publish a Release to make the revert live.
A revert takes back the Revisions it names, in the Units that hold them. To undo a change that has already been promoted into other Spaces, revert it there too, or, if the change was carried by a ChangeOrder, use cub variant demote, which restores each Space it reached and records that it did.
Merging and rebasing
In ConfigHub, revisions and clones are somewhat analogous to git commits and branches, but are somewhat different since each Unit is kind of like its own repo with its own commit history, and ConfigHub also enforces a linear revision history, which is generally more suitable and convenient for managing granular configuration units. But there are some cases where merging changes from other units or prior revisions is necessary or desirable.
Examples:
- Prior revisions were restored, as described above, but there were subsequent changes after the changeset that was undone. You can update the units with
merge_source=Selfand the change set or other revision range for the revisions to rebase on top of the restored revision. - Changes have been made since the last Release that shouldn't go out yet, but an urgent change needs to be made. The last released revision can be restored, then the urgent change made and published, and the reverted changes patched back in when it's time to release them, using the same approach as in (1).
- Clone a configuration unit and make changes for an upcoming release. When it's time to roll out, merge the changes with the upstream. Drafts do this for a Space's units.
cub unit update --patch --space acme-dev --filter acme-home/acme-app --merge-source Self --merge-base Before:ChangeSet:acme-home/release-v452 --merge-end ChangeSet:acme-home/release-v452 --change-desc "Reapply release 452"
A merge walks the range it is given, revision by revision, re-running the functions each revision recorded where it can, and records one revision here per source revision that has an effect. --squash merges the range as one rebased diff in one revision instead. A merge that cannot apply part of what it brought records the withheld change rather than dropping or forcing it; cub unit conflicts lists what is outstanding, and applies or dismisses it. Conflicts are described in the variants guide; the merge engine itself is documented in advanced merging techniques.
Tags
ChangeSets use "managed" Tags, but Tags can also be set independently, on named revisions such as HeadRevisionNum and LastReleasedRevisionNum. It is a good idea to tag any revisions being approved and released that aren't part of a ChangeSet, and then use the Tag when approving (cub variant approve --revision Tag:<tag>), when publishing (cub release publish --revision <tag>), and when restoring (using "Before:Tag:" and the tag ID).
cub tag create --space acme-home upgrade-251023 --display-name "Upgrade from base"
cub unit update --patch --space acme-dev --filter acme-home/acme-app --upgrade # could also use --tag here
cub unit tag --space acme-dev --filter acme-home/acme-app acme-home/upgrade-251023
A ChangeOrder mints Tags of its own, which are how a change is tracked across Spaces, and a Release that creates its Tag owns that one. Those are not added or removed by hand: cub unit tag refuses a Tag a ChangeSet, a ChangeOrder, or a Release owns. The exception is a ChangeOrder's release Tag, which cub unit tag ChangeOrder:<slug> --move moves to adopt a later revision before the change is released; see releasing each stage. --move works on any other Tag too, and refuses a Unit the Tag does not already mark.
Listing ChangeSets and Tags
Use the organization-level Revision List API to list Revisions associated with ChangeSet or Tag. For ChangeSets, you can use the ChangeSet's StartTagID or EndTagID (if closed) via where Tags ? '<tag-id>', or filter by the ChangeSetID using where ChangeSetID = '<changeset-id>'.
cub revision list --space acme-dev --filter acme-home/acme-app --tag acme-home/rollback-v452
--changeset lists the revisions made in a ChangeSet, in whichever units it was opened on:
cub revision list --changeset acme-home/release-v452
For a particular Unit, all Revisions in the ChangeSet can be listed using where ChangeSetID = '<changeset-id>' using the existing unit-level Revision List API.
cub revision list --space acme-dev frontend --where "ChangeSet.Slug = 'release-v452'"
Beyond one variant
Everything above happens in one Space. A change that has to reach dev, then staging, then every production variant is a rollout: it needs an identity that survives crossing a Space boundary, a declared order for the hops, and a way to ask where it has got to. See tracking and promoting changes.