Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image usage #1125

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
11 changes: 7 additions & 4 deletions pkg/controller/pxc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,14 @@ func (r *ReconcilePerconaXtraDBCluster) Reconcile(_ context.Context, request rec

r.resyncPXCUsersWithProxySQL(o)

if o.Status.PXC.Version == "" || strings.HasSuffix(o.Status.PXC.Version, "intermediate") {
err := r.ensurePXCVersion(o, VersionServiceClient{OpVersion: o.Version().String()})
if err != nil {
reqLogger.Info("failed to ensure version, running with default", "error", err)
if isSmartUpdate(o) {
if o.Status.PXC.Version == "" || strings.HasSuffix(o.Status.PXC.Version, "intermediate") {
err := r.ensurePXCVersion(o, VersionServiceClient{OpVersion: o.Version().String()})
if err != nil {
reqLogger.Info("failed to ensure version, running with default", "error", err)
}
}
o.Spec.PXC.Image = o.Status.PXC.Image
}

err = r.deploy(o)
Expand Down
14 changes: 13 additions & 1 deletion pkg/controller/pxc/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,18 @@ func jobName(cr *apiv1.PerconaXtraDBCluster) string {
return fmt.Sprintf("%s/%s", jobName, nn.String())
}

func (r *ReconcilePerconaXtraDBCluster) ensurePXCVersion(cr *apiv1.PerconaXtraDBCluster, vs VersionService) error {
func isSmartUpdate(cr *apiv1.PerconaXtraDBCluster) bool {
if cr.Spec.UpdateStrategy != apiv1.SmartUpdateStatefulSetStrategyType ||
cr.Spec.UpgradeOptions.Schedule == "" ||
strings.ToLower(cr.Spec.UpgradeOptions.Apply) == never ||
strings.ToLower(cr.Spec.UpgradeOptions.Apply) == disabled {
return false
}
return true
}

func (r *ReconcilePerconaXtraDBCluster) ensurePXCVersion(cr *apiv1.PerconaXtraDBCluster, vs VersionService) error {
if !isSmartUpdate(cr) {
return nil
}

Expand Down Expand Up @@ -220,12 +227,17 @@ func (r *ReconcilePerconaXtraDBCluster) ensurePXCVersion(cr *apiv1.PerconaXtraDB
}

cr.Status.ProxySQL.Version = newVersion.ProxySqlVersion
cr.Status.ProxySQL.Image = newVersion.ProxySqlImage
cr.Status.HAProxy.Version = newVersion.HAProxyVersion
cr.Status.HAProxy.Image = newVersion.HAProxyImage
cr.Status.PMM.Version = newVersion.PMMVersion
cr.Status.PMM.Image = newVersion.PMMImage
cr.Status.Backup.Version = newVersion.BackupVersion
cr.Status.Backup.Image = newVersion.BackupImage
cr.Status.PXC.Version = newVersion.PXCVersion
cr.Status.PXC.Image = newVersion.PXCImage
cr.Status.LogCollector.Version = newVersion.LogCollectorVersion
cr.Status.LogCollector.Image = newVersion.LogCollectorImage

return r.client.Status().Update(context.Background(), cr)
})
Expand Down