Skip to content

Revert "[cozystack-controller] Ancestor tracking webhook" - #1425

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
revert-1400-feat/webhook-workload-monitors
Sep 17, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
revert-1400-feat/webhook-workload-monitors

Conversation

@kvaps

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

Copy link
Copy Markdown
Member

Reverts #1400

Summary by CodeRabbit

  • New Features
    • None
  • Refactor
    • Removed the lineage mutating admission webhook and its controller logic; objects are no longer auto-labeled/mutated.
    • Deployment now targets the cozy-system namespace and no longer exposes a webhook port or mounts webhook certs.
  • Chores
    • Removed Service and cert-manager resources previously used for webhook TLS; cert-manager is no longer required.
  • Tests
    • Removed lineage-related tests.

@coderabbitai

coderabbitai Bot commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This PR removes the LineageControllerWebhook feature and its supporting lineage library, eliminates webhook-related manifests and wiring, and updates the controller deployment to run without a mutating webhook. Controller setup code that registered the webhook/controller is deleted.

Changes

Cohort / File(s) Summary of changes
Main setup adjustments
cmd/cozystack-controller/main.go
Removed registration and imports for the LineageControllerWebhook as both controller and webhook.
Lineage webhook package removal
internal/lineagecontrollerwebhook/*
Deleted the webhook type, controller setup, reconciliation logic, runtime config/mapping, admission handler, helpers, and decoder injection.
Lineage library removal
pkg/lineage/...
Deleted lineage traversal API (lineage.go), app mapper (mapper.go), and tests (lineage_test.go).
Helm templates: webhook infra removal
packages/system/cozystack-controller/templates/{service.yaml,mutatingwebhookconfiguration.yaml,certmanager.yaml}
Removed Service exposure, MutatingWebhookConfiguration, and cert-manager Issuer/Certificate chain for the webhook.
Deployment template update
packages/system/cozystack-controller/templates/deployment.yaml
Added namespace cozy-system; removed webhook port, cert volumeMount, and cert volume.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant KAS as K8s API Server
  participant Ctrl as cozystack-controller
  participant WH as (Removed) Mutating Webhook

  rect rgba(230,245,255,0.6)
    note over User,KAS: Previous flow (before this change)
    User->>KAS: Create Pod/Secret/Service/PVC
    KAS->>WH: AdmissionReview /mutate-lineage
    WH->>Ctrl: (internal) Lineage mapping & ownership graph
    WH-->>KAS: Patch/Allow response
    KAS-->>User: Object admitted (possibly mutated)
  end

  rect rgba(245,235,235,0.6)
    note over User,KAS: New flow (after this change)
    User->>KAS: Create Pod/Secret/Service/PVC
    KAS-->>User: Object admitted (no lineage mutation)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • lllamnyp
  • klinch0

Poem

A rabbit once tagged every leaf on the tree,
Hop to pod, to secret—ancestry!
But now the breeze is simple and light,
No web of labels woven tight.
I twitch my nose, less work to do—
Clean meadows, clear paths, and carrots anew! 🥕🐇

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 "Revert "[cozystack-controller] Ancestor tracking webhook"" is concise and accurately summarizes the primary change — reverting the ancestor-tracking webhook in the cozystack-controller; it directly matches the changeset that removes the lineage webhook, its controller/webhook code, and related templates and packages. This makes the intent clear to reviewers scanning PR history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-1400-feat/webhook-workload-monitors

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

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 performs a full reversion of the "Ancestor tracking webhook" feature. It systematically removes all components introduced by the original change, including the Go code responsible for the webhook's logic and its integration into the controller, as well as all Kubernetes deployment artifacts like Cert-Manager configurations, the MutatingWebhookConfiguration, and the webhook service. This ensures a complete rollback of the feature from the cozystack-controller.

Highlights

  • Full Reversion of Ancestor Tracking Webhook: This PR completely undoes the implementation of the "Ancestor tracking webhook" feature, rolling back all associated code and configurations.
  • Code Removal: All Go source code related to the lineagecontrollerwebhook package and the pkg/lineage package, including its controller, webhook logic, types, and configuration, has been removed.
  • Kubernetes Manifest Deletion: All associated Kubernetes manifests, such as Cert-Manager resources, the MutatingWebhookConfiguration, and the Service for the webhook, have been deleted.
  • Deployment Configuration Cleanup: The main controller deployment configuration has been updated to remove webhook-specific port, volume mounts, and volume definitions.
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 reverts the 'Ancestor tracking webhook' feature. The changes correctly remove all code and configuration related to this feature, including the lineagecontrollerwebhook and pkg/lineage packages, and associated Kubernetes manifests. The revert appears clean and complete. I have one suggestion regarding a hardcoded namespace in deployment.yaml to improve the Helm chart's flexibility, which seems to be an issue this revert is re-introducing.

kind: Deployment
metadata:
name: cozystack-controller
namespace: cozy-system

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.

medium

The namespace is hardcoded to cozy-system. While some other components in the system seem to rely on this namespace, it's a best practice in Helm charts to use {{ .Release.Namespace }} to allow for flexible deployment into different namespaces. The removed cert-manager.yaml and mutatingwebhookconfiguration.yaml files used {{ .Release.Namespace }}, which suggests that using the release namespace is the intended pattern. For consistency and to avoid potential deployment issues, consider using the release namespace here.

  namespace: {{ .Release.Namespace }}

@kvaps
Andrei Kvapil (kvaps) merged commit 37720b9 into main Sep 17, 2025
3 of 6 checks passed
@kvaps
Andrei Kvapil (kvaps) deleted the revert-1400-feat/webhook-workload-monitors branch September 17, 2025 10:49

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65a734b and ce52228.

📒 Files selected for processing (12)
  • cmd/cozystack-controller/main.go (0 hunks)
  • internal/lineagecontrollerwebhook/config.go (0 hunks)
  • internal/lineagecontrollerwebhook/controller.go (0 hunks)
  • internal/lineagecontrollerwebhook/types.go (0 hunks)
  • internal/lineagecontrollerwebhook/webhook.go (0 hunks)
  • packages/system/cozystack-controller/templates/certmanager.yaml (0 hunks)
  • packages/system/cozystack-controller/templates/deployment.yaml (1 hunks)
  • packages/system/cozystack-controller/templates/mutatingwebhookconfiguration.yaml (0 hunks)
  • packages/system/cozystack-controller/templates/service.yaml (0 hunks)
  • pkg/lineage/lineage.go (0 hunks)
  • pkg/lineage/lineage_test.go (0 hunks)
  • pkg/lineage/mapper.go (0 hunks)
💤 Files with no reviewable changes (11)
  • pkg/lineage/lineage_test.go
  • packages/system/cozystack-controller/templates/service.yaml
  • internal/lineagecontrollerwebhook/controller.go
  • internal/lineagecontrollerwebhook/types.go
  • packages/system/cozystack-controller/templates/mutatingwebhookconfiguration.yaml
  • cmd/cozystack-controller/main.go
  • packages/system/cozystack-controller/templates/certmanager.yaml
  • internal/lineagecontrollerwebhook/config.go
  • internal/lineagecontrollerwebhook/webhook.go
  • pkg/lineage/lineage.go
  • pkg/lineage/mapper.go
⏰ 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

kind: Deployment
metadata:
name: cozystack-controller
namespace: cozy-system

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.

⚠️ Potential issue

🧩 Analysis chain

Avoid hard-coding namespace in Helm templates; use release namespace or omit.

Pinning metadata.namespace: cozy-system can desync this Deployment from its ServiceAccount/RBAC if those resources are created in .Release.Namespace (default Helm behavior). This can cause pod startup failures (“serviceaccount not found”) when installing into any namespace other than cozy-system, or when other templates don’t hard-code the same namespace.

Two safer options:

  • Prefer omit: let Helm set the namespace from the release.
  • Or template it explicitly.
-  namespace: cozy-system
+  # namespace resolved by Helm release; avoid hard-coding to prevent drift
+  {{- /* omit explicit namespace or, if required: */ -}}
+  {{- /* namespace: {{ .Release.Namespace }} */ -}}

Verify consistency across the chart:


🏁 Script executed:

#!/bin/bash
# Check if ServiceAccount/RBAC are hard-coded to a different namespace or left implicit
rg -n -C2 -g 'packages/system/cozystack-controller/templates/**' -e 'kind:\s*ServiceAccount|RoleBinding|ClusterRoleBinding|Deployment' -e 'namespace:\s*cozy-system'

# List all explicit namespace declarations in this chart
rg -n -C1 -g 'packages/system/cozystack-controller/templates/**' -e '^\s*namespace:\s*'

# Look for lingering webhook artifacts (ports, cert mounts, services) after the revert
rg -n -C2 -g 'packages/system/cozystack-controller/templates/**' -e 'webhook|9443|serving-certs|webhook-certs|MutatingWebhookConfiguration|cert-manager'

Length of output: 5093


Remove hard-coded namespace; use the release namespace or template it

Hard-coded "namespace: cozy-system" exists across templates and can desync ServiceAccount/RBAC, causing "serviceaccount not found" when installing the chart into a different namespace.

  • Fix namespaced resources (omit metadata.namespace so Helm uses the release namespace, or template to .Release.Namespace if you must): packages/system/cozystack-controller/templates/deployment.yaml (line 5), sa.yaml (line 5), role.yaml (lines 5, 17, 25).
  • Fix cluster-scoped RBAC subjects (do not omit—template the subject namespace): packages/system/cozystack-controller/templates/rbac-bind.yaml (line 12) — replace with {{ .Release.Namespace }}.

Suggested edits (examples):

For namespaced resources:

  • namespace: cozy-system
  • omit explicit namespace so Helm uses the release namespace

  • {{- /* if required: namespace: "{{ .Release.Namespace }}" */ -}}

For ClusterRoleBinding subject namespace:

  • namespace: cozy-system
  • namespace: {{ .Release.Namespace }}
🤖 Prompt for AI Agents
packages/system/cozystack-controller/templates/deployment.yaml around line 5:
remove the hard-coded namespace entry so Helm will install into the release
namespace; either delete the metadata.namespace line entirely (preferred for
namespaced resources) or replace it with a template using .Release.Namespace if
an explicit field is required, and apply the same change to sa.yaml and
role.yaml; for cluster-scoped RBAC subjects (rbac-bind.yaml line 12) do not omit
namespace—template the subject namespace as {{ .Release.Namespace }} so bindings
point to the correct release namespace.

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