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
12 changes: 12 additions & 0 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ 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.

## `close_reason="identity_change"` is three reasons

`gitopsreverser_git_commit_windows_total` no longer has `close_reason="identity_change"`. What it
counted is now one of three values: `other_target` (a write of another `GitTarget` on the same
branch), `unproven_footprint` (another author wrote where the files cannot be proven apart), or
`single_window` (another author wrote after the worker fell back to one window at a time). A query or
alert on `identity_change` matches nothing; sum the three for the old total. See
[interpreting metrics](interpreting-metrics.md).

A `CommitRequest` whose window a write outside it closed early this way, or by `path_conflict` or
`footprint_fallback`, still ends with the same reason, and its `Ready` message says why it closed.

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

`status.author` names the request's creator as `username`, plus the `name` and `email` their login
Expand Down
7 changes: 6 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3339,7 +3339,12 @@ request produced a pushed commit:
under the earlier request's message first. Saves by different authors do not race for a
message: each author's writes collect in a window of their own, side by side while their files
are proven not to overlap, and otherwise a write by another author closes the open window, and
its message, before it opens one of its own.
its message, before it opens one of its own. When a write outside a request's window closes it
that way, the request still ends as its outcome says, and its `Ready` message adds why the window
closed early: another author's write touched a file it held, the two could not be proven apart, a
write of another `GitTarget` on the branch arrived, or the branch worker holds one window at a
time. The author's edits after that are not part of the save. `git_commit_windows_total` counts
these closes by `close_reason`, with `timer_source="commit_request"` for a save's window.

`SaveInProgress` is decided when the branch worker registers the request, which is after its
author was found, not when it is created. A client that relies on it to keep two of its saves
Expand Down
22 changes: 14 additions & 8 deletions docs/design/concurrent-author-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ A write is **proven independent** only when all of these hold:
| An object under a kustomization, a generator source, or any layout the worker renders | unknown | no |
| An object the index cannot place | unknown | no |

"No" closes every other open window first, which is today's behavior, reported as
`identity_change` as it is now. The rule never guesses: unknown is treated as overlapping
"No" closes every other open window first, reported as `unproven_footprint` (`identity_change`
before the split into precise reasons). The rule never guesses: unknown is treated as overlapping
everything. Shared files and kustomize layouts are the obvious next candidates once the base change
is measured; each needs its own proof.

Expand Down Expand Up @@ -200,7 +200,9 @@ unrelated push split a save that is protected today.
| `buffer_limit` | every window | none |
| `path_conflict` | the windows whose footprint the new write overlaps | none |
| `footprint_fallback` | every window but the newest, when a commit outside its footprint makes the worker hold one window at a time | none |
| `identity_change` | every other window | stays for writes of another `GitTarget` and for unproven footprints |
| `other_target` | every other window, before a write of another `GitTarget` | none |
| `unproven_footprint` | a window whose footprint, or the write's, cannot be proven | none |
| `single_window` | every other window, once the worker holds one window at a time | none |
| `idle_timeout`, `max_duration`, `attach_next` | that window only | none |

Why the first two exist matters for every later change to them:
Expand Down Expand Up @@ -304,7 +306,7 @@ release, because stage 2 shipped without a flag.
model. Every existing test passes unchanged.
2. **Built. Allow several windows for proven-independent destinations.** Writes keep whole-object commits
and apply behavior stays as it is. Writes of another `GitTarget` keep closing other windows
(`identity_change`), and every layout in the footprint table's "no" rows stays serial.
(`other_target`), and every layout in the footprint table's "no" rows stays serial.
3. **Built. Test the failure boundaries.** Both close orders,
conflicting writes, delete and recreate, `attach_next`, zero-duration windows, resync, shutdown,
failed publication and replay, and buffer pressure, each against the reference model, which
Expand All @@ -313,10 +315,10 @@ release, because stage 2 shipped without a flag.
the release instead of a default-off rollout. What the flag's measurement period was for is read
from the metrics: `git_commit_windows_open` shows windows open side by side,
`git_commit_windows_single` a worker that fell back to one at a time, and
`git_commit_windows_total` by `close_reason` the forced splits (`identity_change`,
`path_conflict`, `footprint_fallback`). Memory is not measured yet: the retained-byte budget
charges windows and pending writes, but not the footprint indexes, the accepted versions or the
withheld-field records.
`git_commit_windows_total` by `close_reason` the forced splits (`path_conflict`,
`unproven_footprint`, `other_target`, `single_window`, `footprint_fallback`). Memory is not
measured yet: the retained-byte budget charges windows and pending writes, but not the footprint
indexes, the accepted versions or the withheld-field records.
5. **Proposed. Reconsider the follow-ups** in
[window-field-ownership-and-apply-hold.md](window-field-ownership-and-apply-hold.md), using those
measurements. Field ownership and the apply hold are separate changes, each with its own
Expand Down Expand Up @@ -453,3 +455,7 @@ branch stay serial; the proof at arrival is the placement index, with its cost u
2. Is a cap on open windows needed beyond the byte cap, such as one per `GitTarget`?
3. When a save's own window is closed early by `path_conflict`, it commits with the save's message
and less than the person meant to save. Is that acceptable, or should the save report it?
**Answered:** the save reports it, for this and every other close a write outside the window
causes (`unproven_footprint`, `other_target`, `single_window`, `footprint_fallback`). The request
ends as before, and its `Ready` and `Reconciling` messages add why the window closed early, so its
edits after that are not part of the save.
6 changes: 3 additions & 3 deletions docs/design/push-cooldown.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ when it cannot sit beside them:

| Source | Close reason |
| --- | --- |
| A write of another `GitTarget` on the same branch (per-target encryption and bootstrap stay serial) | `author-or-target-change` |
| A write, or an open window, whose footprint cannot be proven | `author-or-target-change` |
| A worker that fell back to one window at a time | `author-or-target-change`, after `footprint-fallback` |
| A write of another `GitTarget` on the same branch (per-target encryption and bootstrap stay serial) | `other-target` |
| A write, or an open window, whose footprint cannot be proven | `unproven-footprint` |
| A worker that fell back to one window at a time | `single-window`, after `footprint-fallback` |
| Overlapping footprints | `path-conflict` |
| The retained-byte budget | `buffer-limit` |
| `commit.window.idleTimeout: 0s` | every event commits on arrival |
Expand Down
19 changes: 13 additions & 6 deletions docs/interpreting-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ boundary, the commit, the push. Background:
| `git_queue_refusals_total` | counter | `gitbranch_namespace`, `gitbranch_name`, `provider_namespace`, `provider_name`, `kind` | Work refused at enqueue: the queue was full, intake was paused through an outage, or the worker was stopping. `kind` is `write` / `attach` / `resync` / `refresh`. The producer keeps a refused item and offers it again: the watch delivers a write again from its cursor, the controller re-sends a save, a resync is gathered again, and the next reconcile asks for a refresh. What it can cost, when its watch cursor expires before the write comes back, is the write's own commit and, under `prune.mode: OnEvent`, a deleted object's removal from Git. |
| `git_commit_failures_total` | counter | `gitbranch_namespace`, `gitbranch_name`, `provider_namespace`, `provider_name`, `reason` | A live commit window that died between routing and pushing; a resync's failure is `git_resync_failures_total`. `reason` is `refused` (a Git path a human must fix) / `error`. Every increment is a window's events lost until the next resync. An unreachable remote does not count: a decided window waits for the publication retry instead. |
| `git_writes_dropped_total` | counter | `gitbranch_namespace`, `gitbranch_name`, `provider_namespace`, `provider_name`, `reason` | A live event the branch worker dropped because its `GitTarget`'s render fidelity was not established. `reason` is `render_fidelity_diverged`: a rendered value does not match the live object, and every write is dropped until a fresh replay measures the folder clean. Or it is `render_fidelity_pending`: a collection of the `GitTarget` has not finished its replay, which closes every collection of that target until it does. A live event that meets a pending gate is held, not dropped, and committed with its author once the gate opens; it is counted here only when the hold gives up, 10 minutes after the first one was held or once the branch holds more than its retained-byte budget, and the worker then asks for a fresh snapshot, which commits the current state as the operator (a deletion comes back only under prune mode `Always`). Nothing replays a dropped write, so each one is an edit missing from Git until the object changes again or its collection replays. The worker logs the first drop under each gate status at Info, naming the collections the gate waits for, and each hold, release and give-up at Info. |
| `git_commit_windows_total` | counter | `gittarget_namespace`, `gittarget_name`, `close_reason`, `timer_source` | One per closed commit window, whether or not it then produced a commit. `close_reason` is `idle_timeout` / `max_duration` / `attach_next` / `identity_change` / `path_conflict` / `footprint_fallback` (a commit changed a file outside its window's footprint, so the worker holds one window at a time from then on, and closes all but the newest of the windows open) / `buffer_limit` / `resync_before_apply` / `foreign_commit` (a Git host said the branch may have moved, so the window is published now) / `apply_due` (an apply came due for an applier on the branch, so the window's edits are published before the apply is sent) / `shutdown`; `timer_source` is `target` or `commit_request`. See [tuning commit windows](#tuning-commit-windows). |
| `git_commit_windows_total` | counter | `gittarget_namespace`, `gittarget_name`, `close_reason`, `timer_source` | One per closed commit window, whether or not it then produced a commit. `close_reason` is `idle_timeout` / `max_duration` / `attach_next` / `path_conflict` / `unproven_footprint` / `other_target` / `single_window` / `footprint_fallback` (a commit changed a file outside its window's footprint, so the worker holds one window at a time from then on, and closes all but the newest of the windows open) / `buffer_limit` / `resync_before_apply` / `foreign_commit` (a Git host said the branch may have moved, so the window is published now) / `apply_due` (an apply came due for an applier on the branch, so the window's edits are published before the apply is sent) / `shutdown`; `timer_source` is `target` or `commit_request`. See [tuning commit windows](#tuning-commit-windows). |
| `git_commit_window_duration_seconds` | histogram | `gittarget_namespace`, `gittarget_name` | How long each window collected: from the write that opened it to the start of its finalize. Its count equals `git_commit_windows_total` summed over `close_reason` and `timer_source`. |
| `git_commit_windows_open` | gauge | `gitbranch_namespace`, `gitbranch_name`, `provider_namespace`, `provider_name` | Commit windows the branch worker holds open. Above 1 means authors are collecting side by side, one window each, because their files are proven not to overlap. A branch that only ever reads 0 or 1 while several people edit it gets no concurrency: their writes are in shared files, kustomize folders, or another layout the worker cannot prove independent. Read at scrape time. |
| `git_commit_windows_single` | gauge | `gitbranch_namespace`, `gitbranch_name`, `provider_namespace`, `provider_name` | 1 once the branch worker has fallen back to one commit window at a time, after a commit would have changed a file outside its window's footprint (a bug: the worker refused the commit and asked for a resync). It stays 1 until the worker restarts. The worker logs the refused paths at Error (`SingleWindowFallback`). Read at scrape time. |
Expand Down Expand Up @@ -647,13 +647,20 @@ picture toward `max_duration`.
writes kept arriving closer together than `idleTimeout`; raise `maxDuration` if those changes
belong in one commit. It does not prove continuous activity: an `idleTimeout` close to
`maxDuration` ends quiet windows this way too.
- `identity_change` means a write arrived that could not join an open window, nor be proven to change
other files than it: a different GitTarget on the same branch, or a different author or
attribution state writing where the worker cannot prove a file of its own (a file with other
documents, a kustomize folder, a placement template). A high share means commits are being split
by interleaving rather than by time, and no timer changes that.
- `path_conflict` means another author's write changes a file the window's writes change, so the
window committed first. Authors editing different files keep a window each.
- `unproven_footprint` means another author, or another attribution state, wrote where the worker
cannot prove the files apart: a file with other documents, a kustomize folder, a placement
template, an encrypted type. The write, or the window, may touch the other's file, so the window
committed first.
- `other_target` means a write of another GitTarget on the same branch arrived: GitTargets on one
branch commit one window at a time, for their encryption and bootstrap.
- `single_window` means another author wrote after the worker fell back to one window at a time (see
`footprint_fallback`), so their windows no longer stay open side by side.

These four split commits by interleaving rather than by time, and no timer changes that. With
`timer_source="commit_request"` they count saves cut short: the save commits what its window held
when it closed, and its `Ready` message says why.
- `attach_next` is a save with `attach: Next` closing the author's open window before it waits.
- `buffer_limit` means the worker's retained-write budget was reached, and the window was flushed
to stay within it. Writes committed but not yet pushed count toward that budget, so this reads
Expand Down
45 changes: 45 additions & 0 deletions internal/controller/commitrequest_controller_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,12 @@ func TestCommitRequestReconcile_TerminalWriteRetriesOnConflict(t *testing.T) {

// --- pure helpers (formerly internal/queue/commit_request_test.go) ---

// windowClosedEarlyValues are every value git.FinalizeResult.WindowClosedEarly takes.
var windowClosedEarlyValues = []string{
git.WindowClosedEarlyPathConflict, git.WindowClosedEarlyUnprovenFootprint, git.WindowClosedEarlyOtherTarget,
git.WindowClosedEarlySingleWindow, git.WindowClosedEarlyFootprintFallback,
}

func TestApplyFinalizeResultToStatus(t *testing.T) {
t.Run("committed", func(t *testing.T) {
var cr configv1alpha3.CommitRequest
Expand Down Expand Up @@ -780,6 +786,45 @@ func TestApplyFinalizeResultToStatus(t *testing.T) {
assert.Equal(t, "boom", stalled.Message)
})

t.Run("a window another write closed early says why, and still settles as its outcome", func(t *testing.T) {
for _, closedEarly := range windowClosedEarlyValues {
note := windowClosedEarlyNote(closedEarly)
for _, outcome := range []git.FinalizeOutcome{git.FinalizeCommitted, git.FinalizeAlreadyPresent} {
var cr configv1alpha3.CommitRequest
applyFinalizeResultToStatus(&cr, git.FinalizeResult{Outcome: outcome, Commit: "abc", Branch: "main",
WindowClosedEarly: closedEarly}, nil)
want := "; the window closed early, because " + note +
": edits made after that are not part of this save"
for _, conditionType := range []string{ConditionTypeReady, ConditionTypeReconciling} {
condition := apimeta.FindStatusCondition(cr.Status.Conditions, conditionType)
require.NotNil(t, condition, "%s %s", closedEarly, outcome)
assert.True(t, strings.HasSuffix(condition.Message, want), "%s %s %s: %q",
closedEarly, outcome, conditionType, condition.Message)
}
requireCondition(t, cr, ConditionTypeReady, metav1.ConditionTrue, string(outcome))
}
}

var failed configv1alpha3.CommitRequest
applyFinalizeResultToStatus(&failed, git.FinalizeResult{Outcome: git.FinalizeCommitted,
WindowClosedEarly: git.WindowClosedEarlyPathConflict}, errors.New("boom"))
stalled := requireCondition(t, failed, ConditionTypeStalled, metav1.ConditionTrue, crReasonFinalizeFailed)
assert.Equal(t, "boom", stalled.Message, "a failure says only why it failed")
})

t.Run("every way a window closes early has its own note, and nothing else has one", func(t *testing.T) {
notes := map[string]bool{}
for _, closedEarly := range windowClosedEarlyValues {
note := windowClosedEarlyNote(closedEarly)
assert.NotEmpty(t, note, closedEarly)
assert.False(t, notes[note], "%s shares its note", closedEarly)
notes[note] = true
}
for _, other := range []string{"", "idle_timeout", "max_duration", "shutdown", "made_up"} {
assert.Empty(t, windowClosedEarlyNote(other), other)
}
})

t.Run("unknown outcome stalls", func(t *testing.T) {
var cr configv1alpha3.CommitRequest
applyFinalizeResultToStatus(&cr, git.FinalizeResult{}, nil)
Expand Down
35 changes: 35 additions & 0 deletions internal/controller/commitrequest_finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,41 @@ func applyFinalizeResultToStatus(
// An empty or unknown outcome with no error is a bug, not a benign
// rejection; fail it so it is not silently hidden.
failCommitRequest(cr, crReasonUnexpectedOutcome, "unexpected finalize outcome: "+string(result.Outcome))
return
}
if note := windowClosedEarlyNote(result.WindowClosedEarly); note != "" {
appendCommitRequestMessage(cr, "; the window closed early, because "+note+
": edits made after that are not part of this save", ConditionTypeReady, ConditionTypeReconciling)
}
}

// windowClosedEarlyNote says why a write outside the request's window closed it early, for a
// git.FinalizeResult.WindowClosedEarly; "" for any other value. The request still settles as its outcome
// says, but it saves less than its author may have meant to.
func windowClosedEarlyNote(closedEarly string) string {
switch closedEarly {
case git.WindowClosedEarlyPathConflict:
return "another author's write touched a file it held"
case git.WindowClosedEarlyUnprovenFootprint:
return "another author wrote while the files of that write, or of this window, could not be proven apart"
case git.WindowClosedEarlyOtherTarget:
return "a write of another GitTarget on the same branch arrived, and GitTargets on one branch " +
"commit one at a time"
case git.WindowClosedEarlySingleWindow:
return "another author wrote while the branch worker holds one window at a time"
case git.WindowClosedEarlyFootprintFallback:
return "the branch worker fell back to one window at a time"
default:
return ""
}
}

// appendCommitRequestMessage adds note to the message of each of cr's conditions named.
func appendCommitRequestMessage(cr *configv1alpha3.CommitRequest, note string, conditionTypes ...string) {
for _, conditionType := range conditionTypes {
if condition := apimeta.FindStatusCondition(cr.Status.Conditions, conditionType); condition != nil {
condition.Message += note
}
}
}

Expand Down
Loading