Skip to content

Commit

Permalink
EVEREST-1375: change images only when crVersion changes (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Kralik authored Aug 28, 2024
1 parent 75c1cab commit 402e089
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
26 changes: 23 additions & 3 deletions controllers/providers/pxc/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,14 @@ func (p *applier) applyHAProxyCfg() error {
if !ok {
return fmt.Errorf("haproxy version %s not available", bestHAProxyVersion)
}
haProxy.PodSpec.Image = haProxyVersion.ImagePath

// We can update the HAProxy image name only in case the CRVersions match.
// Otherwise we keep the image unchanged.
image := haProxyVersion.ImagePath
if p.currentPerconaXtraDBClusterSpec.HAProxy != nil && p.DBEngine.Status.OperatorVersion != p.DB.Status.CRVersion {
image = p.currentPerconaXtraDBClusterSpec.HAProxy.PodSpec.Image
}
haProxy.PodSpec.Image = image

if !p.DB.Spec.Proxy.Resources.CPU.IsZero() {
haProxy.PodSpec.Resources.Limits[corev1.ResourceCPU] = p.DB.Spec.Proxy.Resources.CPU
Expand Down Expand Up @@ -361,7 +368,13 @@ func (p *applier) applyProxySQLCfg() error {
return fmt.Errorf("proxysql version %s not available", bestProxySQLVersion)
}

proxySQL.Image = proxySQLVersion.ImagePath
// We can update the image name only in case the CRVersions match.
// Otherwise we keep the image unchanged.
image := proxySQLVersion.ImagePath
if p.currentPerconaXtraDBClusterSpec.ProxySQL != nil && p.DBEngine.Status.OperatorVersion != p.DB.Status.CRVersion {
image = p.currentPerconaXtraDBClusterSpec.ProxySQL.Image
}
proxySQL.Image = image

if !p.DB.Spec.Proxy.Resources.CPU.IsZero() {
proxySQL.Resources.Limits[corev1.ResourceCPU] = p.DB.Spec.Proxy.Resources.CPU
Expand Down Expand Up @@ -447,9 +460,16 @@ func (p *applier) genPXCBackupSpec() (*pxcv1.PXCScheduledBackup, error) {
return nil, fmt.Errorf("backup version %s not available", bestBackupVersion)
}

// We can update the image name only in case the CRVersions match.
// Otherwise we keep the image unchanged.
image := backupVersion.ImagePath
if p.currentPerconaXtraDBClusterSpec.Backup != nil && p.DBEngine.Status.OperatorVersion != p.DB.Status.CRVersion {
image = p.currentPerconaXtraDBClusterSpec.Backup.Image
}

// Initialize PXCScheduledBackup object
pxcBackupSpec := &pxcv1.PXCScheduledBackup{
Image: backupVersion.ImagePath,
Image: image,
PITR: pxcv1.PITRSpec{
Enabled: database.Spec.Backup.PITR.Enabled,
},
Expand Down
11 changes: 8 additions & 3 deletions controllers/providers/pxc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type Provider struct {
providers.ProviderOptions
*pxcv1.PerconaXtraDBCluster

// currentPerconaXtraDBClusterSpec holds the current PXC spec.
currentPerconaXtraDBClusterSpec pxcv1.PerconaXtraDBClusterSpec

clusterType common.ClusterType
operatorVersion *version.Version
}
Expand Down Expand Up @@ -93,12 +96,14 @@ func New(
return nil, err
}

currentSpec := pxc.Spec
pxc.Spec = defaultSpec()

p := &Provider{
PerconaXtraDBCluster: pxc,
ProviderOptions: opts,
operatorVersion: v,
PerconaXtraDBCluster: pxc,
ProviderOptions: opts,
operatorVersion: v,
currentPerconaXtraDBClusterSpec: currentSpec,
}

// Get cluster type.
Expand Down
5 changes: 0 additions & 5 deletions e2e-tests/tests/upgrade/pg/98-drop-pvc.yaml

This file was deleted.

0 comments on commit 402e089

Please sign in to comment.