Skip to content

feat: feedback CRDs and operator scaffold - #32

Merged
mattdjenkinson merged 4 commits into
mainfrom
feat/crds
Nov 18, 2026
Merged

mattdjenkinson merged 4 commits into
mainfrom
feat/crds

Conversation

@mattdjenkinson

Copy link
Copy Markdown
Contributor

Closes #2. First PR of the CRD rewrite: the design moved from an aggregated apiserver with Postgres to CRDs in Milo with an operator, like billing (design change). This replaces #16 and the Postgres stack (#22, #23, #25–#31), which I'm closing.

What's here

  • Every v1alpha1 kind is a cluster-scoped CRD, generated by controller-gen into config/crd, for installing in Milo.
  • A feedback operator command. It's a controller-runtime manager pointed at Milo with --milo-kubeconfig, plus a webhook server, health probes, metrics, and leader election in the local cluster. No controllers or webhooks are registered yet; they come in the next PRs.
  • Deployment config.
    • config/base/operator: Deployment, Services, PDB and leader-election RBAC.
    • config/components/milo-integration: Milo kubeconfig, client certificate and webhook certificate from the datum-control-plane issuer, the same way billing does it.
  • Removed: the aggregated apiserver, the APIService, Postgres, migrations, the clientset and OpenAPI generation, and the discovery policy. CRD annotations now declare discovery contexts.

API changes from the Postgres version

Change Why
Vote, Subscription, Submission, SecurityReport and FeedbackProfile carry spec.userRef. They declare iam.miloapis.com/owner-field: spec.userRef.name and make it a selectable field. Milo stores user-context objects in one platform-wide collection. milo-os/milo#1017 uses this annotation to limit each user to their own objects.
Vote and Subscription names are <post>.<user>, enforced by CEL. One per user per post, across that shared collection.
Post declares iam.miloapis.com/hidden-field: spec.hidden. Milo hides hidden posts from anyone without get on posts/hidden.
New SubmissionReview CRD: triage and the staff decision (Approved, Merged, Rejected, MoveToSecurity). CEL makes the decision immutable once set and requires its fields. Replaces the review and to-security-report subresources and the submitter redaction. A CRD can't hide a field from some readers, so staff-only data lives on a staff-only kind.
New SecurityReportTriage CRD. Replaces status.internal on reports, for the same reason.
New FeedbackProfile and FeedbackDigest CRDs. The public-votes setting, and the digest queue that was a Postgres table.
votes.trendingScore is an integer (score × 1000). controller-gen rejects floats; clients only sort on it.
Posts get feedback.miloapis.com/{org,status,stage} and category.feedback.miloapis.com/<category> labels. So clients can filter with label selectors. Sorting and counts happen in clients.
Removed PostQuery, AttachmentUpload and SubmissionToSecurityReport.
Specs of votes, follows, submissions and reports are immutable (CEL).

Tests

  • task test now fetches envtest binaries and runs pkg/apis/.../crd_test.go against a real API server with the generated CRDs. It covers:
    • every sample is accepted;
    • vote names follow the rule, and vote spec is immutable;
    • field selectors work on owner and post;
    • spec.hidden!=true filters out hidden posts;
    • review decisions are complete and immutable;
    • submissions can't change;
    • profiles are named after their user.
  • A new envtest job in ci.yaml runs these tests. ci-basic runs plain go test, so they skip there.
  • go vet ./..., task test, and task generate with no diff
  • kustomize build of config/base, config/overlays/core-control-plane and config/crd
  • Container image built (CI)

Replace the aggregated apiserver with CRDs installed in Milo and a
controller-runtime operator, following billing. Every v1alpha1 kind is a
cluster-scoped CRD; user-owned kinds carry spec.userRef and declare it
as Milo's owner field, and posts declare spec.hidden as the hidden
field. Staff-only fields move to SubmissionReview and
SecurityReportTriage. FeedbackProfile and FeedbackDigest are new.

CEL rules enforce vote and follow names, immutable specs and complete
review decisions; an envtest suite checks them against a real API
server.
scotwells
scotwells previously approved these changes Nov 17, 2026
# Conflicts:
#	.github/workflows/ci.yaml
#	go.mod
#	go.sum

Copy link
Copy Markdown

Non-blocking follow-up: readiness currently returns success before the webhook server is necessarily serving TLS (cmd/feedback/operator.go). Once #33 adds fail-closed webhooks, that can cause failed requests during rollouts. Please include the webhook server's StartedChecker() in readiness before enabling those webhooks.

Readiness was a plain ping, so a new operator pod could take webhook
traffic before its TLS listener was up, and Milo's fail-closed webhooks
would refuse requests during rollouts. Use the webhook server's
StartedChecker instead.

Document what must ship before the API is enabled for users: the
Metadata-only audit policy, Milo's owner filtering, and the user and
public-reader bindings.
@mattdjenkinson

Copy link
Copy Markdown
Contributor Author

Done in 2cea230: readiness now includes the webhook server's StartedChecker(), so a pod isn't ready until the webhook server answers TLS. The operator-readiness test in #42 checks this in kind. I also added a "Before enabling for users" section to the README listing the rollout prerequisites, including applying the webhook configurations after the operator is ready.

@mattdjenkinson
mattdjenkinson merged commit b289bf3 into main Nov 18, 2026
6 checks passed
@mattdjenkinson
mattdjenkinson deleted the feat/crds branch November 18, 2026 03:47
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.

Define the v1alpha1 API types

2 participants