Skip to content

Remove deprecated operator status fields#127

Open
hardbyte wants to merge 5 commits into
mainfrom
opencode/operator-crd-cleanup
Open

Remove deprecated operator status fields#127
hardbyte wants to merge 5 commits into
mainfrom
opencode/operator-crd-cleanup

Conversation

@hardbyte

@hardbyte hardbyte commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • remove deprecated PostgresPolicy status fields planned_sql, planned_sql_truncated, and last_reconcile_time
  • default omitted spec.approval to manual and document approval: auto for immediate apply
  • add Kubernetes map-list semantics for spec.schemas, spec.roles, and spec.retirements
  • regenerate PostgresPolicy CRD and bump chart metadata

Closes #73
Closes #126

Validation

  • cargo fmt --all
  • SQLX_OFFLINE=true cargo clippy --all-targets --all-features -- -D warnings
  • SQLX_OFFLINE=true cargo build --workspace
  • cargo test --workspace
  • scripts/check-crd-drift.sh

Summary by CodeRabbit

  • Added

    • 0.7.9 release entry and examples showing approval: auto.
  • Changed

    • Operator defaults to manual approval when spec.approval is omitted.
    • Plan SQL previews are surfaced via dedicated plan resources instead of policy status.
    • Policy list fields (schemas/roles/retirements) now merge as keyed map-lists for better server-side-apply/GitOps behavior.
  • Removed

    • Deprecated/plan-only status fields cleaned from status schema.
  • Chores

    • Version bumped to 0.7.9; docs and samples updated.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 978c781a-7902-45a7-9597-974a3acb8f9d

📥 Commits

Reviewing files that changed from the base of the PR and between 92d3dbe and 926c9a9.

📒 Files selected for processing (5)
  • charts/pgroles-operator/crds/postgrespolicies.pgroles.io.yaml
  • crates/pgroles-operator/src/crd.rs
  • crates/pgroles-operator/src/reconciler.rs
  • docs/src/pages/docs/operator.md
  • k8s/crd.yaml
✅ Files skipped from review due to trivial changes (1)
  • docs/src/pages/docs/operator.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • k8s/crd.yaml

📝 Walkthrough

Walkthrough

Bumps package/chart to 0.7.9, removes deprecated PostgresPolicy status fields (planned_sql, planned_sql_truncated, last_reconcile_time), teaches CRDs that spec.schemas/roles/retirements are keyed map-lists, defaults omitted approval to Manual, and updates reconciler, tests, docs, samples, CI, and release notes.

Changes

PostgresPolicy CRD Deprecation & Cleanup

Layer / File(s) Summary
CRD list-key semantics for named arrays
crates/pgroles-operator/src/crd.rs, charts/pgroles-operator/crds/postgrespolicies.pgroles.io.yaml, k8s/crd.yaml, crates/pgroles-operator tests
Adds schemars extend annotations and regenerated CRDs so spec.schemas, spec.roles, and spec.retirements are emitted with x-kubernetes-list-type: map and x-kubernetes-list-map-keys. Adds a unit test that asserts the generated CRD contains the expected list-map markers.
Approval mode default behavior
crates/pgroles-operator/src/crd.rs, tests
PostgresPolicySpec::effective_approval() now returns ApprovalMode::Manual when spec.approval is omitted; tests updated to assert the new defaulting behavior (including apply-mode cases).
Removal of deprecated status fields
crates/pgroles-operator/src/crd.rs, crates/pgroles-operator/src/reconciler.rs, charts/pgroles-operator/crds/postgrespolicies.pgroles.io.yaml, k8s/crd.yaml
Removes last_reconcile_time, planned_sql, and planned_sql_truncated from the PostgresPolicyStatus struct and both committed CRD copies. Reconciler no longer renders/truncates/stores planned SQL; status updates now use change_summary and last_reconcile_mode and keep last_successful_reconcile_time. Tests referencing removed fields were updated or removed.
Documentation, samples, CI and release metadata
CHANGELOG.md, charts/pgroles-operator/Chart.yaml, Cargo.toml, docs/src/pages/docs/*, k8s/samples/*, scripts/generate-load-policy.sh, .github/workflows/ci.yml
Bumps versions to 0.7.9 and extends Artifact Hub changelog annotations. Docs updated to reference PostgresPolicyPlan for SQL previews and last_successful_reconcile_time. Sample manifests and generation script add approval: auto where examples show auto-approval. CI e2e adjusted to fetch plan SQL from the generated PostgresPolicyPlan rather than .status.planned_sql.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • hardbyte/pgroles#100: Related removal of legacy PostgresPolicy.status.planned_sql* fields and updates to plan artifact handling.
  • hardbyte/pgroles#102: CI/CRD work ensuring PostgresPolicyPlan CRD availability (relevant to moving SQL previews to plan CRs).
  • hardbyte/pgroles#74: Approval/plan workflow changes that connect to effective approval defaulting and plan-based execution.

"I nibble at diffs and tidy the plot,
CRD keys line up each YAML spot.
Plans moved out to their proper den,
Manual approval — carrot for when.
Release stamped, I hop off to trot!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove deprecated operator status fields' accurately summarizes the main changes: removal of planned_sql, planned_sql_truncated, and last_reconcile_time from PostgresPolicyStatus.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from #73 and #126: removes deprecated status fields [#73], defaults spec.approval to manual [#73], adds x-kubernetes-list-type/map-keys for spec.schemas/roles/retirements [#126], regenerates CRD artifacts, and bumps versions.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issues: status field removal, approval defaulting, map-list CRD semantics, version bumps, documentation updates, and sample policy updates to demonstrate approval:auto. No unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 92.59% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6399d53550

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +8 to +9
version: 0.7.9
appVersion: "0.7.9"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align chart version with the workspace release

With the chart bumped to 0.7.9, a v0.7.9 tag will pass the Helm workflow's chart/tag check and the chart will default the operator image tag to .Chart.AppVersion, but the Rust workspace in Cargo.toml is still 0.7.8 and the release workflow publishes/builds from that version. In a 0.7.9 release this leaves the Helm chart pointing at 0.7.9 while the packaged binaries/crates still report or publish as 0.7.8, and cargo publish can fail if 0.7.8 is already published.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CHANGELOG.md (1)

8-8: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Align changelog release header with bumped chart/app version.

The changelog entries added in this PR are under 0.7.8, but charts/pgroles-operator/Chart.yaml is bumped to 0.7.9. Please align the release number to avoid ambiguous release notes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 8, The changelog release header currently reads "##
[0.7.8] - 2026-06-04" but the chart/app version was bumped to 0.7.9; update the
header in CHANGELOG.md to "## [0.7.9] - 2026-06-04" (or the correct release date
if different) so the CHANGELOG entry matches the bumped Chart version referenced
in charts/pgroles-operator/Chart.yaml.
🧹 Nitpick comments (1)
crates/pgroles-operator/src/crd.rs (1)

3759-3774: ⚡ Quick win

Strengthen the CRD map-list test with field-scoped assertions.

This test currently relies on global substring checks, so it can still pass even if one specific list (schemas/roles/retirements) loses its x-kubernetes-list-* metadata.

Suggested refactor
 #[test]
 fn postgres_policy_crd_marks_named_lists_as_maps() {
     let crd = PostgresPolicy::crd();
-    let yaml = serde_yaml::to_string(&crd).expect("CRD should serialize to YAML");
-
-    for field_name in ["schemas", "roles"] {
-        assert!(
-            yaml.contains(&format!("{field_name}:\n")),
-            "CRD should contain spec.{field_name}"
-        );
-    }
-    assert!(yaml.contains("x-kubernetes-list-type: map"));
-    assert!(yaml.contains("x-kubernetes-list-map-keys:"));
-    assert!(yaml.contains("- name"));
-    assert!(yaml.contains("- role"));
+    let v = serde_yaml::to_value(&crd).expect("CRD should serialize to value");
+    let spec_props = &v["spec"]["versions"][0]["schema"]["openAPIV3Schema"]["properties"]["spec"]["properties"];
+
+    for (field, key) in [("schemas", "name"), ("roles", "name"), ("retirements", "role")] {
+        let schema = &spec_props[field];
+        assert_eq!(schema["x-kubernetes-list-type"], "map", "spec.{field} should be map-list");
+        assert_eq!(schema["x-kubernetes-list-map-keys"][0], key, "spec.{field} should be keyed by {key}");
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/pgroles-operator/src/crd.rs` around lines 3759 - 3774, The test
postgres_policy_crd_marks_named_lists_as_maps uses global substring checks;
change it to scope assertions to each field by locating the index of the field
header produced by PostgresPolicy::crd() (e.g., find
yaml.find(&format!("{field_name}:\n"))), then assert that the slice after that
index contains "x-kubernetes-list-type: map" and "x-kubernetes-list-map-keys:",
and also assert the expected map key for that field (for "schemas" assert the
following slice contains "- name", for "roles" assert it contains "- role", and
include any other named list like "retirements" with its expected key) so each
named list is independently verified.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@CHANGELOG.md`:
- Line 8: The changelog release header currently reads "## [0.7.8] - 2026-06-04"
but the chart/app version was bumped to 0.7.9; update the header in CHANGELOG.md
to "## [0.7.9] - 2026-06-04" (or the correct release date if different) so the
CHANGELOG entry matches the bumped Chart version referenced in
charts/pgroles-operator/Chart.yaml.

---

Nitpick comments:
In `@crates/pgroles-operator/src/crd.rs`:
- Around line 3759-3774: The test postgres_policy_crd_marks_named_lists_as_maps
uses global substring checks; change it to scope assertions to each field by
locating the index of the field header produced by PostgresPolicy::crd() (e.g.,
find yaml.find(&format!("{field_name}:\n"))), then assert that the slice after
that index contains "x-kubernetes-list-type: map" and
"x-kubernetes-list-map-keys:", and also assert the expected map key for that
field (for "schemas" assert the following slice contains "- name", for "roles"
assert it contains "- role", and include any other named list like "retirements"
with its expected key) so each named list is independently verified.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ba00f5e5-113c-4e01-b0fc-7976cf99b6ff

📥 Commits

Reviewing files that changed from the base of the PR and between f9e8818 and 6399d53.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • charts/pgroles-operator/Chart.yaml
  • charts/pgroles-operator/crds/postgrespolicies.pgroles.io.yaml
  • crates/pgroles-operator/src/crd.rs
  • crates/pgroles-operator/src/reconciler.rs
  • docs/src/pages/docs/operator.md
  • k8s/crd.yaml
💤 Files with no reviewable changes (1)
  • crates/pgroles-operator/src/reconciler.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add key-aware CRD list semantics for named spec arrays Remove deprecated planned_sql from PostgresPolicy status

1 participant