Skip to content

Commit

Permalink
add mysql_server_version flag to vtctld
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Jan 18, 2024
1 parent 5f7d0b8 commit 25f08b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/vitesscluster/reconcile_vtctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ func (r *ReconcileVitessCluster) reconcileVtctld(ctx context.Context, vt *planet
Kind: &appsv1.Deployment{},

New: func(key client.ObjectKey) runtime.Object {
return vtctld.NewDeployment(key, specMap[key])
return vtctld.NewDeployment(key, specMap[key], vt.Spec.Images.Mysqld.Image())
},
UpdateInPlace: func(key client.ObjectKey, obj runtime.Object) {
newObj := obj.(*appsv1.Deployment)
if *vt.Spec.UpdateStrategy.Type == planetscalev2.ImmediateVitessClusterUpdateStrategyType {
vtctld.UpdateDeployment(newObj, specMap[key])
vtctld.UpdateDeployment(newObj, specMap[key], vt.Spec.Images.Mysqld.Image())
return
}
vtctld.UpdateDeploymentImmediate(newObj, specMap[key])
},
UpdateRollingInPlace: func(key client.ObjectKey, obj runtime.Object) {
newObj := obj.(*appsv1.Deployment)
vtctld.UpdateDeployment(newObj, specMap[key])
vtctld.UpdateDeployment(newObj, specMap[key], vt.Spec.Images.Mysqld.Image())
},
Status: func(key client.ObjectKey, obj runtime.Object) {
// This function will get called once for each Deployment.
Expand Down
8 changes: 5 additions & 3 deletions pkg/operator/vtctld/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"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"
Expand Down Expand Up @@ -74,7 +75,7 @@ type Spec struct {
}

// NewDeployment creates a new Deployment object for vtctld.
func NewDeployment(key client.ObjectKey, spec *Spec) *appsv1.Deployment {
func NewDeployment(key client.ObjectKey, spec *Spec, mysqldImage string) *appsv1.Deployment {
// Fill in the immutable parts.
obj := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -88,7 +89,7 @@ func NewDeployment(key client.ObjectKey, spec *Spec) *appsv1.Deployment {
},
}
// Set everything else.
UpdateDeployment(obj, spec)
UpdateDeployment(obj, spec, mysqldImage)
return obj
}

Expand All @@ -104,7 +105,7 @@ func UpdateDeploymentImmediate(obj *appsv1.Deployment, spec *Spec) {

// UpdateDeployment updates the mutable parts of the vtctld Deployment
// that should be changed as part of a gradual, rolling update.
func UpdateDeployment(obj *appsv1.Deployment, spec *Spec) {
func UpdateDeployment(obj *appsv1.Deployment, spec *Spec, mysqldImage string) {
UpdateDeploymentImmediate(obj, spec)

// Reset Pod template labels so we remove old ones.
Expand All @@ -131,6 +132,7 @@ func UpdateDeployment(obj *appsv1.Deployment, spec *Spec) {
key = strings.TrimLeft(key, "-")
flags[key] = value
}
mysql.UpdateMySQLServerVersion(flags, mysqldImage)

// Set only the Pod template fields we care about.
// Use functions from the `operator/update` package for lists
Expand Down

0 comments on commit 25f08b6

Please sign in to comment.