From 5f7d0b8af3c9256476db1836983dcab91a4a3a73 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 14:20:47 -0600 Subject: [PATCH] add mysql_server_version flag to vtbackup and mysqlctld Signed-off-by: Florent Poinsard --- pkg/controller/vitessshard/reconcile_backup_job.go | 2 +- pkg/operator/vttablet/pod.go | 5 ++++- pkg/operator/vttablet/vtbackup_pod.go | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/controller/vitessshard/reconcile_backup_job.go b/pkg/controller/vitessshard/reconcile_backup_job.go index a302fb04..ab341cba 100644 --- a/pkg/controller/vitessshard/reconcile_backup_job.go +++ b/pkg/controller/vitessshard/reconcile_backup_job.go @@ -141,7 +141,7 @@ func (r *ReconcileVitessShard) reconcileBackupJob(ctx context.Context, vts *plan Kind: &corev1.Pod{}, New: func(key client.ObjectKey) runtime.Object { - return vttablet.NewBackupPod(key, specMap[key]) + return vttablet.NewBackupPod(key, specMap[key], vts.Spec.Images.Mysqld.Image()) }, Status: func(key client.ObjectKey, obj runtime.Object) { pod := obj.(*corev1.Pod) diff --git a/pkg/operator/vttablet/pod.go b/pkg/operator/vttablet/pod.go index 5e8bdfbe..9dcc25f1 100644 --- a/pkg/operator/vttablet/pod.go +++ b/pkg/operator/vttablet/pod.go @@ -167,13 +167,16 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) { var mysqldContainer *corev1.Container var mysqldExporterContainer *corev1.Container + mysqlctldAllFlags := mysqlctldFlags.Get(spec) + mysql.UpdateMySQLServerVersion(mysqlctldAllFlags, spec.Images.Mysqld.Image()) + if spec.Mysqld != nil { mysqldContainer = &corev1.Container{ Name: MysqldContainerName, Image: spec.Images.Mysqld.Image(), ImagePullPolicy: spec.ImagePullPolicies.Mysqld, Command: []string{mysqldCommand}, - Args: mysqlctldFlags.Get(spec).FormatArgs(), + Args: mysqlctldAllFlags.FormatArgs(), Ports: []corev1.ContainerPort{ { Name: planetscalev2.DefaultMysqlPortName, diff --git a/pkg/operator/vttablet/vtbackup_pod.go b/pkg/operator/vttablet/vtbackup_pod.go index 8dcd80d6..5823cdb1 100644 --- a/pkg/operator/vttablet/vtbackup_pod.go +++ b/pkg/operator/vttablet/vtbackup_pod.go @@ -23,6 +23,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" + "planetscale.dev/vitess-operator/pkg/operator/mysql" "sigs.k8s.io/controller-runtime/pkg/client" planetscalev2 "planetscale.dev/vitess-operator/pkg/apis/planetscale/v2" @@ -92,7 +93,7 @@ func InitialBackupPodName(clusterName, keyspaceName string, keyRange planetscale // NewBackupPod creates a new vtbackup Pod, which is like a special kind of // minimal tablet used to run backups as a batch process. -func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec) *corev1.Pod { +func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage string) *corev1.Pod { tabletSpec := backupSpec.TabletSpec // Include vttablet env vars, since we run some vttablet code like backups. @@ -132,6 +133,8 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec) *corev1.Pod { // Make a copy of Resources since it contains pointers. update.ResourceRequirements(&containerResources, &tabletSpec.Mysqld.Resources) + vtbackupAllFlags := vtbackupFlags.Get(backupSpec) + mysql.UpdateMySQLServerVersion(vtbackupAllFlags, mysqldImage) pod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Namespace: key.Namespace, @@ -171,7 +174,7 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec) *corev1.Pod { Image: tabletSpec.Images.Mysqld.Image(), ImagePullPolicy: tabletSpec.ImagePullPolicies.Mysqld, Command: []string{vtbackupCommand}, - Args: vtbackupFlags.Get(backupSpec).FormatArgs(), + Args: vtbackupAllFlags.FormatArgs(), Resources: containerResources, SecurityContext: securityContext, Env: env,