Skip to content

introduce VMAnomalyConfig#1472

Open
AndrewChubatiuk wants to merge 2 commits intomasterfrom
introduce-vmanomalymodel
Open

introduce VMAnomalyConfig#1472
AndrewChubatiuk wants to merge 2 commits intomasterfrom
introduce-vmanomalymodel

Conversation

@AndrewChubatiuk
Copy link
Copy Markdown
Contributor

@AndrewChubatiuk AndrewChubatiuk commented Jul 17, 2025

starting 1.25.0 anomaly supports hot-reload, and this PR introduces VMAnomalyConfig CR, that allows to add extra models, schedulers and queries for VMAnomaly dynamic configuration

@AndrewChubatiuk AndrewChubatiuk marked this pull request as draft July 17, 2025 08:34
@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch 2 times, most recently from 7b569bb to a7fc951 Compare July 17, 2025 09:39
@AndrewChubatiuk AndrewChubatiuk marked this pull request as ready for review July 17, 2025 09:39
@AndrewChubatiuk AndrewChubatiuk requested a review from zekker6 July 17, 2025 09:39
@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch 3 times, most recently from 840964f to 9e5ab0f Compare July 17, 2025 10:47
Copy link
Copy Markdown
Collaborator

@f41gh7 f41gh7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's required to add documentation in first place. Is it possible that model could interfere on each other? Is it required to config VMAnomaly itself somehow? What is a relations between VMAnomaly and VMAnomalyModel?

Currently it's not possible to use this new API.

Also, I suggest to add -configCheckInterval to the vmanomaly in the same way as other components have it. It solves configuration reload without need of external config reloaders.

@AndrewChubatiuk
Copy link
Copy Markdown
Contributor Author

AndrewChubatiuk commented Jul 18, 2025

removed config reloader since python watchdog, which implements hot reload listens to fs events

@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch from 0ec9f87 to 1ba5e13 Compare July 18, 2025 12:20
@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch from 1ba5e13 to 4558e7c Compare July 29, 2025 13:19
@AndrewChubatiuk AndrewChubatiuk changed the title introduce VMAnomalyModel introduce VMAnomalyModel and VMAnomalyScheduler Jul 29, 2025
@AndrewChubatiuk
Copy link
Copy Markdown
Contributor Author

added scheduler CR, added docs

@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch 5 times, most recently from 1b8eb91 to 2216f0a Compare July 29, 2025 14:58
@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch 2 times, most recently from 66eac73 to bfc5203 Compare October 7, 2025 08:05
@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch 5 times, most recently from cdea53b to 5914c18 Compare October 21, 2025 13:33

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch from 11c333c to bf10354 Compare April 2, 2026 13:09
@AndrewChubatiuk AndrewChubatiuk changed the title introduce VMAnomalyModel and VMAnomalyScheduler introduce VMAnomalyConfig Apr 2, 2026
@AndrewChubatiuk AndrewChubatiuk force-pushed the introduce-vmanomalymodel branch from c53d6a0 to 21aa85c Compare April 2, 2026 15:15
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 issues found across 31 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/controller/operator/vmanomalyconfig_controller_test.go">

<violation number="1" location="internal/controller/operator/vmanomalyconfig_controller_test.go:47">
P2: Fail fast on non-NotFound errors in test setup instead of silently ignoring them.</violation>
</file>

<file name="docs/CHANGELOG.md">

<violation number="1" location="docs/CHANGELOG.md:34">
P1: Custom agent: **Changelog Review Agent**

This entry is missing the mandatory issue/PR reference link required by the changelog structure.</violation>

<violation number="2" location="docs/CHANGELOG.md:223">
P2: This changelog entry is duplicated and appears in the wrong release section (`v0.64.0` and `v0.65.0`), which makes release notes inaccurate.</violation>

<violation number="3" location="docs/CHANGELOG.md:223">
P1: Custom agent: **Changelog Review Agent**

New changelog entries must be added only to `tip`; this line adds a new BUGFIX entry in a released section, which violates placement requirements.</violation>
</file>

<file name="internal/controller/operator/vmanomalyconfig_controller.go">

<violation number="1" location="internal/controller/operator/vmanomalyconfig_controller.go:118">
P2: Propagate the CreateOrUpdateConfig error so reconcile fails and requeues instead of silently succeeding.</violation>
</file>

<file name="internal/controller/operator/factory/vmanomaly/config/config.go">

<violation number="1" location="internal/controller/operator/factory/vmanomaly/config/config.go:288">
P1: Writing merged model entries into `c.Models` can panic when the base config omits `models` (nil map). Initialize the map before assignment.</violation>

<violation number="2" location="internal/controller/operator/factory/vmanomaly/config/config.go:292">
P1: Writing merged scheduler entries into `c.Schedulers` can panic when the base config omits `schedulers` (nil map). Initialize the map before assignment.</violation>
</file>

<file name="internal/controller/operator/factory/vmanomaly/config/config_test.go">

<violation number="1" location="internal/controller/operator/factory/vmanomaly/config/config_test.go:714">
P2: The new external-config test sets `ConfigNamespaceSelector` but doesn't create a matching labeled Namespace object, so no `VMAnomalyConfig` can be selected in this setup.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

* FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): support HPA in VMAgent CR and in VMAgent, which is a part of VMDistributed. See [#1961](https://github.com/VictoriaMetrics/operator/issues/1961).
* FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): VMAgent CRs running in statefulSet mode, including VMAgent components in VMDistributed, now support configuring rolling update strategy behavior. See [#1987](https://github.com/VictoriaMetrics/operator/issues/1987).
* FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): VMAgent CRs running in DaemonSet mode now support configuring rolling update strategy behavior.
* FEATURE: [vmanomaly](https://docs.victoriametrics.com/operator/resources/vmanomaly/): introduce `VMAnomalyConfig` CRD to enable dynamic configuration and hot-reload support starting from VMAnomaly version `1.25.0`.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Custom agent: Changelog Review Agent

This entry is missing the mandatory issue/PR reference link required by the changelog structure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/CHANGELOG.md, line 34:

<comment>This entry is missing the mandatory issue/PR reference link required by the changelog structure.</comment>

<file context>
@@ -31,6 +31,7 @@ aliases:
 * FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): support HPA in VMAgent CR and in VMAgent, which is a part of VMDistributed. See [#1961](https://github.com/VictoriaMetrics/operator/issues/1961).
 * FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): VMAgent CRs running in statefulSet mode, including VMAgent components in VMDistributed, now support configuring rolling update strategy behavior.  See [#1987](https://github.com/VictoriaMetrics/operator/issues/1987).
 * FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): VMAgent CRs running in DaemonSet mode now support configuring rolling update strategy behavior.
+* FEATURE: [vmanomaly](https://docs.victoriametrics.com/operator/resources/vmanomaly/): introduce `VMAnomalyConfig` CRD to enable dynamic configuration and hot-reload support starting from VMAnomaly version `1.25.0`.
 
 * BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): VMPodScrape for VLAgent and VMAgent now uses the correct port; previously it used the wrong port and could cause scrape failures. See [#1887](https://github.com/VictoriaMetrics/operator/issues/1887).
</file context>
Fix with Cubic

BeforeEach(func() {
By("creating the custom resource for the Kind VMAnomalyConfig")
err := k8sClient.Get(ctx, typeNamespacedName, vmanomalyconfig)
if err != nil && k8serrors.IsNotFound(err) {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Fail fast on non-NotFound errors in test setup instead of silently ignoring them.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/vmanomalyconfig_controller_test.go, line 47:

<comment>Fail fast on non-NotFound errors in test setup instead of silently ignoring them.</comment>

<file context>
@@ -0,0 +1,83 @@
+		BeforeEach(func() {
+			By("creating the custom resource for the Kind VMAnomalyConfig")
+			err := k8sClient.Get(ctx, typeNamespacedName, vmanomalyconfig)
+			if err != nil && k8serrors.IsNotFound(err) {
+				resource := &vmv1.VMAnomalyConfig{
+					ObjectMeta: metav1.ObjectMeta{
</file context>
Fix with Cubic

* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): fix an issue where the return value from a couple of controllers was always `nil`. See [#1532](https://github.com/VictoriaMetrics/operator/pull/1532) for details.
* BUGFIX: [VMCluster](https://docs.victoriametrics.com/operator/resources/vmcluster/): emit warning if `vmcluster.spec.vmselect.persistentVolume` is set, previously it was emitted for `vmcluster.spec.vmselect.storage`.
* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): Prevent endless Service reconcile loop by correctly track changes to Service.spec.LoadBalancerClass. See this issue [#1550](https://github.com/VictoriaMetrics/operator/issues/1550) for details.
* BUGFIX: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/) and [vmanomaly](https://docs.victoriametrics.com/operator/resources/vmanomaly/): create PDB per shard to guarantee proper application protection. See [#1548](https://github.com/VictoriaMetrics/operator/issues/1548).
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This changelog entry is duplicated and appears in the wrong release section (v0.64.0 and v0.65.0), which makes release notes inaccurate.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/CHANGELOG.md, line 223:

<comment>This changelog entry is duplicated and appears in the wrong release section (`v0.64.0` and `v0.65.0`), which makes release notes inaccurate.</comment>

<file context>
@@ -219,6 +220,7 @@ This change could be reverted by providing env variable `VM_USECUSTOMCONFIGRELOA
 * BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): fix an issue where the return value from a couple of controllers was always `nil`. See [#1532](https://github.com/VictoriaMetrics/operator/pull/1532) for details.
 * BUGFIX: [VMCluster](https://docs.victoriametrics.com/operator/resources/vmcluster/): emit warning if `vmcluster.spec.vmselect.persistentVolume` is set, previously it was emitted for `vmcluster.spec.vmselect.storage`.
 * BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): Prevent endless Service reconcile loop by correctly track changes to Service.spec.LoadBalancerClass. See this issue [#1550](https://github.com/VictoriaMetrics/operator/issues/1550) for details.
+* BUGFIX: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/) and [vmanomaly](https://docs.victoriametrics.com/operator/resources/vmanomaly/): create PDB per shard to guarantee proper application protection. See [#1548](https://github.com/VictoriaMetrics/operator/issues/1548).
 
 
</file context>
Fix with Cubic

}
}

if err := vmanomaly.CreateOrUpdateConfig(ctx, r, item, &instance); err != nil {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Propagate the CreateOrUpdateConfig error so reconcile fails and requeues instead of silently succeeding.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/vmanomalyconfig_controller.go, line 118:

<comment>Propagate the CreateOrUpdateConfig error so reconcile fails and requeues instead of silently succeeding.</comment>

<file context>
@@ -0,0 +1,136 @@
+			}
+		}
+
+		if err := vmanomaly.CreateOrUpdateConfig(ctx, r, item, &instance); err != nil {
+			l.Error(err, "failed to update vmanomaly config")
+		}
</file context>
Fix with Cubic

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.

3 participants