Skip to content

Update linage webhook configuration - #1454

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
fix-webhook
Sep 24, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
fix-webhook

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Sep 24, 2025 •

Copy link
Copy Markdown
Member

Signed-off-by: Andrei Kvapil [email protected]

What this PR does

Release note

[]

Summary by CodeRabbit

  • New Features
    • Expanded lineage webhook coverage to include WorkloadMonitor resources, enabling automatic mutation and consistent metadata across these workloads.
    • Added mutation support for Ingresses, helping propagate lineage metadata across HTTP entrypoints for improved traceability and governance.

@coderabbitai

coderabbitai Bot commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Updated the MutatingWebhookConfiguration template: replaced a mutation rule from vmclusters (operator.victoriametrics.com/v1beta1) to workloadmonitors (cozystack.io/v1alpha1) and added a new mutation rule for ingresses (networking.k8s.io/v1) under the lineage webhook.

Changes

Cohort / File(s) Summary
Lineage MutatingWebhookConfiguration
packages/system/cozystack-controller/templates/mutatingwebhookconfiguration.yaml
Replaced mutation rule: vmclusters (operator.victoriametrics.com/v1beta1) → workloadmonitors (cozystack.io/v1alpha1). Added new mutation rule for ingresses (networking.k8s.io/v1).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant KAS as Kubernetes API Server
    participant MWH as lineage.cozystack.io MutatingWebhook

    rect rgb(235, 245, 255)
    note over KAS,MWH: Create/Update WorkloadMonitor (cozystack.io/v1alpha1)
    KAS->>MWH: AdmissionReview (WorkloadMonitor)
    MWH-->>KAS: AdmissionResponse (mutations/patches or allow)
    end

    rect rgb(240, 255, 240)
    note over KAS,MWH: Create/Update Ingress (networking.k8s.io/v1)
    KAS->>MWH: AdmissionReview (Ingress)
    MWH-->>KAS: AdmissionResponse (mutations/patches or allow)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • lllamnyp
  • klinch0

Poem

Thump-thump go my paws, review in sight,
Webhooks realigned in the moonlit night.
From clusters to monitors, neat little hops,
Ingress joins the warren with gentle plops.
Carrot-crowned commits, tidy and bright—
Ship it, and let the pipelines bite! 🥕🚀

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title is concise and directly reflects the primary change in the changeset—updating the webhook configuration (MutatingWebhookConfiguration updates that replace the vmclusters rule with workloadmonitors and add an ingress rule)—so it accurately summarizes the PR; it does contain a minor typo ("linage" → "lineage") but remains understandable.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-webhook

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello Andrei Kvapil (@kvaps), I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the Cozystack controller's Kubernetes configurations to align with evolving resource management needs. It updates the mutating webhook to focus on Cozystack's native workloadmonitors and standard Kubernetes ingresses, while simultaneously broadening the controller's RBAC permissions to encompass the dashboard.cozystack.io API group. These changes ensure the controller can effectively manage and observe the intended resources within the Cozystack ecosystem.

Highlights

  • Webhook Configuration Update: The mutating webhook configuration has been updated to remove monitoring for vmclusters and instead include workloadmonitors from the cozystack.io API group and ingresses from the networking.k8s.io API group for CREATE and UPDATE operations.
  • RBAC Permissions Expansion: The cozystack-controller's Role-Based Access Control (RBAC) permissions have been expanded to include the dashboard.cozystack.io API group, granting it comprehensive access to resources within this group.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment Gemini (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the lineage mutating webhook configuration to intercept workloadmonitors and ingresses instead of vmclusters. It also expands the cozystack-controller's permissions to the dashboard.cozystack.io API group. My review identifies a couple of areas for improvement. First, removing the vmclusters webhook rule leaves behind dead code in the webhook handler that should be cleaned up. Second, the permissions granted to the controller are overly broad, and I recommend scoping them down following the principle of least privilege.

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/system/cozystack-controller/templates/mutatingwebhookconfiguration.yaml (1)

28-30: Ingress mutation rule added: confirm handler coverage and consider explicit webhook knobs

  • Rule is correct for networking.k8s.io/v1 ingresses.
  • Confirm /mutate-lineage handles Ingress and that failurePolicy: Fail is acceptable for ingress mutations.

Optionally add explicit timeouts/reinvocation/match policy to harden behavior:

     admissionReviewVersions: ["v1"]
     sideEffects: None
+    timeoutSeconds: 5
+    reinvocationPolicy: IfNeeded
+    matchPolicy: Equivalent

If ingress mutations are not universally needed, consider adding an objectSelector to limit scope to labeled ingresses.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d76e6b and 97f1b29.

📒 Files selected for processing (1)
  • packages/system/cozystack-controller/templates/mutatingwebhookconfiguration.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (1)
packages/system/cozystack-controller/templates/mutatingwebhookconfiguration.yaml (1)

24-26: Switch to WorkloadMonitor (cozystack.io/v1alpha1): verified — CRD, scope, webhook and RBAC OK

  • CRD: packages/system/cozystack-controller/templates/crds/cozystack.io_workloadmonitors.yaml — kind=WorkloadMonitor, plural=workloadmonitors, version=v1alpha1, scope=Namespaced (namespaceSelector applies).
  • Webhook: internal/lineagecontrollerwebhook/webhook.go registers the handler at /mutate-lineage and Handle processes unstructured objects; MutatingWebhookConfiguration includes workloadmonitors.
  • RBAC: packages/system/cozystack-controller/templates/rbac.yaml grants apiGroups: ['cozystack.io'] resources: [''] verbs: [''] — covers workloadmonitors.

@kvaps
Andrei Kvapil (kvaps) merged commit 152ab20 into main Sep 24, 2025
20 checks passed
@kvaps
Andrei Kvapil (kvaps) deleted the fix-webhook branch September 24, 2025 15:20
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.

1 participant