Skip to content

add crd binding#344

Merged
f-leu merged 2 commits intomainfrom
crd-binding
Apr 2, 2026
Merged

add crd binding#344
f-leu merged 2 commits intomainfrom
crd-binding

Conversation

@f-leu
Copy link
Copy Markdown
Contributor

@f-leu f-leu commented Mar 27, 2026

● MPA V3: WorkloadRule two-way CRD sync — collector Add/Delete/Update handlers

📚 Description of Changes

  • What Changed:
    Extended the WorkloadRule collector to handle the full CRD lifecycle — AddFunc, DeleteFunc, and spec-change UpdateFunc — so kubectl-applied or CP-pushed CRDs
    are reported back to the control plane via SendResourceBatch. Previously the collector only sent on OOM/throttle status changes.
  • Why This Change:
    MPA V3 introduces two-way sync between WorkloadRule CRDs and the control plane DB. When a user applies a WorkloadRule via kubectl, the control plane needs to
    know about it to create a DB record. When a CRD is deleted from the cluster, the CP needs to clean up. Without these handlers, only OOM events were sent —
    spec additions and deletions were silently ignored.
  • Affected Components:
  • Compose
  • K8s
  • Other

❓ Motivation and Context

  • Context:
    Part of the MPA V3 initiative that replaces the policy→target→recommendation model with per-workload WorkloadRule CRDs. The control plane already handles
    ingestion of Add/Update/Delete events (RESOURCE_TYPE_WORKLOAD_RULE in metrics_collector.go) — this PR is the zxporter-side counterpart that generates those
    events.
  • Relevant Tasks/Issues:
    Related services PR: crd-binding branch (implements CP ingestion, new optimization policies, deletion flow, and UI)

🔍 Types of Changes

  • BUGFIX: Non-breaking fix for an issue.
  • NEW FEATURE: Non-breaking addition of functionality.
  • BREAKING CHANGE: Fix or feature that causes existing functionality to not work as expected.
  • ENHANCEMENT: Improvement to existing functionality.
  • CHORE: Changes that do not affect production.

🔬 QA / Verification Steps

  1. Deploy zxporter to a Kind cluster with the dakr CRD installed
  2. Apply a CollectionPolicy and verify the workload-rule-collector starts ("workload_rule" collector started in logs)
  3. kubectl apply a WorkloadRule CRD — verify zxporter logs "WorkloadRule added, sending to control plane" and sends a workload_rule batch
  4. Edit the CRD spec — verify zxporter detects the spec change and sends an update event
  5. kubectl delete the CRD — verify zxporter logs "WorkloadRule deleted, sending to control plane" with EVENT_TYPE_DELETE
  6. Existing OOM/throttle event extraction continues to work unchanged

✅ Global Checklist

  • I have read and followed the .github/CONTRIBUTING.md.
  • My code follows the code style of this project.
  • I have updated the documentation as needed.
  • I have added tests that cover my changes.
  • All new and existing tests have passed locally.
  • I have run this code in a local environment to verify functionality.
  • I have considered the security implications of this change.

@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 2, 2026

Code Review ✅ Approved

Adds CRD binding support to zxporter. No issues found.

Was this helpful? React with 👍 / 👎 | Gitar

@f-leu f-leu merged commit cc101ce into main Apr 2, 2026
26 checks passed
@f-leu f-leu deleted the crd-binding branch April 2, 2026 17:57
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.

2 participants