Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Oct 10, 2024
1 parent 131a1c4 commit e403fa4
Show file tree
Hide file tree
Showing 22 changed files with 29 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: some-name
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-haproxy
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-haproxy
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-haproxy
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-haproxy
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ spec:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: proxysql
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: proxydata
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ spec:
type: OnDelete
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: pxc
app.kubernetes.io/instance: upgrade-proxysql
app.kubernetes.io/managed-by: percona-xtradb-cluster-operator
app.kubernetes.io/name: percona-xtradb-cluster
app.kubernetes.io/part-of: percona-xtradb-cluster
name: datadir
spec:
accessModes:
Expand Down
23 changes: 22 additions & 1 deletion pkg/controller/pxc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,13 @@ func (r *ReconcilePerconaXtraDBCluster) deploy(ctx context.Context, cr *api.Perc
if client.IgnoreNotFound(err) != nil {
return errors.Wrap(err, "get current pxc sts")
}
// Keep same volumeClaimTemplates labels if statefulset already exists.
// We can't update volumeClaimTemplates.
if err == nil && cr.CompareVersionWith("1.16.0") >= 0 {
for i, pvc := range currentNodeSet.Spec.VolumeClaimTemplates {
nodeSet.Spec.VolumeClaimTemplates[i].Labels = pvc.Labels
}
}
// TODO: code duplication with updatePod function
if nodeSet.Spec.Template.Annotations == nil {
nodeSet.Spec.Template.Annotations = make(map[string]string)
Expand Down Expand Up @@ -698,10 +705,17 @@ func (r *ReconcilePerconaXtraDBCluster) deploy(ctx context.Context, cr *api.Perc
return errors.Wrap(err, "get HAProxy stateful set")
}
if err == nil {
err := r.reconcilePDB(ctx, cr, cr.Spec.HAProxy.PodDisruptionBudget, sfsHAProxy, haProxySet)
err := r.reconcilePDB(ctx, cr, cr.Spec.HAProxy.PodDisruptionBudget, sfsHAProxy, currentHAProxySts)
if err != nil {
return errors.Wrapf(err, "PodDisruptionBudget for %s", haProxySet.Name)
}
// Keep same volumeClaimTemplates labels if statefulset already exists.
// We can't update volumeClaimTemplates.
if cr.CompareVersionWith("1.16.0") >= 0 {
for i, pvc := range currentHAProxySts.Spec.VolumeClaimTemplates {
haProxySet.Spec.VolumeClaimTemplates[i].Labels = pvc.Labels
}
}
}

err = r.client.Create(context.TODO(), haProxySet)
Expand All @@ -728,6 +742,13 @@ func (r *ReconcilePerconaXtraDBCluster) deploy(ctx context.Context, cr *api.Perc
if client.IgnoreNotFound(err) != nil {
return errors.Wrap(err, "get current proxy sts")
}
// Keep same volumeClaimTemplates labels if statefulset already exists.
// We can't update volumeClaimTemplates.
if err == nil && cr.CompareVersionWith("1.16.0") >= 0 {
for i, pvc := range currentProxySet.Spec.VolumeClaimTemplates {
proxySet.Spec.VolumeClaimTemplates[i].Labels = pvc.Labels
}
}

// TODO: code duplication with updatePod function
if proxySet.Spec.Template.Annotations == nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/pxc/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ func (r *ReconcilePerconaXtraDBCluster) updatePod(ctx context.Context, sfs api.S
if err != nil {
return errors.Wrap(err, "failed to get statefulset")
}
// Keep same volumeClaimTemplates labels if statefulset already exists.
// We can't update volumeClaimTemplates.
if err == nil && cr.CompareVersionWith("1.16.0") >= 0 {
for i, pvc := range currentSet.Spec.VolumeClaimTemplates {
sts.Spec.VolumeClaimTemplates[i].Labels = pvc.Labels
}
}

annotations := currentSet.Spec.Template.Annotations
labels := currentSet.Spec.Template.Labels
Expand Down

0 comments on commit e403fa4

Please sign in to comment.