Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/v1alpha3/commitrequest_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
// the new hash here.
var commitRequestSchemaHashes = map[int]string{
1: "395df39c86bc4c0350eb2c476dd0ae02db2a7513f03962103416123b0cbb5476",
2: "41060fecb5109059cb04f03124c60d3166a1b3e8b55ee225382a556087a2f5fc",
}

// commitRequestRevisionLine is the last line of the kind's description.
Expand Down
36 changes: 28 additions & 8 deletions api/v1alpha3/commitrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ type CommitRequestWindow struct {
MaxDuration *metav1.Duration `json:"maxDuration,omitempty"`
}

// CommitRequestAuthor is who created a CommitRequest. A commit the request
// makes on its own, with nothing else in it, is authored by this person.
type CommitRequestAuthor struct {
// Username is the Kubernetes username. The request saves only writes
// whose author has this username.
// +required
// +kubebuilder:validation:MinLength=1
Username string `json:"username"`

// Name is the display name the login carried, such as the OIDC name
// claim. Omitted, a commit names the author by username.
// +optional
Name string `json:"name,omitempty"`

// Email is the address the login carried, such as the OIDC email claim.
// Omitted, a commit gets an address made from the username.
// +optional
Email string `json:"email,omitempty"`
}

// CommitRequestStatus defines the observed state of CommitRequest. Progress
// and outcome are reported entirely through conditions (kstatus-compatible),
// so the object carries no lifecycle phase string:
Expand All @@ -198,11 +218,11 @@ type CommitRequestStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// Author is who created this request, as the audit events of the cluster
// it was created on name them. Empty when they name nobody, or when author
// attribution is off: then the request saves only writes that name nobody
// either.
// it was created on name them. Omitted when they name nobody, or when
// author attribution is off: then the request saves only writes that name
// nobody either.
// +optional
Author string `json:"author,omitempty"`
Author *CommitRequestAuthor `json:"author,omitempty"`

// Conditions are the latest observations of this CommitRequest's state.
// Reconciling and Stalled follow kstatus.
Expand Down Expand Up @@ -274,7 +294,7 @@ type CommitRequestStatus struct {
// +kubebuilder:printcolumn:name="GitTarget",type=string,JSONPath=`.spec.gitTargetRef.name`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
// +kubebuilder:printcolumn:name="Author",type=string,JSONPath=`.status.author`
// +kubebuilder:printcolumn:name="Author",type=string,JSONPath=`.status.author.username`
// +kubebuilder:printcolumn:name="Commit",type=string,JSONPath=`.status.commit`
// +kubebuilder:printcolumn:name="Pushed",type=string,JSONPath=`.status.conditions[?(@.type=="Pushed")].status`,priority=1
// +kubebuilder:printcolumn:name="Applied",type=string,JSONPath=`.status.conditions[?(@.type=="Applied")].status`,priority=1
Expand All @@ -289,7 +309,7 @@ type CommitRequestStatus struct {
// spec is immutable, and status.commit reports the commit once it is on the
// remote.
//
// Schema revision 1, compatible from revision 1.
// Schema revision 2, compatible from revision 2.
type CommitRequest struct {
metav1.TypeMeta `json:",inline"`

Expand Down Expand Up @@ -331,8 +351,8 @@ func (s *CommitRequest) GitTargetKey() types.NamespacedName {
// schema this operator was built with, and the oldest revision it can serve: the last line of the
// kind's description.
const (
CommitRequestSchemaRevision = 1
CommitRequestSchemaFloor = 1
CommitRequestSchemaRevision = 2
CommitRequestSchemaFloor = 2
)

func init() {
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions config/crd/bases/configbutler.ai_commitrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
- jsonPath: .status.author
- jsonPath: .status.author.username
name: Author
type: string
- jsonPath: .status.commit
Expand Down Expand Up @@ -60,7 +60,7 @@ spec:
spec is immutable, and status.commit reports the commit once it is on the
remote.

Schema revision 1, compatible from revision 1.
Schema revision 2, compatible from revision 2.
properties:
apiVersion:
description: |-
Expand Down Expand Up @@ -251,10 +251,29 @@ spec:
author:
description: |-
Author is who created this request, as the audit events of the cluster
it was created on name them. Empty when they name nobody, or when author
attribution is off: then the request saves only writes that name nobody
either.
type: string
it was created on name them. Omitted when they name nobody, or when
author attribution is off: then the request saves only writes that name
nobody either.
properties:
email:
description: |-
Email is the address the login carried, such as the OIDC email claim.
Omitted, a commit gets an address made from the username.
type: string
name:
description: |-
Name is the display name the login carried, such as the OIDC name
claim. Omitted, a commit names the author by username.
type: string
username:
description: |-
Username is the Kubernetes username. The request saves only writes
whose author has this username.
minLength: 1
type: string
required:
- username
type: object
branch:
description: Branch is the branch the commit is made on. Set once
the request ends.
Expand Down
32 changes: 13 additions & 19 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

The open work, in one list. Each item is one or two lines with a code pointer or the design page
that argues it. Ranked within each group, most urgent first. **Before the next release** marks what
should land before the next tag is cut (the last release is v0.55.0). Checked against `main` at
`1bc97904` on 2026-10-24.
should land before the next tag is cut (the last release is v0.56.0). Checked against `main` at
`a13c23d9` on 2026-11-25.

## Before the next release

Expand Down Expand Up @@ -112,14 +112,6 @@ Their argument for each is in [gitops-api-open-asks.md](future/gitops-api-open-a
the wall clock, so the model sends each late write inside it). Two guards no input reaches are pinned by unit
tests instead: the outage ending when its writes settle with no push, and an attach that closes a
later window in the same pass.
- [ ] `expireWaitingCommitRequests` ranges over a map, so empty commits for saves that expire in
the same pass land in random order; sort by `seq` (`internal/git/commit_request_attach_loop.go`).
- [ ] `buildRequestRecordWrite` keeps only the username (`UserInfo{Username: pcr.author}`); carry the
full `UserInfo` so a record commit has the same author identity as a window commit.
- [ ] A record commit skips `requestTemplate`, though its doc comment says it is phrased like every
other commit; fix the code or the comment.
- [ ] Nits: a doubled doc comment on `commitWindowFor`; "close-delay" in the test names in
`internal/controller/commitrequest_kstatus_test.go`.
- [ ] **Parent observation, step 1**: keep parent availability and its timestamp after the write
branch exists, from existing advertisements, with no extra connections.
[gittarget-parent-observation.md](design/gittarget-parent-observation.md#implementation-and-validation).
Expand Down Expand Up @@ -153,7 +145,7 @@ Their argument for each is in [gitops-api-open-asks.md](future/gitops-api-open-a
- [ ] Accepted for now: no rate bound on push deliveries. Folding bounds the queue, not the rate, so
a `GitReceiver` token holder can keep a worker reading; a per-worker cooldown would bound it.
- [ ] Re-assess unifying the pending-write kinds
(grouped window, resync and request record, since #450 removed the atomic kind). Deferred.
(grouped window, resync and empty commit, since #450 removed the atomic kind). Deferred.
- [ ] Improve queue and worker observability, with more high-load tests.

## Watch plane
Expand Down Expand Up @@ -208,19 +200,21 @@ Their argument for each is in [gitops-api-open-asks.md](future/gitops-api-open-a
Address before the next feature that widens commit-message, snapshot or write-window behavior.
- [ ] **Run image-refresh only when its inputs change**, a path filter in `ci.yml`; it removes a
14–18 minute leg from most PRs. [e2e-suite-trim.md](design/e2e-suite-trim.md).
- [ ] **F-f: E6 can leak its editing goroutine**: `close(stop)` runs only after the `Eventually`
succeeds. Use `DeferCleanup` (`test/e2e/bi_directional_echoes_e2e_test.go`).
- [ ] The e2e detail gaps and redundancy tables in [e2e-suite-trim.md](design/e2e-suite-trim.md):
four specs that look tested and are not, then the moves and merges.
- [ ] `SetDefaultEventuallyTimeout` is global and set in 17 e2e files, so the last `Describe` body
built wins; use per-spec timeouts (`Eventually(...).WithTimeout`).
- [ ] e2e for the commit-window stack: two authors editing disjoint files at once, then a
`path_conflict`; E5 extended to the withheld-field carry; a restart of a source cluster's
controller with a save in flight; `catchUp: AfterPush` at shutdown.
built wins; use per-spec timeouts (`Eventually(...).WithTimeout`). Moving each call into a
`BeforeEach` is not enough: Ginkgo runs top-level containers in random order, so a spec that sets
none would inherit whichever container ran before it, and a `BeforeAll` runs before its own
container's `BeforeEach`. Needs a full e2e run to verify.
- [ ] e2e for the commit-window stack: E5 extended to the withheld-field carry; a restart of a
source cluster's controller with a save in flight; `catchUp: AfterPush` at shutdown. (Two and
three authors at once and a `path_conflict` are covered since #478.)
- [ ] e2e Test A: a delete missed while the controller is scaled to 0; then Tests B and C.
[e2e-coverage-gaps-and-improvements-plan.md](design/e2e-coverage-gaps-and-improvements-plan.md).
- [ ] Re-enable `goconst` with a path-scoped exclusion (`test/`, `internal/git/commit.go`) instead
of the repo-wide disable in [.golangci.yml](../.golangci.yml).
- [ ] Enable `goconst`. It is not in the `enable` list of [.golangci.yml](../.golangci.yml) (only a
`_test.go` exclusion names it), so it never runs; enable it with a path-scoped exclusion (`test/`,
`internal/git/commit.go`).
- [ ] Release-image reuse PRs 2, 3 and 5 ([release-image-reuse-plan.md](design/release-image-reuse-plan.md)).
- [ ] Metrics Phase 5: dashboard JSON, recording and alert rules
([metrics-observability-plan.md](design/metrics-observability-plan.md) §7).
Expand Down
33 changes: 33 additions & 0 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ guidance that the changelog's breaking-change entries link to.
We are pre-1.0, so breaking changes bump the **minor** version (release-please is configured with
`bump-minor-pre-major`) rather than the major. Read the relevant entry before upgrading across it.

## A `CommitRequest`'s `status.author` is an object

`status.author` names the request's creator as `username`, plus the `name` and `email` their login
carried (an OIDC name and email claim), when the audit event has them:

```yaml
status:
author:
username: oidc:alice
name: Alice Jansen
email: alice@corp.example
```

It was the username alone. Read `.status.author.username` where you read `.status.author`; the
`Author` column of `kubectl get commitrequests` already does. With the name and email kept, an empty
commit (`whenNothingToCommit: CommitEmpty`, when no write reached the save in time) is authored as
`Alice Jansen <alice@corp.example>`, like the person's other commits, instead of by username. Its
message is also framed by the target's `requestTemplate`, as every other save's is.

A stored `CommitRequest` whose `status.author` is still a string cannot be read by this release, and
one such object stops every `CommitRequest` on that cluster from being served, not only itself.
Finished requests stay for 48 hours, so there usually are some. Before upgrading, let the saves in
progress finish, then delete every `CommitRequest` on the cluster GitOps Reverser runs in and on
each source cluster that serves them (`spec.commitRequests` on its `KubeProvider`):

```bash
kubectl delete commitrequests --all --all-namespaces
```

The `CommitRequest` CRD is at schema revision 2. On each such source cluster, apply this release's
`commitrequest-crd.yaml` too: a revision 1 CRD rejects the new `status.author`, so a request there
is never claimed.

## An empty repository gets its default branch first

In an empty repository with `spec.parentBranch` omitted, a `GitBranch` whose `spec.branch` is not
Expand Down
5 changes: 3 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ fields:
default) and `maxDuration` (default `2s`). A request never opens a window; only writes do.
- `spec.whenNothingToCommit`: `Resolve` (default) or `CommitEmpty`, which records the message in an
empty commit when the request ends with nothing to commit.
- `status.author`: the creator, as the request's audit event names them; empty when it names nobody,
and then the request can attach only to an unnamed window.
- `status.author`: the creator, as the request's audit event names them: `username`, and the `name`
and `email` the login carried, if any. Omitted when it names nobody, and then the request can
attach only to an unnamed window.
- `status.conditions`: kstatus-compatible. **Ready** is the summary (Unknown while the save runs, True
once the request reached a terminal outcome that is not an error: a pushed commit, or a benign
no-commit); **Reconciling**/**Stalled** are the kstatus progress/blocked pair. **Pushed** reports
Expand Down
7 changes: 4 additions & 3 deletions docs/commit-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ message only on some branch passes validation and falls back at commit time.

| Input, in precedence order | Message source |
|---|---|
| Attached [save request](configuration.md#commitrequest) **and** `requestTemplate` set | `requestTemplate`, with the request's message as `.RequestMessage` |
| [Save request](configuration.md#commitrequest) message, on its window or its empty commit, **and** `requestTemplate` set | `requestTemplate`, with the request's message as `.RequestMessage`; an empty commit lists no resources |
| Non-empty literal override, including an attached [save request](configuration.md#commitrequest) | Exact supplied text |
| Live window of any size | `liveTemplate` |
| Atomic snapshot or resync | `reconcileTemplate` |
Expand Down Expand Up @@ -77,8 +77,9 @@ spec:
{{end -}}
```

It renders only for a window a save request attached to; every other window is unaffected. Omit it
and request messages are committed verbatim, exactly as before.
It renders only for a commit a save request gave its message: the window the request attached to,
or the empty commit of a request no window reached in time. Every other window is unaffected. Omit
it and request messages are committed verbatim, exactly as before.

The request is **never** parsed as a template. Its message arrives as `.RequestMessage` and is
committed unaltered, so a save-button user supplies the content while the operator owns the
Expand Down
18 changes: 11 additions & 7 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1487,10 +1487,11 @@ ever update.
#### Commit message templates

Three templates decide how a commit is phrased: `liveTemplate` for a live window,
`reconcileTemplate` for an atomic snapshot or resync, and `requestTemplate` for a window a
[save request](#commitrequest) attached to. Each is a Go template over a documented context,
checked when the target reconciles rather than at commit time, and each has a built-in default, so a
target that sets none still writes useful messages.
`reconcileTemplate` for an atomic snapshot or resync, and `requestTemplate` for a commit a
[save request](#commitrequest) gave its message: the window it attached to, or its empty commit.
Each is a Go template over a documented context, checked when the target reconciles rather than at
commit time, and each has a built-in default, so a target that sets none still writes useful
messages.

```yaml
spec:
Expand Down Expand Up @@ -3258,7 +3259,9 @@ A request no grant admits fails before it attaches: `Ready=False`, `Stalled=True
A request's author is found from its own audit event, on the cluster it was created on, the same
way an edit's author is: from the same index, with the same `--author-attribution-grace`. So a save
attaches only to its creator's windows, by the ordinary author rule, and `status.author` names the
creator. The author is recorded in the request's first status write, before it attaches. Create a
creator: `username`, plus the `name` and `email` the login carried (an OIDC name and email claim),
when it carried them. The author is recorded in the request's first status write, before it
attaches. Create a
request on a source cluster as JSON: `kubectl` and browsers send JSON, and an API server that drops
the audit event of a YAML body loses the save's author without an error.

Expand Down Expand Up @@ -3286,8 +3289,9 @@ namespace decides only whether a grant admits it.
reason, without changing Git.

- `Resolve` (the default) finishes without a commit.
- `CommitEmpty` records `spec.message` in an empty commit, authored like any other commit by the
request's submitter. It requires `spec.message`.
- `CommitEmpty` records `spec.message` in an empty commit, authored by the request's submitter
with the same name and email as their other commits, and framed by `requestTemplate` like any
other save. It requires `spec.message`.

| Outcome | `Resolve` | `CommitEmpty` |
|---|---|---|
Expand Down
Loading