From db072e5210130a4b4abd1836495551b28639688e Mon Sep 17 00:00:00 2001 From: f41gh7 Date: Sat, 28 Sep 2024 01:35:11 +0200 Subject: [PATCH] build/default: properly apply global container registry for VMCluster Regression was introduced at v0.48.0 release Related issue https://github.com/VictoriaMetrics/operator/issues/1118 Signed-off-by: f41gh7 --- docs/CHANGELOG.md | 2 ++ .../controller/operator/factory/build/container.go | 4 ++-- .../operator/factory/build/container_test.go | 2 +- internal/controller/operator/factory/build/defaults.go | 10 +++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 88a4fa1f..866d3e0b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,8 @@ aliases: - /operator/changelog/index.html --- +- [vmcluster](https://docs.victoriametrics.com/operator/resources/vmcluster): properly apply global container registry from configuration. It was ignored for `VMCluster` since `v0.48.0` release. See [this issue](https://github.com/VictoriaMetrics/operator/issues/1118) for details. + ## [v0.48.2](https://github.com/VictoriaMetrics/operator/releases/tag/v0.48.2) - 27 Sep 2024 - [operator](https://docs.victoriametrics.com/operator/): properly expose `vm_app_version` metric tag with `version` and `short_version` build info. It was broken since v0.46.0 release. diff --git a/internal/controller/operator/factory/build/container.go b/internal/controller/operator/factory/build/container.go index fc4b4a61..85ba7a17 100644 --- a/internal/controller/operator/factory/build/container.go +++ b/internal/controller/operator/factory/build/container.go @@ -196,8 +196,8 @@ func AddExtraArgsOverrideDefaults(args []string, extraArgs map[string]string, da return args } -// FormatContainerImage returns container image with registry prefix if needed. -func FormatContainerImage(globalRepo string, containerImage string) string { +// formatContainerImage returns container image with registry prefix if needed. +func formatContainerImage(globalRepo string, containerImage string) string { if globalRepo == "" { // no need to add global repo return containerImage diff --git a/internal/controller/operator/factory/build/container_test.go b/internal/controller/operator/factory/build/container_test.go index cd473308..b80c8304 100644 --- a/internal/controller/operator/factory/build/container_test.go +++ b/internal/controller/operator/factory/build/container_test.go @@ -257,7 +257,7 @@ func Test_addExtraArgsOverrideDefaults(t *testing.T) { func TestFormatContainerImage(t *testing.T) { f := func(globalRepo, image, wantImage string) { t.Helper() - gotImage := FormatContainerImage(globalRepo, image) + gotImage := formatContainerImage(globalRepo, image) if gotImage != wantImage { t.Errorf("unexpected container image, got: \n%s\nwant: \n%s", gotImage, wantImage) } diff --git a/internal/controller/operator/factory/build/defaults.go b/internal/controller/operator/factory/build/defaults.go index 6389234d..a67719af 100644 --- a/internal/controller/operator/factory/build/defaults.go +++ b/internal/controller/operator/factory/build/defaults.go @@ -336,6 +336,8 @@ func addVMClusterDefaults(objI interface{}) { if cr.Spec.VMStorage.Image.Repository == "" { cr.Spec.VMStorage.Image.Repository = c.VMClusterDefault.VMStorageDefault.Image } + cr.Spec.VMStorage.Image.Repository = formatContainerImage(c.ContainerRegistry, cr.Spec.VMStorage.Image.Repository) + if cr.Spec.VMStorage.Image.Tag == "" { if cr.Spec.ClusterVersion != "" { cr.Spec.VMStorage.Image.Tag = cr.Spec.ClusterVersion @@ -390,6 +392,7 @@ func addVMClusterDefaults(objI interface{}) { if cr.Spec.VMInsert.Image.Repository == "" { cr.Spec.VMInsert.Image.Repository = c.VMClusterDefault.VMInsertDefault.Image } + cr.Spec.VMInsert.Image.Repository = formatContainerImage(c.ContainerRegistry, cr.Spec.VMInsert.Image.Repository) if cr.Spec.VMInsert.Image.Tag == "" { if cr.Spec.ClusterVersion != "" { cr.Spec.VMInsert.Image.Tag = cr.Spec.ClusterVersion @@ -422,6 +425,7 @@ func addVMClusterDefaults(objI interface{}) { if cr.Spec.VMSelect.Image.Repository == "" { cr.Spec.VMSelect.Image.Repository = c.VMClusterDefault.VMSelectDefault.Image } + cr.Spec.VMSelect.Image.Repository = formatContainerImage(c.ContainerRegistry, cr.Spec.VMSelect.Image.Repository) if cr.Spec.VMSelect.Image.Tag == "" { if cr.Spec.ClusterVersion != "" { cr.Spec.VMSelect.Image.Tag = cr.Spec.ClusterVersion @@ -466,7 +470,7 @@ func addDefaultsToCommonParams(common *vmv1beta1.CommonDefaultableParams, appDef if common.DisableSelfServiceScrape == nil { common.DisableSelfServiceScrape = &c.DisableSelfServiceScrapeCreation } - common.Image.Repository = FormatContainerImage(c.ContainerRegistry, common.Image.Repository) + common.Image.Repository = formatContainerImage(c.ContainerRegistry, common.Image.Repository) if common.Image.Tag == "" { common.Image.Tag = appDefaults.Version } @@ -502,7 +506,7 @@ func addDefaluesToConfigReloader(common *vmv1beta1.CommonConfigReloaderParams, u } } - common.ConfigReloaderImageTag = FormatContainerImage(c.ContainerRegistry, common.ConfigReloaderImageTag) + common.ConfigReloaderImageTag = formatContainerImage(c.ContainerRegistry, common.ConfigReloaderImageTag) common.ConfigReloaderResources = Resources(common.ConfigReloaderResources, config.Resource{ Limit: struct { Mem string @@ -530,7 +534,7 @@ func addDefaultsToVMBackup(cr *vmv1beta1.VMBackup, useDefaultResources bool, app if cr.Image.Repository == "" { cr.Image.Repository = appDefaults.Image } - cr.Image.Repository = FormatContainerImage(c.ContainerRegistry, cr.Image.Repository) + cr.Image.Repository = formatContainerImage(c.ContainerRegistry, cr.Image.Repository) if cr.Image.Tag == "" { cr.Image.Tag = appDefaults.Version }