Skip to content

chore: refactored probe building and cluster defaults management#1916

Merged
vrutkovs merged 2 commits intomasterfrom
refactor-probes-and-defaults
Mar 6, 2026
Merged

chore: refactored probe building and cluster defaults management#1916
vrutkovs merged 2 commits intomasterfrom
refactor-probes-and-defaults

Conversation

@AndrewChubatiuk
Copy link
Contributor

@AndrewChubatiuk AndrewChubatiuk commented Mar 3, 2026

  • temporary replaced caarlos0/env with fork till PR is merged
  • consolidate all functions for cluster defaults population
  • merged EmbeddedProbes, CommonDefaultableParams and CommonApplicationDeploymentParams into CommonAppsParams as all these structs are used together in all CRs
  • moved setting terminationGracePeriodSeconds to defaults management

Summary by cubic

Refactored probe handling and app/cluster defaults to simplify CRDs and centralize config. Probes are now built from CommonAppsParams, support proxy protocol via extraArgs, and termination grace is controlled by operator defaults per app.

  • Refactors

    • Replaced EmbeddedProbes, CommonDefaultableParams, and CommonApplicationDeploymentParams with CommonAppsParams across CRDs; removed Probe() from CRs. Probe builder now mutates containers and consumes CommonAppsParams.
    • Added UseProxyProtocol(extraArgs) helper and UseProxyProtocol() on CRs to drive probe behavior.
    • Moved terminationGracePeriodSeconds out of CRDs; defaults come from VM__TERMINATION_GRACE_PERIOD_SECONDS (default 30). Updated docs, CRDs, and tests.
    • Security helpers and Add*CommonParams now read UseStrictSecurity/SecurityContext from CommonAppsParams; AddServiceAccountTokenVolume updated accordingly.
    • Consolidated defaults application and license handling; tests initialize defaults via AddDefaults where needed.
    • Temporarily replaced caarlos0/env with a fork to unblock builds.
  • Migration

    • Update manifests to use CommonAppsParams and drop EmbeddedProbes.
    • Move liveness/readiness/startup probe settings under CommonAppsParams.
    • If terminationGracePeriodSeconds was set in specs, switch to VM__TERMINATION_GRACE_PERIOD_SECONDS.

Written for commit 3de2008. Summary will update on new commits.

Copy link
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 98 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

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="api/operator/v1beta1/vmextra_types.go">

<violation number="1" location="api/operator/v1beta1/vmextra_types.go:1229">
P3: Missing preposition "to" in GoDoc comments for `LivenessProbe` and `ReadinessProbe`. The `StartupProbe` comment correctly uses "added to CR pod", but these two say "added CR pod".

(Based on your team's feedback about documenting exported structs and public methods.) [FEEDBACK_USED]</violation>
</file>

<file name="api/operator/v1/vmanomaly_types.go">

<violation number="1" location="api/operator/v1/vmanomaly_types.go:458">
P3: Incorrect interface referenced in comment</violation>
</file>

<file name="internal/config/config.go">

<violation number="1" location="internal/config/config.go:809">
P1: Recursive env expansion in mapper can cause infinite recursion/stack overflow for cyclic variable references.</violation>
</file>

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

if val == "" {
val = opts.Environment[v]
}
return os.Expand(val, mapper)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 3, 2026

Choose a reason for hiding this comment

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

P1: Recursive env expansion in mapper can cause infinite recursion/stack overflow for cyclic variable references.

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

<comment>Recursive env expansion in mapper can cause infinite recursion/stack overflow for cyclic variable references.</comment>

<file context>
@@ -767,8 +799,14 @@ func (labels *Labels) Set(value string) error {
+		if val == "" {
+			val = opts.Environment[v]
+		}
+		return os.Expand(val, mapper)
 	}
 	params, err := env.GetFieldParamsWithOptions(cfg, opts)
</file context>
Fix with Cubic

@AndrewChubatiuk AndrewChubatiuk force-pushed the refactor-probes-and-defaults branch 2 times, most recently from 8932c2d to 5491f58 Compare March 3, 2026 15:59
opts := getEnvOpts()
mapper := func(v string) string {
return opts.Environment[v]
rawEnvVars := make(map[string]string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a dangerous function - we'll be expanding all env vars, not limited to the env var we want.

Lets move this expansion to UseProxyProtocol?

Copy link
Contributor Author

@AndrewChubatiuk AndrewChubatiuk Mar 4, 2026

Choose a reason for hiding this comment

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

it's a subset of functionality from carlos0/env library, which we're using already and this function is only used once to init metrics with env variables names and values

this expansion has nothing to do with useProxyProtocol

Copy link
Collaborator

@vrutkovs vrutkovs Mar 6, 2026

Choose a reason for hiding this comment

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

Oh, I see - its used in declaration like VM_OPERATOR_VERSION,expand. Why would we want to change anything here - is it for recursive env var expansion? In that case its best to limit the depth to some sensible value - 3 or maybe even 5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it for recursive env var expansion?

yes

its best to limit the depth to some sensible value - 3 or maybe even 5

agree, will update soon

@AndrewChubatiuk AndrewChubatiuk force-pushed the refactor-probes-and-defaults branch from 3f7044d to bf97d25 Compare March 4, 2026 15:40
AndrewChubatiuk and others added 2 commits March 5, 2026 08:30
- temporary replaced caarlos0/env with fork till PR is merged
- consolidate all functions for cluster defaults population
- merged EmbeddedProbes, CommonDefaultableParams and CommonApplicationDeploymentParams into CommonAppsParams
- moved setting terminationGracePeriodSeconds to defaults management
Co-authored-by: Vadim Rutkovsky <vadim@vrutkovs.eu>
Signed-off-by: Andrii Chubatiuk <andrew.chubatiuk@gmail.com>
@AndrewChubatiuk AndrewChubatiuk force-pushed the refactor-probes-and-defaults branch from bf97d25 to 3de2008 Compare March 5, 2026 06:48
@vrutkovs vrutkovs merged commit dfb2911 into master Mar 6, 2026
6 checks passed
@vrutkovs vrutkovs deleted the refactor-probes-and-defaults branch March 6, 2026 13:33
AndrewChubatiuk added a commit that referenced this pull request Mar 18, 2026
Co-authored-by: Vadim Rutkovsky <vadim@vrutkovs.eu>
AndrewChubatiuk added a commit that referenced this pull request Mar 18, 2026
Co-authored-by: Vadim Rutkovsky <vadim@vrutkovs.eu>
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.

2 participants