Skip to content

Commit 7b1bad5

Browse files
egegunesgkechpooknullhors
authored
K8SPS-126: Support volume expansion (#937)
* K8SPS-126: Support volume expansion * add pvc-resize e2e test * fix pvc-resize test * K8SPS-126 Introduce controller test for pvc resize * fix formatting * fix duplicate annotation functions and usage * fix lint * remove pxc references --------- Co-authored-by: George Kechagias <george.kechagias@percona.com> Co-authored-by: Andrii Dema <a.dema@jazzserve.com> Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent a7b947d commit 7b1bad5

37 files changed

+1168
-133
lines changed

api/v1alpha1/perconaservermysql_types.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,24 @@ const (
5757
// +kubebuilder:validation:XValidation:rule="!(self.mysql.clusterType == 'group-replication' && has(self.mysql.size) && self.mysql.size >= 9) || self.unsafeFlags.mysqlSize",message="Invalid configuration: For 'group replication', scaling MySQL replicas above 9 requires 'unsafeFlags.mysqlSize: true'"
5858
// +kubebuilder:validation:XValidation:rule="!(self.mysql.clusterType == 'group-replication' && has(self.mysql.size) && self.mysql.size % 2 == 0) || self.unsafeFlags.mysqlSize",message="Invalid configuration: For 'group replication', using an even number of MySQL replicas requires 'unsafeFlags.mysqlSize: true'"
5959
type PerconaServerMySQLSpec struct {
60-
CRVersion string `json:"crVersion,omitempty"`
61-
Pause bool `json:"pause,omitempty"`
62-
SecretsName string `json:"secretsName,omitempty"`
63-
SSLSecretName string `json:"sslSecretName,omitempty"`
64-
Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
65-
InitImage string `json:"initImage,omitempty"`
66-
IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"`
67-
IgnoreLabels []string `json:"ignoreLabels,omitempty"`
68-
MySQL MySQLSpec `json:"mysql,omitempty"`
69-
Orchestrator OrchestratorSpec `json:"orchestrator,omitempty"`
70-
PMM *PMMSpec `json:"pmm,omitempty"`
71-
Backup *BackupSpec `json:"backup,omitempty"`
72-
Proxy ProxySpec `json:"proxy,omitempty"`
73-
TLS *TLSSpec `json:"tls,omitempty"`
74-
Toolkit *ToolkitSpec `json:"toolkit,omitempty"`
75-
UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
76-
UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"`
60+
CRVersion string `json:"crVersion,omitempty"`
61+
Pause bool `json:"pause,omitempty"`
62+
VolumeExpansionEnabled bool `json:"enableVolumeExpansion,omitempty"`
63+
SecretsName string `json:"secretsName,omitempty"`
64+
SSLSecretName string `json:"sslSecretName,omitempty"`
65+
Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
66+
InitImage string `json:"initImage,omitempty"`
67+
IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"`
68+
IgnoreLabels []string `json:"ignoreLabels,omitempty"`
69+
MySQL MySQLSpec `json:"mysql,omitempty"`
70+
Orchestrator OrchestratorSpec `json:"orchestrator,omitempty"`
71+
PMM *PMMSpec `json:"pmm,omitempty"`
72+
Backup *BackupSpec `json:"backup,omitempty"`
73+
Proxy ProxySpec `json:"proxy,omitempty"`
74+
TLS *TLSSpec `json:"tls,omitempty"`
75+
Toolkit *ToolkitSpec `json:"toolkit,omitempty"`
76+
UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
77+
UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"`
7778
}
7879

7980
type UnsafeFlags struct {
@@ -1114,6 +1115,11 @@ func (cr *PerconaServerMySQL) InnoDBClusterName() string {
11141115
return NonAlphaNumeric.ReplaceAllString(cr.Name, "")
11151116
}
11161117

1118+
func (cr *PerconaServerMySQL) PVCResizeInProgress() bool {
1119+
_, ok := cr.Annotations[string(naming.AnnotationPVCResizeInProgress)]
1120+
return ok
1121+
}
1122+
11171123
// Registers PerconaServerMySQL types with the SchemeBuilder.
11181124
func init() {
11191125
SchemeBuilder.Register(&PerconaServerMySQL{}, &PerconaServerMySQLList{})

cmd/manager/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"context"
2021
"flag"
2122
"os"
2223
"strconv"
@@ -26,12 +27,14 @@ import (
2627
"github.com/go-logr/logr"
2728
uzap "go.uber.org/zap"
2829
"go.uber.org/zap/zapcore"
30+
eventsv1 "k8s.io/api/events/v1"
2931
"k8s.io/apimachinery/pkg/runtime"
3032
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3133
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3234
_ "k8s.io/client-go/plugin/pkg/client/auth"
3335
ctrl "sigs.k8s.io/controller-runtime"
3436
"sigs.k8s.io/controller-runtime/pkg/cache"
37+
"sigs.k8s.io/controller-runtime/pkg/client"
3538
"sigs.k8s.io/controller-runtime/pkg/healthz"
3639
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3740
metricsServer "sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -180,6 +183,20 @@ func main() {
180183
}
181184
//+kubebuilder:scaffold:builder
182185

186+
err = mgr.GetFieldIndexer().IndexField(
187+
context.Background(),
188+
&eventsv1.Event{},
189+
"regarding.name",
190+
func(rawObj client.Object) []string {
191+
event := rawObj.(*eventsv1.Event)
192+
return []string{event.Regarding.Name}
193+
},
194+
)
195+
if err != nil {
196+
setupLog.Error(err, "unable to index field")
197+
os.Exit(1)
198+
}
199+
183200
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
184201
setupLog.Error(err, "unable to set up health check")
185202
os.Exit(1)

config/crd/bases/ps.percona.com_perconaservermysqls.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,8 @@ spec:
23262326
type: object
23272327
crVersion:
23282328
type: string
2329+
enableVolumeExpansion:
2330+
type: boolean
23292331
ignoreAnnotations:
23302332
items:
23312333
type: string

config/rbac/cluster/role.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ rules:
2323
- ""
2424
resources:
2525
- events
26+
- serviceaccounts
2627
verbs:
2728
- create
29+
- get
30+
- list
2831
- patch
32+
- watch
2933
- apiGroups:
3034
- ""
3135
resources:
@@ -40,16 +44,6 @@ rules:
4044
- patch
4145
- update
4246
- watch
43-
- apiGroups:
44-
- ""
45-
resources:
46-
- serviceaccounts
47-
verbs:
48-
- create
49-
- get
50-
- list
51-
- patch
52-
- watch
5347
- apiGroups:
5448
- apps
5549
resources:
@@ -90,6 +84,16 @@ rules:
9084
- patch
9185
- update
9286
- watch
87+
- apiGroups:
88+
- events.k8s.io
89+
resources:
90+
- events
91+
verbs:
92+
- create
93+
- get
94+
- list
95+
- patch
96+
- watch
9397
- apiGroups:
9498
- ps.percona.com
9599
resources:

config/rbac/role.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ rules:
2323
- ""
2424
resources:
2525
- events
26+
- serviceaccounts
2627
verbs:
2728
- create
29+
- get
30+
- list
2831
- patch
32+
- watch
2933
- apiGroups:
3034
- ""
3135
resources:
@@ -40,16 +44,6 @@ rules:
4044
- patch
4145
- update
4246
- watch
43-
- apiGroups:
44-
- ""
45-
resources:
46-
- serviceaccounts
47-
verbs:
48-
- create
49-
- get
50-
- list
51-
- patch
52-
- watch
5347
- apiGroups:
5448
- apps
5549
resources:
@@ -90,6 +84,16 @@ rules:
9084
- patch
9185
- update
9286
- watch
87+
- apiGroups:
88+
- events.k8s.io
89+
resources:
90+
- events
91+
verbs:
92+
- create
93+
- get
94+
- list
95+
- patch
96+
- watch
9397
- apiGroups:
9498
- ps.percona.com
9599
resources:

deploy/bundle.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,6 +4249,8 @@ spec:
42494249
type: object
42504250
crVersion:
42514251
type: string
4252+
enableVolumeExpansion:
4253+
type: boolean
42524254
ignoreAnnotations:
42534255
items:
42544256
type: string
@@ -11520,9 +11522,13 @@ rules:
1152011522
- ""
1152111523
resources:
1152211524
- events
11525+
- serviceaccounts
1152311526
verbs:
1152411527
- create
11528+
- get
11529+
- list
1152511530
- patch
11531+
- watch
1152611532
- apiGroups:
1152711533
- ""
1152811534
resources:
@@ -11537,16 +11543,6 @@ rules:
1153711543
- patch
1153811544
- update
1153911545
- watch
11540-
- apiGroups:
11541-
- ""
11542-
resources:
11543-
- serviceaccounts
11544-
verbs:
11545-
- create
11546-
- get
11547-
- list
11548-
- patch
11549-
- watch
1155011546
- apiGroups:
1155111547
- apps
1155211548
resources:
@@ -11587,6 +11583,16 @@ rules:
1158711583
- patch
1158811584
- update
1158911585
- watch
11586+
- apiGroups:
11587+
- events.k8s.io
11588+
resources:
11589+
- events
11590+
verbs:
11591+
- create
11592+
- get
11593+
- list
11594+
- patch
11595+
- watch
1159011596
- apiGroups:
1159111597
- ps.percona.com
1159211598
resources:

deploy/crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,6 +4249,8 @@ spec:
42494249
type: object
42504250
crVersion:
42514251
type: string
4252+
enableVolumeExpansion:
4253+
type: boolean
42524254
ignoreAnnotations:
42534255
items:
42544256
type: string

deploy/cw-bundle.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,6 +4249,8 @@ spec:
42494249
type: object
42504250
crVersion:
42514251
type: string
4252+
enableVolumeExpansion:
4253+
type: boolean
42524254
ignoreAnnotations:
42534255
items:
42544256
type: string
@@ -11520,9 +11522,13 @@ rules:
1152011522
- ""
1152111523
resources:
1152211524
- events
11525+
- serviceaccounts
1152311526
verbs:
1152411527
- create
11528+
- get
11529+
- list
1152511530
- patch
11531+
- watch
1152611532
- apiGroups:
1152711533
- ""
1152811534
resources:
@@ -11537,16 +11543,6 @@ rules:
1153711543
- patch
1153811544
- update
1153911545
- watch
11540-
- apiGroups:
11541-
- ""
11542-
resources:
11543-
- serviceaccounts
11544-
verbs:
11545-
- create
11546-
- get
11547-
- list
11548-
- patch
11549-
- watch
1155011546
- apiGroups:
1155111547
- apps
1155211548
resources:
@@ -11587,6 +11583,16 @@ rules:
1158711583
- patch
1158811584
- update
1158911585
- watch
11586+
- apiGroups:
11587+
- events.k8s.io
11588+
resources:
11589+
- events
11590+
verbs:
11591+
- create
11592+
- get
11593+
- list
11594+
- patch
11595+
- watch
1159011596
- apiGroups:
1159111597
- ps.percona.com
1159211598
resources:

deploy/cw-rbac.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ rules:
6464
- ""
6565
resources:
6666
- events
67+
- serviceaccounts
6768
verbs:
6869
- create
70+
- get
71+
- list
6972
- patch
73+
- watch
7074
- apiGroups:
7175
- ""
7276
resources:
@@ -81,16 +85,6 @@ rules:
8185
- patch
8286
- update
8387
- watch
84-
- apiGroups:
85-
- ""
86-
resources:
87-
- serviceaccounts
88-
verbs:
89-
- create
90-
- get
91-
- list
92-
- patch
93-
- watch
9488
- apiGroups:
9589
- apps
9690
resources:
@@ -131,6 +125,16 @@ rules:
131125
- patch
132126
- update
133127
- watch
128+
- apiGroups:
129+
- events.k8s.io
130+
resources:
131+
- events
132+
verbs:
133+
- create
134+
- get
135+
- list
136+
- patch
137+
- watch
134138
- apiGroups:
135139
- ps.percona.com
136140
resources:

0 commit comments

Comments
 (0)