Skip to content
Closed
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
80 changes: 22 additions & 58 deletions api/operator/v1/cluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,87 +80,51 @@ func TestVLCluster_AvailableStorageNodeIDs(t *testing.T) {
}

func TestVLSingle_PrefixedName(t *testing.T) {
f := func(name string, omit bool, want string) {
t.Helper()
cr := &VLSingle{Spec: VLSingleSpec{UseLegacyNaming: omit}}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName())
}

f("myapp", false, "vlsingle-myapp")
f("myapp", true, "myapp")
cr := &VLSingle{}
cr.Name = "myapp"
assert.Equal(t, "vlsingle-myapp", cr.PrefixedName())
}

func TestVTSingle_PrefixedName(t *testing.T) {
f := func(name string, omit bool, want string) {
t.Helper()
cr := &VTSingle{Spec: VTSingleSpec{UseLegacyNaming: omit}}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName())
}

f("myapp", false, "vtsingle-myapp")
f("myapp", true, "myapp")
cr := &VTSingle{}
cr.Name = "myapp"
assert.Equal(t, "vtsingle-myapp", cr.PrefixedName())
}

func TestVLAgent_PrefixedName(t *testing.T) {
f := func(name string, omit bool, want string) {
t.Helper()
cr := &VLAgent{Spec: VLAgentSpec{UseLegacyNaming: omit}}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName())
}

f("myapp", false, "vlagent-myapp")
f("myapp", true, "myapp")
cr := &VLAgent{}
cr.Name = "myapp"
assert.Equal(t, "vlagent-myapp", cr.PrefixedName())
}

func TestVMAnomaly_PrefixedName(t *testing.T) {
f := func(name string, omit bool, want string) {
t.Helper()
cr := &VMAnomaly{Spec: VMAnomalySpec{UseLegacyNaming: omit}}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName())
}

f("myapp", false, "vmanomaly-myapp")
f("myapp", true, "myapp")
cr := &VMAnomaly{}
cr.Name = "myapp"
assert.Equal(t, "vmanomaly-myapp", cr.PrefixedName())
}

func TestVLCluster_PrefixedName(t *testing.T) {
f := func(name string, omit bool, kind vmv1beta1.ClusterComponent, want string) {
f := func(name string, kind vmv1beta1.ClusterComponent, want string) {
t.Helper()
cr := &VLCluster{Spec: VLClusterSpec{UseLegacyNaming: omit}}
cr := &VLCluster{}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName(kind))
}

// default — <component>-<name>
f("myapp", false, vmv1beta1.ClusterComponentSelect, "vlselect-myapp")
f("myapp", false, vmv1beta1.ClusterComponentInsert, "vlinsert-myapp")
f("myapp", false, vmv1beta1.ClusterComponentStorage, "vlstorage-myapp")

// useLegacyNaming — <name>-<component>
f("myapp", true, vmv1beta1.ClusterComponentSelect, "myapp-vlselect")
f("myapp", true, vmv1beta1.ClusterComponentInsert, "myapp-vlinsert")
f("myapp", true, vmv1beta1.ClusterComponentStorage, "myapp-vlstorage")
f("myapp", vmv1beta1.ClusterComponentSelect, "vlselect-myapp")
f("myapp", vmv1beta1.ClusterComponentInsert, "vlinsert-myapp")
f("myapp", vmv1beta1.ClusterComponentStorage, "vlstorage-myapp")
}

func TestVTCluster_PrefixedName(t *testing.T) {
f := func(name string, omit bool, kind vmv1beta1.ClusterComponent, want string) {
f := func(name string, kind vmv1beta1.ClusterComponent, want string) {
t.Helper()
cr := &VTCluster{Spec: VTClusterSpec{UseLegacyNaming: omit}}
cr := &VTCluster{}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName(kind))
}

// default — <component>-<name>
f("myapp", false, vmv1beta1.ClusterComponentSelect, "vtselect-myapp")
f("myapp", false, vmv1beta1.ClusterComponentInsert, "vtinsert-myapp")
f("myapp", false, vmv1beta1.ClusterComponentStorage, "vtstorage-myapp")

// useLegacyNaming — <name>-<component>
f("myapp", true, vmv1beta1.ClusterComponentSelect, "myapp-vtselect")
f("myapp", true, vmv1beta1.ClusterComponentInsert, "myapp-vtinsert")
f("myapp", true, vmv1beta1.ClusterComponentStorage, "myapp-vtstorage")
f("myapp", vmv1beta1.ClusterComponentSelect, "vtselect-myapp")
f("myapp", vmv1beta1.ClusterComponentInsert, "vtinsert-myapp")
f("myapp", vmv1beta1.ClusterComponentStorage, "vtstorage-myapp")
}
10 changes: 2 additions & 8 deletions api/operator/v1/vlagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
vmv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1"
)

const VLAgentQueueMetricName = "vlagent_remotewrite_pending_data_bytes"

// VLAgentSpec defines the desired state of VLAgent
// +k8s:openapi-gen=true
type VLAgentSpec struct {
Expand Down Expand Up @@ -97,11 +99,6 @@ type VLAgentSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
Expand Down Expand Up @@ -431,9 +428,6 @@ func (cr *VLAgent) FinalLabels() map[string]string {

// PrefixedName returns name of resource with fixed prefix
func (cr *VLAgent) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vlagent-%s", cr.Name)
}

Expand Down
12 changes: 0 additions & 12 deletions api/operator/v1/vlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ type VLClusterSpec struct {
// going to be performed, except for delete actions.
// +optional
Paused bool `json:"paused,omitempty"`
// UseLegacyNaming switches component resource naming from the default prefix convention
// (<component>-<name>, e.g. "vlselect-myapp") to a suffix convention (<name>-<component>,
// e.g. "myapp-vlselect"). Useful when migrating from standalone Helm charts.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
// UseStrictSecurity enables strict security mode for component
// it restricts disk writes access
// uses non-root user out of the box
Expand Down Expand Up @@ -182,17 +176,11 @@ func (cr *VLCluster) FinalAnnotations() map[string]string {

// PrefixedName returns prefixed name for the given component kind
func (cr *VLCluster) PrefixedName(kind vmv1beta1.ClusterComponent) string {
if cr.Spec.UseLegacyNaming {
return vmv1beta1.ClusterSuffixedName(kind, cr.Name, "vl", false)
}
return vmv1beta1.ClusterPrefixedName(kind, cr.Name, "vl", false)
}

// PrefixedInternalName returns prefixed name for the given component kind
func (cr *VLCluster) PrefixedInternalName(kind vmv1beta1.ClusterComponent) string {
if cr.Spec.UseLegacyNaming {
return vmv1beta1.ClusterSuffixedName(kind, cr.Name, "vl", true)
}
return vmv1beta1.ClusterPrefixedName(kind, cr.Name, "vl", true)
}

Expand Down
9 changes: 0 additions & 9 deletions api/operator/v1/vlsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ type VLSingleSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
// +optional
Expand Down Expand Up @@ -280,9 +274,6 @@ func (cr *VLSingle) ResourceLabels(input map[string]string) map[string]string {
}

func (cr *VLSingle) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vlsingle-%s", cr.Name)
}

Expand Down
8 changes: 0 additions & 8 deletions api/operator/v1/vmanomaly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ type VMAnomalySpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
}

Expand Down Expand Up @@ -409,9 +404,6 @@ func (cr *VMAnomaly) FinalLabels() map[string]string {

// PrefixedName format name of the component with hard-coded prefix
func (cr *VMAnomaly) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vmanomaly-%s", cr.Name)
}

Expand Down
12 changes: 0 additions & 12 deletions api/operator/v1/vtcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ type VTClusterSpec struct {
// going to be performed, except for delete actions.
// +optional
Paused bool `json:"paused,omitempty"`
// UseLegacyNaming switches component resource naming from the default prefix convention
// (<component>-<name>, e.g. "vtselect-myapp") to a suffix convention (<name>-<component>,
// e.g. "myapp-vtselect"). Useful when migrating from standalone Helm charts.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
// UseStrictSecurity enables strict security mode for component
// it restricts disk writes access
// uses non-root user out of the box
Expand Down Expand Up @@ -177,17 +171,11 @@ func (cr *VTCluster) FinalAnnotations() map[string]string {

// PrefixedName returns prefixed name for the given component kind
func (cr *VTCluster) PrefixedName(kind vmv1beta1.ClusterComponent) string {
if cr.Spec.UseLegacyNaming {
return vmv1beta1.ClusterSuffixedName(kind, cr.Name, "vt", false)
}
return vmv1beta1.ClusterPrefixedName(kind, cr.Name, "vt", false)
}

// PrefixedInternalName returns prefixed name for the given component kind
func (cr *VTCluster) PrefixedInternalName(kind vmv1beta1.ClusterComponent) string {
if cr.Spec.UseLegacyNaming {
return vmv1beta1.ClusterSuffixedName(kind, cr.Name, "vt", true)
}
return vmv1beta1.ClusterPrefixedName(kind, cr.Name, "vt", true)
}

Expand Down
9 changes: 0 additions & 9 deletions api/operator/v1/vtsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ type VTSingleSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
// +optional
Expand Down Expand Up @@ -275,9 +269,6 @@ func (cr *VTSingle) ResourceLabels(input map[string]string) map[string]string {

// PrefixedName format name of the component with hard-coded prefix
func (cr *VTSingle) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vtsingle-%s", cr.Name)
}

Expand Down
9 changes: 0 additions & 9 deletions api/operator/v1beta1/vlogs_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ type VLogsSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
// +optional
Expand Down Expand Up @@ -247,9 +241,6 @@ func (cr *VLogs) FinalAnnotations() map[string]string {
}

func (cr *VLogs) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vlogs-%s", cr.Name)
}

Expand Down
11 changes: 2 additions & 9 deletions api/operator/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

const VMAgentQueueMetricName = "vmagent_remotewrite_pending_data_bytes"

// VMAgentSpec defines the desired state of VMAgent
// +k8s:openapi-gen=true
type VMAgentSpec struct {
Expand Down Expand Up @@ -128,12 +130,6 @@ type VMAgentSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
// +optional
Expand Down Expand Up @@ -566,9 +562,6 @@ func (cr *VMAgent) FinalAnnotations() map[string]string {
}

func (cr *VMAgent) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vmagent-%s", cr.Name)
}

Expand Down
12 changes: 3 additions & 9 deletions api/operator/v1beta1/vmagent_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,9 @@ func TestVMAgent_DefaultStatusFields(t *testing.T) {
}

func TestVMAgent_PrefixedName(t *testing.T) {
f := func(name string, omit bool, want string) {
t.Helper()
cr := &VMAgent{Spec: VMAgentSpec{UseLegacyNaming: omit}}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName())
}

f("myapp", false, "vmagent-myapp")
f("myapp", true, "myapp")
cr := &VMAgent{}
cr.Name = "myapp"
assert.Equal(t, "vmagent-myapp", cr.PrefixedName())
}

// TestVMAgent_IsUnmanaged is the VMAgent counterpart of TestVMAlert_IsUnmanaged.
Expand Down
9 changes: 0 additions & 9 deletions api/operator/v1beta1/vmalert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ type VMAlertSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
// +notes={available_from: "v0.73.0"}
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
// +optional
Expand Down Expand Up @@ -457,9 +451,6 @@ func (cr *VMAlert) FinalAnnotations() map[string]string {
}

func (cr *VMAlert) PrefixedName() string {
if cr.Spec.UseLegacyNaming {
return cr.Name
}
return fmt.Sprintf("vmalert-%s", cr.Name)
}

Expand Down
12 changes: 3 additions & 9 deletions api/operator/v1beta1/vmalert_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,9 @@ func TestVMAlert_ValidateFail(t *testing.T) {
}

func TestVMAlert_PrefixedName(t *testing.T) {
f := func(name string, omit bool, want string) {
t.Helper()
cr := &VMAlert{Spec: VMAlertSpec{UseLegacyNaming: omit}}
cr.Name = name
assert.Equal(t, want, cr.PrefixedName())
}

f("myapp", false, "vmalert-myapp")
f("myapp", true, "myapp")
cr := &VMAlert{}
cr.Name = "myapp"
assert.Equal(t, "vmalert-myapp", cr.PrefixedName())
}

// TestVMAlert_IsUnmanaged: an unknown-fields-only ParsingSpecError (the operator's
Expand Down
Loading
Loading