Skip to content

Commit ab440ae

Browse files
authored
Fix conversion routines (#1088)
* Fix conversion routines * update pool golden files
1 parent 0ccf73a commit ab440ae

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

operator/api/redpanda/v1alpha2/conversion/helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func convertInitContainer(state *redpanda.RenderState, values *redpanda.Values,
108108
}
109109

110110
container := containerOrInit(&values.Statefulset.PodTemplate.Spec.InitContainers, name)
111+
if container.Resources == nil {
112+
container.Resources = &applycorev1.ResourceRequirementsApplyConfiguration{}
113+
}
111114
if err := convertJSONNotNil(spec.GetResources(), container.Resources); err != nil {
112115
return err
113116
}

operator/api/redpanda/v1alpha2/conversion/to_render.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ func convertStatefulsetV2Fields(state *redpanda.RenderState, values *redpanda.Va
182182
values.Statefulset.PodTemplate.Spec.TerminationGracePeriodSeconds = ptr.To(int64(*spec.TerminationGracePeriodSeconds))
183183
}
184184

185+
if redpandaContainer.LivenessProbe == nil {
186+
redpandaContainer.LivenessProbe = &applycorev1.ProbeApplyConfiguration{}
187+
}
188+
if redpandaContainer.StartupProbe == nil {
189+
redpandaContainer.StartupProbe = &applycorev1.ProbeApplyConfiguration{}
190+
}
191+
if sidecarContainer.ReadinessProbe == nil {
192+
sidecarContainer.ReadinessProbe = &applycorev1.ProbeApplyConfiguration{}
193+
}
194+
185195
if err := convertJSONNotNil(spec.LivenessProbe, redpandaContainer.LivenessProbe); err != nil {
186196
return err
187197
}
@@ -191,12 +201,14 @@ func convertStatefulsetV2Fields(state *redpanda.RenderState, values *redpanda.Va
191201
if err := convertJSONNotNil(spec.ReadinessProbe, sidecarContainer.ReadinessProbe); err != nil {
192202
return err
193203
}
204+
194205
if err := convertAndAppendJSONNotNil(spec.Tolerations, &values.Statefulset.PodTemplate.Spec.Tolerations); err != nil {
195206
return err
196207
}
197208
if err := convertAndAppendJSONNotNil(spec.TopologySpreadConstraints, &values.Statefulset.PodTemplate.Spec.TopologySpreadConstraints); err != nil {
198209
return err
199210
}
211+
200212
if values.Statefulset.PodTemplate.Spec.Affinity == nil {
201213
values.Statefulset.PodTemplate.Spec.Affinity = &applycorev1.AffinityApplyConfiguration{}
202214
}
@@ -277,6 +289,14 @@ func convertStatefulsetSidecarV2Fields(state *redpanda.RenderState, values *redp
277289
if err := convertAndAppendYAMLNotNil(state, spec.ExtraVolumeMounts, &sidecarContainer.VolumeMounts); err != nil {
278290
return err
279291
}
292+
293+
if sidecarContainer.Resources == nil {
294+
sidecarContainer.Resources = &applycorev1.ResourceRequirementsApplyConfiguration{}
295+
}
296+
if sidecarContainer.SecurityContext == nil {
297+
sidecarContainer.SecurityContext = &applycorev1.SecurityContextApplyConfiguration{}
298+
}
299+
280300
if err := convertJSONNotNil(spec.Resources, sidecarContainer.Resources); err != nil {
281301
return err
282302
}

operator/internal/lifecycle/testdata/cases.pools.golden.txtar

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
periodSeconds: 10
189189
successThreshold: 1
190190
resources: {}
191+
securityContext: {}
191192
volumeMounts:
192193
- mountPath: /etc/tls/certs/default
193194
name: redpanda-default-cert
@@ -547,7 +548,11 @@
547548
initialDelaySeconds: 1
548549
periodSeconds: 10
549550
successThreshold: 1
550-
resources: {}
551+
resources:
552+
requests:
553+
cpu: 16m
554+
memory: 256Mi
555+
securityContext: {}
551556
volumeMounts:
552557
- mountPath: /etc/tls/certs/default
553558
name: redpanda-default-cert
@@ -1373,6 +1378,7 @@
13731378
periodSeconds: 10
13741379
successThreshold: 1
13751380
resources: {}
1381+
securityContext: {}
13761382
volumeMounts:
13771383
- mountPath: /etc/tls/certs/default
13781384
name: redpanda-default-cert

operator/internal/lifecycle/testdata/cases.txtar

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ spec:
1919
clusterSpec:
2020
statefulset:
2121
replicas: 0
22+
sideCars:
23+
resources:
24+
requests:
25+
cpu: 16m
26+
memory: 256Mi
2227
---
2328
apiVersion: cluster.redpanda.com/v1alpha2
2429
kind: NodePool

operator/internal/lifecycle/testdata/cases.values.golden.txtar

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ values:
320320
containers:
321321
- name: redpanda
322322
- name: sidecar
323+
readinessProbe: {}
324+
resources: {}
325+
securityContext: {}
323326
initContainers:
324327
- name: redpanda-configurator
328+
resources: {}
325329
priorityClassName: ""
326330
securityContext: {}
327331
terminationGracePeriodSeconds: 90
@@ -908,8 +912,15 @@ values:
908912
containers:
909913
- name: redpanda
910914
- name: sidecar
915+
readinessProbe: {}
916+
resources:
917+
requests:
918+
cpu: 16m
919+
memory: 256Mi
920+
securityContext: {}
911921
initContainers:
912922
- name: redpanda-configurator
923+
resources: {}
913924
priorityClassName: ""
914925
securityContext: {}
915926
terminationGracePeriodSeconds: 90
@@ -1411,8 +1422,12 @@ values:
14111422
containers:
14121423
- name: redpanda
14131424
- name: sidecar
1425+
readinessProbe: {}
1426+
resources: {}
1427+
securityContext: {}
14141428
initContainers:
14151429
- name: redpanda-configurator
1430+
resources: {}
14161431
priorityClassName: ""
14171432
securityContext: {}
14181433
terminationGracePeriodSeconds: 90

0 commit comments

Comments
 (0)