Skip to content

Commit 257028d

Browse files
committed
add version checks
1 parent 10c82f3 commit 257028d

File tree

13 files changed

+118
-26
lines changed

13 files changed

+118
-26
lines changed

api/v1alpha1/perconaservermysql_types.go

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ type PerconaServerMySQLSpec struct {
6363
SecretsName string `json:"secretsName,omitempty"`
6464
SSLSecretName string `json:"sslSecretName,omitempty"`
6565
Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
66-
InitContainer InitContainerSpec `json:"initContainer,omitempty"`
6766
IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"`
6867
IgnoreLabels []string `json:"ignoreLabels,omitempty"`
6968
MySQL MySQLSpec `json:"mysql,omitempty"`
@@ -75,6 +74,10 @@ type PerconaServerMySQLSpec struct {
7574
Toolkit *ToolkitSpec `json:"toolkit,omitempty"`
7675
UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
7776
UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"`
77+
78+
// Deprecated: not supported since v0.12.0. Use initContainer instead
79+
InitImage string `json:"initImage,omitempty"`
80+
InitContainer InitContainerSpec `json:"initContainer,omitempty"`
7881
}
7982

8083
type InitContainerSpec struct {
@@ -180,11 +183,14 @@ type ContainerSpec struct {
180183

181184
type PodSpec struct {
182185
// +kubebuilder:validation:Required
183-
Size int32 `json:"size,omitempty"`
184-
Annotations map[string]string `json:"annotations,omitempty"`
185-
Labels map[string]string `json:"labels,omitempty"`
186-
VolumeSpec *VolumeSpec `json:"volumeSpec,omitempty"`
187-
InitContainer InitContainerSpec `json:"initContainer,omitempty"`
186+
Size int32 `json:"size,omitempty"`
187+
Annotations map[string]string `json:"annotations,omitempty"`
188+
Labels map[string]string `json:"labels,omitempty"`
189+
VolumeSpec *VolumeSpec `json:"volumeSpec,omitempty"`
190+
191+
// Deprecated: not supported since v0.12.0. Use initContainer instead
192+
InitImage string `json:"initImage,omitempty"`
193+
InitContainer *InitContainerSpec `json:"initContainer,omitempty"`
188194

189195
Affinity *PodAffinity `json:"affinity,omitempty"`
190196
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
@@ -213,8 +219,16 @@ func (s PodSpec) GetTerminationGracePeriodSeconds() *int64 {
213219
return &gp
214220
}
215221

216-
func (s *PodSpec) GetInitSpec() InitContainerSpec {
217-
return s.InitContainer
222+
func (s *PodSpec) GetInitSpec(cr *PerconaServerMySQL) InitContainerSpec {
223+
if s.InitContainer == nil {
224+
if cr.CompareVersion("0.12.0") < 0 {
225+
return InitContainerSpec{
226+
Image: s.InitImage,
227+
}
228+
}
229+
return InitContainerSpec{}
230+
}
231+
return *s.InitContainer
218232
}
219233

220234
type PMMSpec struct {
@@ -230,7 +244,6 @@ type PMMSpec struct {
230244
type BackupSpec struct {
231245
Enabled bool `json:"enabled,omitempty"`
232246
Image string `json:"image"`
233-
InitContainer InitContainerSpec `json:"initContainer,omitempty"`
234247
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
235248
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
236249
ServiceAccountName string `json:"serviceAccountName,omitempty"`
@@ -240,6 +253,10 @@ type BackupSpec struct {
240253
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
241254
PiTR PiTRSpec `json:"pitr,omitempty"`
242255
Schedule []BackupSchedule `json:"schedule,omitempty"`
256+
257+
// Deprecated: not supported since v0.12.0. Use initContainer instead
258+
InitImage string `json:"initImage,omitempty"`
259+
InitContainer *InitContainerSpec `json:"initContainer,omitempty"`
243260
}
244261

245262
type BackupSchedule struct {
@@ -252,8 +269,16 @@ type BackupSchedule struct {
252269
StorageName string `json:"storageName,omitempty"`
253270
}
254271

255-
func (s *BackupSpec) GetInitSpec() InitContainerSpec {
256-
return s.InitContainer
272+
func (s *BackupSpec) GetInitSpec(cr *PerconaServerMySQL) InitContainerSpec {
273+
if s.InitContainer == nil {
274+
if cr.CompareVersion("0.12.0") < 0 {
275+
return InitContainerSpec{
276+
Image: s.InitImage,
277+
}
278+
}
279+
return InitContainerSpec{}
280+
}
281+
return *s.InitContainer
257282
}
258283

259284
type BackupStorageType string

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ spec:
255255
type: object
256256
type: object
257257
type: object
258+
initImage:
259+
type: string
258260
pitr:
259261
properties:
260262
binlogServer:
@@ -1004,6 +1006,8 @@ spec:
10041006
type: object
10051007
type: object
10061008
type: object
1009+
initImage:
1010+
type: string
10071011
labels:
10081012
additionalProperties:
10091013
type: string
@@ -2662,6 +2666,8 @@ spec:
26622666
type: object
26632667
type: object
26642668
type: object
2669+
initImage:
2670+
type: string
26652671
mysql:
26662672
properties:
26672673
affinity:
@@ -3453,6 +3459,8 @@ spec:
34533459
type: object
34543460
type: object
34553461
type: object
3462+
initImage:
3463+
type: string
34563464
labels:
34573465
additionalProperties:
34583466
type: string
@@ -6339,6 +6347,8 @@ spec:
63396347
type: object
63406348
type: object
63416349
type: object
6350+
initImage:
6351+
type: string
63426352
labels:
63436353
additionalProperties:
63446354
type: string
@@ -7786,6 +7796,8 @@ spec:
77867796
type: object
77877797
type: object
77887798
type: object
7799+
initImage:
7800+
type: string
77897801
labels:
77907802
additionalProperties:
77917803
type: string
@@ -9109,6 +9121,8 @@ spec:
91099121
type: object
91109122
type: object
91119123
type: object
9124+
initImage:
9125+
type: string
91129126
labels:
91139127
additionalProperties:
91149128
type: string

deploy/bundle.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,8 @@ spec:
21782178
type: object
21792179
type: object
21802180
type: object
2181+
initImage:
2182+
type: string
21812183
pitr:
21822184
properties:
21832185
binlogServer:
@@ -2927,6 +2929,8 @@ spec:
29272929
type: object
29282930
type: object
29292931
type: object
2932+
initImage:
2933+
type: string
29302934
labels:
29312935
additionalProperties:
29322936
type: string
@@ -4585,6 +4589,8 @@ spec:
45854589
type: object
45864590
type: object
45874591
type: object
4592+
initImage:
4593+
type: string
45884594
mysql:
45894595
properties:
45904596
affinity:
@@ -5376,6 +5382,8 @@ spec:
53765382
type: object
53775383
type: object
53785384
type: object
5385+
initImage:
5386+
type: string
53795387
labels:
53805388
additionalProperties:
53815389
type: string
@@ -8262,6 +8270,8 @@ spec:
82628270
type: object
82638271
type: object
82648272
type: object
8273+
initImage:
8274+
type: string
82658275
labels:
82668276
additionalProperties:
82678277
type: string
@@ -9709,6 +9719,8 @@ spec:
97099719
type: object
97109720
type: object
97119721
type: object
9722+
initImage:
9723+
type: string
97129724
labels:
97139725
additionalProperties:
97149726
type: string
@@ -11032,6 +11044,8 @@ spec:
1103211044
type: object
1103311045
type: object
1103411046
type: object
11047+
initImage:
11048+
type: string
1103511049
labels:
1103611050
additionalProperties:
1103711051
type: string

deploy/crd.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,8 @@ spec:
21782178
type: object
21792179
type: object
21802180
type: object
2181+
initImage:
2182+
type: string
21812183
pitr:
21822184
properties:
21832185
binlogServer:
@@ -2927,6 +2929,8 @@ spec:
29272929
type: object
29282930
type: object
29292931
type: object
2932+
initImage:
2933+
type: string
29302934
labels:
29312935
additionalProperties:
29322936
type: string
@@ -4585,6 +4589,8 @@ spec:
45854589
type: object
45864590
type: object
45874591
type: object
4592+
initImage:
4593+
type: string
45884594
mysql:
45894595
properties:
45904596
affinity:
@@ -5376,6 +5382,8 @@ spec:
53765382
type: object
53775383
type: object
53785384
type: object
5385+
initImage:
5386+
type: string
53795387
labels:
53805388
additionalProperties:
53815389
type: string
@@ -8262,6 +8270,8 @@ spec:
82628270
type: object
82638271
type: object
82648272
type: object
8273+
initImage:
8274+
type: string
82658275
labels:
82668276
additionalProperties:
82678277
type: string
@@ -9709,6 +9719,8 @@ spec:
97099719
type: object
97109720
type: object
97119721
type: object
9722+
initImage:
9723+
type: string
97129724
labels:
97139725
additionalProperties:
97149726
type: string
@@ -11032,6 +11044,8 @@ spec:
1103211044
type: object
1103311045
type: object
1103411046
type: object
11047+
initImage:
11048+
type: string
1103511049
labels:
1103611050
additionalProperties:
1103711051
type: string

deploy/cw-bundle.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,8 @@ spec:
21782178
type: object
21792179
type: object
21802180
type: object
2181+
initImage:
2182+
type: string
21812183
pitr:
21822184
properties:
21832185
binlogServer:
@@ -2927,6 +2929,8 @@ spec:
29272929
type: object
29282930
type: object
29292931
type: object
2932+
initImage:
2933+
type: string
29302934
labels:
29312935
additionalProperties:
29322936
type: string
@@ -4585,6 +4589,8 @@ spec:
45854589
type: object
45864590
type: object
45874591
type: object
4592+
initImage:
4593+
type: string
45884594
mysql:
45894595
properties:
45904596
affinity:
@@ -5376,6 +5382,8 @@ spec:
53765382
type: object
53775383
type: object
53785384
type: object
5385+
initImage:
5386+
type: string
53795387
labels:
53805388
additionalProperties:
53815389
type: string
@@ -8262,6 +8270,8 @@ spec:
82628270
type: object
82638271
type: object
82648272
type: object
8273+
initImage:
8274+
type: string
82658275
labels:
82668276
additionalProperties:
82678277
type: string
@@ -9709,6 +9719,8 @@ spec:
97099719
type: object
97109720
type: object
97119721
type: object
9722+
initImage:
9723+
type: string
97129724
labels:
97139725
additionalProperties:
97149726
type: string
@@ -11032,6 +11044,8 @@ spec:
1103211044
type: object
1103311045
type: object
1103411046
type: object
11047+
initImage:
11048+
type: string
1103511049
labels:
1103611050
additionalProperties:
1103711051
type: string

0 commit comments

Comments
 (0)