Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,17 @@ test: manifests generate fmt vet envtest ## Run tests.
lint: golangci-lint ## Run golangci-lint linter
cd api && $(GOLANGCI_LINT) run operator/... & P1=$$!; \
$(GOLANGCI_LINT) run & P2=$$!; \
wait $$P1; wait $$P2
wait $$P1; S1=$$?; \

@cubic-dev-ai cubic-dev-ai Bot Aug 28, 2026

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.

P3: Under errexit (.SHELLFLAGS = -ec), the shell terminates as soon as wait $$P1 returns non-zero, so S1=$$? (and S2=$$?) is never assigned on a linter failure. The final [ $$S1 -eq 0 ] && [ $$S2 -eq 0 ] only runs when both linters already succeeded, so the newly added status-capture logic is dead and the target still fails only because errexit aborts the recipe. Since errexit already guarantees the correct pass/fail behavior, revert to the simpler wait $$P1; wait $$P2 in both lint and lint-fix, or restructure the capture (e.g. wait $$P1 || S1=1; wait $$P2 || S1=$$((S1|1))) if you intend to keep both runs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Makefile, line 168:

<comment>Under errexit (`.SHELLFLAGS = -ec`), the shell terminates as soon as `wait $$P1` returns non-zero, so `S1=$$?` (and `S2=$$?`) is never assigned on a linter failure. The final `[ $$S1 -eq 0 ] && [ $$S2 -eq 0 ]` only runs when both linters already succeeded, so the newly added status-capture logic is dead and the target still fails only because errexit aborts the recipe. Since errexit already guarantees the correct pass/fail behavior, revert to the simpler `wait $$P1; wait $$P2` in both `lint` and `lint-fix`, or restructure the capture (e.g. `wait $$P1 || S1=1; wait $$P2 || S1=$$((S1|1))`) if you intend to keep both runs.</comment>

<file context>
@@ -165,13 +165,17 @@ test: manifests generate fmt vet envtest ## Run tests.
 	cd api && $(GOLANGCI_LINT) run operator/... & P1=$$!; \
 	$(GOLANGCI_LINT) run & P2=$$!; \
-	wait $$P1; wait $$P2
+	wait $$P1; S1=$$?; \
+	wait $$P2; S2=$$?; \
+	[ $$S1 -eq 0 ] && [ $$S2 -eq 0 ]
</file context>
Fix with cubic

wait $$P2; S2=$$?; \
[ $$S1 -eq 0 ] && [ $$S2 -eq 0 ]

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
cd api && $(GOLANGCI_LINT) run --fix operator/... & P1=$$!; \
$(GOLANGCI_LINT) run --fix & P2=$$!; \
wait $$P1; wait $$P2
wait $$P1; S1=$$?; \
wait $$P2; S2=$$?; \
[ $$S1 -eq 0 ] && [ $$S2 -eq 0 ]

##@ Build

Expand Down Expand Up @@ -357,7 +361,7 @@ COSIGN_BIN ?= $(LOCALBIN)/cosign-$(COSIGN_VERSION)
## Tool Versions
KUSTOMIZE_VERSION ?= v5.8.1
CONTROLLER_TOOLS_VERSION ?= v0.22.0
ENVTEST_VERSION ?= release-0.23
ENVTEST_VERSION ?= release-0.24
GOLANGCI_LINT_VERSION ?= v2.13.2
CODEGENERATOR_VERSION ?= v0.37.0
OLM_VERSION ?= 0.46.0
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/VictoriaMetrics/operator/api

// NOTE: modify go version only if it's really needed
// and api package is no longer compatible with previous go versions.
go 1.26.6
go 1.27.0

require (
github.com/VictoriaMetrics/VictoriaMetrics v1.151.0
Expand Down
2 changes: 1 addition & 1 deletion api/operator/v1/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
"encoding/json"
"encoding/json/v2"
"fmt"
"net/url"
"strconv"
Expand Down
7 changes: 4 additions & 3 deletions api/operator/v1/vlagent_types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand Down Expand Up @@ -108,7 +109,7 @@ type VLAgentSpec struct {
// Configures vertical pod autoscaling.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`
}

type VLAgentK8sCollector struct {
Expand Down Expand Up @@ -380,7 +381,7 @@ func (cr *VLAgent) UnmarshalJSON(src []byte) error {
type pcr VLAgent
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions api/operator/v1/vlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand Down Expand Up @@ -701,7 +702,7 @@ func (cr *VLCluster) UnmarshalJSON(src []byte) error {
type pcr VLCluster
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions api/operator/v1/vlsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand All @@ -41,7 +42,7 @@ type VLSingleSpec struct {
// created by operator for the given CustomResource
ManagedMetadata *vmv1beta1.ManagedObjectsMetadata `json:"managedMetadata,omitempty"`

vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`

// LogLevel for VictoriaLogs to be configured with.
// +optional
Expand Down Expand Up @@ -183,7 +184,7 @@ func (cr *VLSingle) UnmarshalJSON(src []byte) error {
type pcr VLSingle
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
9 changes: 5 additions & 4 deletions api/operator/v1/vmanomaly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"path"
"strings"
Expand Down Expand Up @@ -135,7 +136,7 @@ type VMAnomalySpec struct {
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`
}

// VMAnomalyWritersSpec defines writer configuration for VMAnomaly
Expand Down Expand Up @@ -166,7 +167,7 @@ type VMAnomalyWritersSpec struct {
// +kubebuilder:validation:Minimum=0
MetricPrefixCacheMaxEntries *int `json:"metricPrefixCacheMaxEntries,omitempty" yaml:"metric_prefix_cache_max_entries,omitempty"`
// +optional
VMAnomalyHTTPClientSpec `json:",inline,omitempty" yaml:",inline,omitempty"`
VMAnomalyHTTPClientSpec `json:",inline" yaml:",inline,omitempty"`
}

// VMAnomalyVMWriterMetricFormatSpec defines the desired state of VMAnomalyVMWriterMetricFormat
Expand Down Expand Up @@ -381,7 +382,7 @@ func (cr *VMAnomaly) UnmarshalJSON(src []byte) error {
type pcr VMAnomaly
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions api/operator/v1/vtagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand Down Expand Up @@ -108,7 +109,7 @@ type VTAgentSpec struct {
// Configures vertical pod autoscaling.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`
}

// Validate performs syntax validation
Expand Down Expand Up @@ -324,7 +325,7 @@ func (cr *VTAgent) UnmarshalJSON(src []byte) error {
type pcr VTAgent
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions api/operator/v1/vtcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand Down Expand Up @@ -614,7 +615,7 @@ func (cr *VTCluster) UnmarshalJSON(src []byte) error {
type pcr VTCluster
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions api/operator/v1/vtsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand All @@ -41,7 +42,7 @@ type VTSingleSpec struct {
// created by operator for the given CustomResource
ManagedMetadata *vmv1beta1.ManagedObjectsMetadata `json:"managedMetadata,omitempty"`

vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`

// LogLevel for VictoriaTraces to be configured with.
// +optional
Expand Down Expand Up @@ -176,7 +177,7 @@ func (cr *VTSingle) UnmarshalJSON(src []byte) error {
type pcr VTSingle
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions api/operator/v1alpha1/vldistributed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1alpha1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand Down Expand Up @@ -263,7 +264,7 @@ type VLDistributedZoneAgentSpec struct {
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`

vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`
}

// ToVLAgentSpec converts VLDistributedZoneAgentSpec to vmv1.VLAgentSpec via JSON round-trip.
Expand Down Expand Up @@ -454,7 +455,7 @@ func (cr *VLDistributed) UnmarshalJSON(src []byte) error {
type pcr VLDistributed
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions api/operator/v1alpha1/vmdistributed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1alpha1

import (
"encoding/json"
"encoding/json/jsontext"
"encoding/json/v2"
"fmt"
"strings"

Expand Down Expand Up @@ -283,7 +284,7 @@ type VMDistributedZoneAgentSpec struct {
// +optional
HPA *vmv1beta1.EmbeddedHPA `json:"hpa,omitempty"`

vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline"`
}

func (s *VMDistributedZoneAgentSpec) ToVMAgentSpec() (*vmv1beta1.VMAgentSpec, error) {
Expand Down Expand Up @@ -490,7 +491,7 @@ func (cr *VMDistributed) UnmarshalJSON(src []byte) error {
type pcr VMDistributed
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
Spec jsontext.Value `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
Expand Down
Loading