Prune safety

Orbit verifies the complete source before applying workloads. Git/path/read, token, conditional-list or scope uncertainty aborts the pass. Manifest syntax/state errors and API discovery failures, including unavailable CRDs/APIs, timeouts and access errors, are reported per item while independent valid manifests continue. A YAML stream parse error stops the unreadable remainder of that file; already parsed documents and other files remain eligible. A skipped desired document is never evidence of intended removal. Every manifest/compile/apply error blocks that pass's automatic pruning and preserves old tracking.

Processing of later desired objects continues after an apply failure, including their configured recreation DELETE/CREATE. That behavior does not authorize the final pruning pass after a failed apply.

Access errors must propagate; they are not evidence that a directory or metadata file is absent. Cluster replacement defaults are published only after their inputs have been read successfully. Missing named Git refs abort reconciliation on every retry until available; stale local refs are not substitutes. The selected source must match the selected committed Git tree before and after rendering. Validation checks directory membership, file contents and linked inputs independently of Git's index/stat cache. A checkout reporting success does not establish completeness. Git's LF/CRLF and canonical ident conversions are accepted; other marker expansions and custom content-changing checkout filters abort the run. Genuine committed removals still authorize pruning; a missing selected source directory does not. Avoid ambiguous bare hexadecimal branch/tag names as described in the Git source documentation.

After successful processing, pruning is automatic. Targets come from the OD's status.managedObjects, retaining pending tracking when a status write fails; they are never constructed from a possible replacement manifest. A candidate must be tracked, absent from the complete desired inventory and currently owned by the worker in kube-system/orbit-deployment-owners. Identity is API group, kind, namespace and name; changing the served API version does not remove that identity. There are no approval settings, extra prune policies or workload-health gates. Cross-group API aliases remain a deferred limitation in TODO.md.

Only one worker for an OD may run at a time. Retirement blocks registration until the previous thread ends. Forced retirement of a thread that will not stop terminates the controller process instead of starting an overlapping worker. Failure to start a retirement reaper also terminates the controller while the retirement barrier remains in place. A surviving blocked worker cannot resume alongside its replacement. The supplied controller Deployment uses destroy-before-create (Recreate).

Shared ownership

Resource locks serialize competing ownership decisions and mutations while unrelated resources make API requests concurrently. Each transaction reads its own fresh authoritative ConfigMap snapshot and commits ownership synchronously with UID/resourceVersion checks. On a conflicting write, it merges unrelated entries only if the target claim and ConfigMap UID remain unchanged. A changed target aborts the transaction. Monitoring and metrics do not hold resource locks. Malformed snapshots, failed reads and failed writes stop the affected operation. Missing storage is initialized only after a confirmed absence. See ownership transactions for concurrency, legacy aliases, bounded retries, nested recreation and failure handling.

Owner identity is the OrbitDeployment namespace/name plus priority. Object UID and resourceVersion are fresh request preconditions against races, not extra owner identity. The object mutation and ownership write are separate API calls; a crash between them can leave state requiring reconciliation or inspection.

Protection flags

  • k8s.tlspu.com/no-update or noupdate in the rendered Git manifest blocks in-place updates/replaces. Live-only flags are ignored. Removing or disabling the Git flag resumes updates without a manual live edit. Creation is allowed.
  • Live k8s.tlspu.com/no-delete or nodelete blocks DELETE for pruning, recreation and cleanup. Normal removal releases tracking/ownership while retaining the object; blocked recreation retains tracking. The flag does not block an otherwise permitted update that changes or removes it.
  • recreate-on-change deletes the verified old tracked reference before replacement. Only live no-delete on that old target blocks its DELETE; desired-only no-delete protection and Git no-update do not.

CREATE and REPLACE stamp a controller-managed k8s.tlspu.com/applied-manifest annotation with the deployment namespace/name and desired content hash. For a currently owned object, this durable receipt takes precedence over the status hash, so a failed status PATCH followed by a controller restart does not repeat a successful recreation. The receipt does not grant ownership or DELETE authority; those still come from the shared ownership ConfigMap.

Flags accept true, 1, yes and on, ignoring case. Namespace and CRD protection applies to that target only. Protect the parent itself to retain it; Orbit does not inspect descendants before deletion, and Kubernetes cascades can remove children carrying their own no-delete flag.

Purge and forced reapplication

Purge clears managed-object/error status after its status PATCH succeeds and requests a full eligible reapply. It never reads or mutates the ownership store, so the deployment retains its priority against competing ODs throughout the operation. It does not directly apply or delete workloads. Clearing tracking also forgets previously managed objects absent from source; their ownership claims remain and their future lifecycle needs separate operator inspection.

The worker snapshots a Purge generation before acquiring ownership for an apply pass. Successful completion acknowledges only that snapshot; a concurrent Purge remains pending for a subsequent complete pass. Failures retain the request for retry. The forced pass bypasses unchanged-content/live-receipt skips while retaining ownership, scope and Git no-update checks. Missing tracking also requires an apply, allowing cleared entries to rebuild after a restart without losing their ownership.

Live receipts still distinguish unchanged content from a genuine change when evaluating recreate-on-change. Reapplying an unchanged object uses REPLACE, preserving its UID; Purge alone must not cause DELETE/CREATE. A genuine Git-controlled recreation still requires the old tracked target and follows the normal ownership/no-delete rules.

Cleanup and verification

Confirmed OrbitDeployment deletion makes one best-effort cleanup attempt with the same ownership and live no-delete checks. An existing/recreated source CR or uncertain read blocks cleanup. There is deliberately no finalizer or durable retry queue; missed events or failed requests can leave resources behind. One target's cleanup failure does not stop checks for subsequent targets; every target requires its own successful scope, ownership and protection reads.

When a parent OrbitDeployment loads a child OrbitDeployment, a live no-delete annotation on the child retains that child during parent cleanup. The parent releases its tracking and ownership of the child; the child's worker and its managed resources remain independent. This does not prevent Kubernetes from removing the child if its Namespace is deleted.

Run the unit suite and, when available, the opt-in disposable-cluster tests in tests/test_install_safety.py. They require an explicit loopback kind kubeconfig and do not select the user's normal kubeconfig. Target-cluster outage, crash, concurrency and performance acceptance remain tracked in TODO.md.

A complete but unintended Git change can legitimately remove resources. Normal updates and Kubernetes parent cascades can also reduce availability. These checks address uncertainty-driven pruning; they do not make every outage or over-pruning mathematically impossible.