Skip to content

Commit

Permalink
build/default: properly apply global container registry for VMCluster
Browse files Browse the repository at this point in the history
Regression was introduced at v0.48.0 release

 Related issue #1118

Signed-off-by: f41gh7 <[email protected]>
  • Loading branch information
f41gh7 committed Sep 27, 2024
1 parent d39fc94 commit db072e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/operator/factory/build/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 7 additions & 3 deletions internal/controller/operator/factory/build/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit db072e5

Please sign in to comment.