Skip to content

use multiple secrets if scrape config exceeds K8s secret limit#2232

Open
AndrewChubatiuk wants to merge 1 commit into
masterfrom
vmagent-use-multiple-secrets-for-scrape-config
Open

use multiple secrets if scrape config exceeds K8s secret limit#2232
AndrewChubatiuk wants to merge 1 commit into
masterfrom
vmagent-use-multiple-secrets-for-scrape-config

Conversation

@AndrewChubatiuk
Copy link
Copy Markdown
Contributor

@AndrewChubatiuk AndrewChubatiuk commented May 31, 2026

vmagent and vmsingle: use additional secrets if default scrape config size exceeds K8s secret limit. fixes #1048


Summary by cubic

Splits oversized scrape configs for vmagent/vmsingle into multiple gzip-compressed Secrets and loads overflow jobs via scrape_config_files. Adds config-reloader support to mirror and decompress watched files into an EmptyDir and clean up stale files.

  • New Features

    • vmagent/vmsingle: When scrape config exceeds the 1MB Secret limit, overflow jobs are split using compressed-size-aware packing into extra Secrets (jobs.yaml). Pods mount a shared sc-files-out EmptyDir; config-reloader watches per-bucket raw Secret dirs and writes decompressed files to matching subdirs. The main config adds a scrape_config_files glob, and stale extra Secrets are removed automatically.
    • config-reloader: Added --target-dir paired with --watched-dir (counts must match). Detects gzip and decompresses. Copies files on init/start and on change, and removes orphaned files in the target.
  • Bug Fixes

    • Ignore NotFound errors when updating child status conditions to avoid noisy failures during reconcile.

Written for commit 5af4c85. Summary will update on new commits.

Review in cubic

@AndrewChubatiuk AndrewChubatiuk requested a review from vrutkovs as a code owner May 31, 2026 18:53
@AndrewChubatiuk AndrewChubatiuk force-pushed the vmagent-use-multiple-secrets-for-scrape-config branch 2 times, most recently from 8cf847c to 6d36761 Compare May 31, 2026 18:59
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.

3 issues found across 16 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread cmd/config-reloader/main.go Outdated
Comment thread internal/controller/operator/factory/vmscrapes/extra_config.go
Comment thread cmd/config-reloader/file_watch.go
@AndrewChubatiuk AndrewChubatiuk force-pushed the vmagent-use-multiple-secrets-for-scrape-config branch 3 times, most recently from 286ce17 to 22d00e0 Compare June 1, 2026 07:36
@AndrewChubatiuk
Copy link
Copy Markdown
Contributor Author

@cubic-ai-dev

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Jun 1, 2026

@cubic-ai-dev

@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete.

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.

2 issues found across 17 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/factory/vmsingle/vmsingle.go">

<violation number="1" location="internal/controller/operator/factory/vmsingle/vmsingle.go:129">
P2: `prevDeploy` is always constructed with `extraConfigSecretCount=0`, even when the previous deployment had extra config secrets. This causes unnecessary deployment updates on every reconciliation for VMSingle instances with oversized scrape configs, as the prevDeploy/newDeploy comparison will always see a volume/mount diff.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread internal/controller/operator/factory/vmsingle/vmsingle.go Outdated
if prevCR != nil {
var err error
prevDeploy, err = newDeploy(ctx, prevCR)
prevDeploy, err = newDeploy(ctx, prevCR, 0)
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Jun 1, 2026

Choose a reason for hiding this comment

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

P2: prevDeploy is always constructed with extraConfigSecretCount=0, even when the previous deployment had extra config secrets. This causes unnecessary deployment updates on every reconciliation for VMSingle instances with oversized scrape configs, as the prevDeploy/newDeploy comparison will always see a volume/mount diff.

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

<comment>`prevDeploy` is always constructed with `extraConfigSecretCount=0`, even when the previous deployment had extra config secrets. This causes unnecessary deployment updates on every reconciliation for VMSingle instances with oversized scrape configs, as the prevDeploy/newDeploy comparison will always see a volume/mount diff.</comment>

<file context>
@@ -125,22 +126,22 @@ func CreateOrUpdate(ctx context.Context, cr *vmv1beta1.VMSingle, rclient client.
 	if prevCR != nil {
 		var err error
-		prevDeploy, err = newDeploy(ctx, prevCR)
+		prevDeploy, err = newDeploy(ctx, prevCR, 0)
 		if err != nil {
 			return fmt.Errorf("cannot generate prev deploy spec: %w", err)
</file context>
Fix with Cubic

@AndrewChubatiuk AndrewChubatiuk force-pushed the vmagent-use-multiple-secrets-for-scrape-config branch from 22d00e0 to 16ff747 Compare June 1, 2026 08:51
@AndrewChubatiuk AndrewChubatiuk force-pushed the vmagent-use-multiple-secrets-for-scrape-config branch 3 times, most recently from 7590330 to e748449 Compare June 1, 2026 10:16
@AndrewChubatiuk AndrewChubatiuk force-pushed the vmagent-use-multiple-secrets-for-scrape-config branch from e748449 to 5af4c85 Compare June 1, 2026 12:28
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.

Operator is unable to create secret for vmagent when compressed config "vmagent.yaml.gz" is larger than 1MB

1 participant