Skip to content

fix(tenant): gate VM-resource HelmReleases on victoria-metrics-operator readiness - #3141

Merged
Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
fix/tenant-monitoring-gate-vmo
Jul 1, 2026
Merged

fix(tenant): gate VM-resource HelmReleases on victoria-metrics-operator readiness#3141
Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
fix/tenant-monitoring-gate-vmo

Conversation

@lexfrei

@lexfrei Aleksei Sviridkin (lexfrei) commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What this PR does

The tenant etcd, ingress and monitoring HelmReleases create VictoriaMetrics custom resources — VMPodScrape directly in etcd and ingress, and VMCluster / VMAlert / VLCluster / VMAlertmanager / VMServiceScrape via the monitoring-system child that monitoring creates. All of these are intercepted by the victoria-metrics-operator validating webhook, which is configured with failurePolicy: Fail.

On a cold install the operator pod can be briefly unavailable on :9443 (for example a transient API-server blip during startup leaves the webhook backend not yet serving). In that window the tenant releases reconcile, the webhook rejects their VM* resources with connection refused, and the releases churn through failed-install → rollback → retry. They carry install.remediation.retries: -1 and recover eventually, but the churn can outlast a cold-install readiness deadline and surfaces as spurious install failures.

This adds a Flux spec.dependsOn from each of those three tenant releases to the victoria-metrics-operator HelmRelease in cozy-victoria-metrics-operator, so they wait for the operator to be Ready before creating any VM* resource. The system monitoring components already gate on the operator the same way (a variant-level dependsOn in the platform package sources); this brings the tenant releases to parity. failurePolicy: Fail is preserved — validation is unchanged.

The tenant releases are sharded (sharding.fluxcd.io/key) while the operator release is not. helm-controller resolves dependsOn through an uncached API read that bypasses the shard's watch-label-selector cache (since v1.1.0, PR fluxcd/helm-controller#1070), so the cross-shard reference is visible to the tenant shard's controller; this repo ships helm-controller v1.5.0.

A helm-unittest suite pins the gate on all three releases and asserts that the tenant releases creating no VM* resources (seaweedfs, gateway) do not carry it, documenting the intentional narrowness of the gate.

Release note

fix(tenant): gate tenant etcd, ingress and monitoring HelmReleases on victoria-metrics-operator readiness so they no longer fail to install when the operator's admission webhook is briefly unavailable on a cold install

Summary by CodeRabbit

  • Bug Fixes
    • Improved tenant installation reliability by adding readiness gating: etcd, ingress, and monitoring Helm releases now wait for the Victoria Metrics operator to become Ready before applying dependent resources.
    • Prevents install/rollback failures caused by temporary admission webhook unavailability during cold starts.
  • Tests
    • Added Helm-unittest coverage to confirm the dependency gate is present only for templates that create VM* resources (and omitted for templates that don’t).

@github-actions github-actions Bot added area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review size/L This PR changes 100-499 lines, ignoring generated files kind/bug Categorizes issue or PR as related to a bug labels Jun 29, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses transient installation failures occurring during cold starts of the cluster. By introducing explicit dependencies on the victoria-metrics-operator, the tenant HelmReleases now wait for the operator's admission webhook to be fully operational before attempting to create VictoriaMetrics custom resources. This change prevents unnecessary reconciliation churn and ensures a more robust deployment process.

Highlights

  • Dependency Management: Added a Flux spec.dependsOn constraint to the etcd, ingress, and monitoring HelmReleases to ensure they wait for the victoria-metrics-operator to be ready before deployment.
  • Stability Improvement: Prevents installation failures and rollback loops caused by the victoria-metrics-operator admission webhook being temporarily unavailable during cold starts.
  • Automated Testing: Introduced a helm-unittest suite to verify the dependency gates are correctly applied to relevant releases while ensuring they remain absent from releases that do not require them.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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

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.

@lexfrei Aleksei Sviridkin (lexfrei) added the backport Should change be backported on previous release label Jun 29, 2026
@dosubot dosubot Bot added the area/kubernetes Issues or PRs related to the tenant Kubernetes app label Jun 29, 2026
@coderabbitai

coderabbitai Bot commented Jun 29, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5a8afc5a-73fa-408c-86d9-bbd10216de9d

📥 Commits

Reviewing files that changed from the base of the PR and between 01e2ad9 and 6db5ae9.

📒 Files selected for processing (4)
  • packages/apps/tenant/templates/etcd.yaml
  • packages/apps/tenant/templates/ingress.yaml
  • packages/apps/tenant/templates/monitoring.yaml
  • packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/apps/tenant/templates/etcd.yaml
  • packages/apps/tenant/templates/ingress.yaml
  • packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml
  • packages/apps/tenant/templates/monitoring.yaml

📝 Walkthrough

Walkthrough

Three tenant HelmRelease templates (etcd, ingress, monitoring) now depend on victoria-metrics-operator in cozy-victoria-metrics-operator. A new helm-unittest suite checks that dependency for those templates and confirms it is absent from seaweedfs and gateway.

Changes

VMO webhook dependsOn gating

Layer / File(s) Summary
dependsOn added to tenant HelmReleases
packages/apps/tenant/templates/etcd.yaml, packages/apps/tenant/templates/ingress.yaml, packages/apps/tenant/templates/monitoring.yaml
Each template's HelmRelease spec gains a dependsOn entry for victoria-metrics-operator in cozy-victoria-metrics-operator, with comments about cold-install webhook behavior.
Helm-unittest coverage for dependsOn scope
packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml
The new helm-unittest suite renders selected tenant templates, enables the relevant tenant features, and checks dependsOn presence for etcd, ingress, and monitoring while excluding seaweedfs and gateway.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: area/testing, area/kubernetes

Suggested reviewers: lllamnyp, kvaps, androndo, IvanHunters, sircthulhu, myasnikovdaniil

Poem

The operator wakes before the charts,
Three HelmReleases wait their parts.
Tests keep seaweedfs and gateway clear,
While VM hooks line up in gear.

🚥 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 accurately summarizes the main change: gating tenant VM-resource HelmReleases on victoria-metrics-operator readiness.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tenant-monitoring-gate-vmo

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.

@lexfrei Aleksei Sviridkin (lexfrei) added area/monitoring Issues or PRs related to the monitoring stack (vlogs, vmstack, grafana, workloadmonitor) and removed area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review labels Jun 29, 2026

@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 tenant application templates (etcd, ingress, and monitoring) to depend on the victoria-metrics-operator HelmRelease. This ensures that during a cold install, these releases wait for the operator to become ready before deploying, preventing installation failures caused by the operator's admission webhook being temporarily unavailable. Additionally, a new unit test suite has been added to verify these dependency gates and ensure that other releases (like seaweedfs and gateway) are not needlessly blocked. I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@lexfrei Aleksei Sviridkin (lexfrei) removed the area/kubernetes Issues or PRs related to the tenant Kubernetes app label Jun 29, 2026
@github-actions github-actions Bot added the area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review label Jun 29, 2026

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

The root cause is real and the fix is minimal. victoria-metrics-operator ships failurePolicy: Fail on its ValidatingWebhookConfiguration (confirmed: values.yaml: policy: Fail), so any CREATE of a VM* resource while the webhook backend is not yet serving on :9443 is rejected, causing the tenant releases to churn through fail-install → rollback on a cold install. Adding spec.dependsOn on the operator's HelmRelease is the correct remedy and matches the existing pattern at the system-monitoring layer (sources/monitoring.yaml variant-level dependsOn: [cozystack.victoria-metrics-operator]). The cross-shard claim holds — helm-controller v1.1.0+ resolves dependsOn via an uncached API read; this repo pins Flux v2.8 (helm-controller v1.5.0). The chain works for monitoring too: gating the parent prevents the monitoring-system child HelmRelease from being created until the operator is Ready.

Two small suggestions inline; neither blocks.

# HelmRelease becoming Ready to avoid an install failure → rollback. The system
# monitoring components gate on the operator the same way, via a variant-level
# dependsOn in packages/core/platform/sources/monitoring.yaml.
dependsOn:

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.

The comment block (7 lines) is longer than needed. The WHY is genuinely non-obvious, but the mechanism detail (helm-controller cross-shard resolution, reference to monitoring.yaml) belongs in the PR description, not the template. A tighter version:

  # VMPodScrape is guarded by the VMO admission webhook (failurePolicy: Fail);
  # wait for the operator to be Ready to survive a cold install.
  dependsOn:

Same applies to the comment blocks in ingress.yaml and monitoring.yaml.

namespace: cozy-victoria-metrics-operator

- it: ingress HR depends on the victoria-metrics-operator
asserts:

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.

Using equal on the entire spec.dependsOn list means this test will fail if a second legitimate dependsOn entry is added later. contains is more resilient and equally expressive:

        contains:
          path: spec.dependsOn
          content:
            name: victoria-metrics-operator
            namespace: cozy-victoria-metrics-operator

If the intent is specifically to prevent any additional dependsOn from being added silently, equal is fine — just add a note saying so. Applies to all three positive test cases.

- templates/gateway.yaml

release:
name: tenant-test

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.

info.yaml is absent from the template list, so the negative coverage has a gap. extra/info creates only a ServiceAccount, ConfigMap, and kubeconfig Secret — no VM* resources — so the info HelmRelease should not carry the gate. no_upgrade_force_test.yaml already includes templates/info.yaml without issue, so it renders safely in helm-unittest.

Consider adding:

  - templates/info.yaml

to the templates: list and a corresponding test:

  - it: info HR carries no operator gate
    asserts:
      - template: templates/info.yaml
        notExists:
          path: spec.dependsOn

@lexfrei
Aleksei Sviridkin (lexfrei) force-pushed the fix/tenant-monitoring-gate-vmo branch from 7727ebc to 01e2ad9 Compare June 30, 2026 10:35
…rator

The tenant etcd, ingress and monitoring HelmReleases create VM* custom
resources (VMPodScrape directly in etcd/ingress; VMCluster, VMAlert,
VLCluster, VMAlertmanager and VMServiceScrape via the monitoring-system
child of monitoring) guarded by the victoria-metrics-operator validating
webhook with failurePolicy: Fail. On a cold install the operator pod can
be briefly unavailable on :9443, so these releases reconcile before the
webhook backend is serving and are rejected with connection refused. They
carry install.remediation.retries: -1 and would eventually recover, but
the failed-install -> rollback -> retry churn can outlast a cold-install
readiness deadline and surfaces as spurious install failures.

Add a Flux spec.dependsOn from each of these releases to the
victoria-metrics-operator HelmRelease in cozy-victoria-metrics-operator,
so they wait for the operator to be Ready before creating VM* resources.
The system monitoring components gate on the operator the same way, via a
variant-level dependsOn. The cross-shard reference (tenant releases are
sharded, the operator release is not) resolves via helm-controller's
uncached dependency check (APIReader, v1.1.0+).

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@lexfrei
Aleksei Sviridkin (lexfrei) force-pushed the fix/tenant-monitoring-gate-vmo branch from 01e2ad9 to 6db5ae9 Compare July 1, 2026 09:05
@lexfrei Aleksei Sviridkin (lexfrei) added area/tenant Issues or PRs related to the tenant chart and multi-tenancy and removed area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review labels Jul 1, 2026
@lexfrei
Aleksei Sviridkin (lexfrei) merged commit a31a73c into main Jul 1, 2026
17 checks passed
@lexfrei
Aleksei Sviridkin (lexfrei) deleted the fix/tenant-monitoring-gate-vmo branch July 1, 2026 10:51
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

myasnikovdaniil added a commit that referenced this pull request Jul 3, 2026
…victoria-metrics-operator readiness (#3166)

# Description
Backport of #3141 to `release-1.5`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/monitoring Issues or PRs related to the monitoring stack (vlogs, vmstack, grafana, workloadmonitor) area/tenant Issues or PRs related to the tenant chart and multi-tenancy backport Should change be backported on previous release kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants