Skip to content

Commit 707589f

Browse files
committed
kuttl test for "ClusterConfiguration" override
Ensure the configuration is correctly stashed and updated. kuttl test for "ClusterConfiguration" external ref override Note: because this test causes an additional env var to be added to an initContainer, it'll cause a restart of the resulting statefulSet.
1 parent 78fdb66 commit 707589f

File tree

15 files changed

+308
-3
lines changed

15 files changed

+308
-3
lines changed

operator/pkg/clusterconfiguration/expander.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,15 @@ func ParseRepresentation(repr string, metadata *rpadmin.ConfigPropertyMetadata)
163163
switch metadata.Type {
164164
case "string":
165165
var s string
166+
// YAML unmarshalling to "be liberal in what we accept" here.
166167
err := yaml.Unmarshal([]byte(repr), &s)
167168
return s, err
168169
case "number":
169-
return strconv.ParseFloat(repr, 64)
170+
return strconv.ParseFloat(strings.Trim(repr, "\n"), 64)
170171
case "integer":
171-
return strconv.ParseInt(repr, 10, 64)
172+
return strconv.ParseInt(strings.Trim(repr, "\n"), 10, 64)
172173
case "boolean":
173-
return strconv.ParseBool(repr)
174+
return strconv.ParseBool(strings.Trim(repr, "\n"))
174175
case "array":
175176
return convertStringToStringArray(repr)
176177
default:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: centralized-configuration-injected-ref
5+
status:
6+
replicas: 2
7+
restarting: false
8+
---
9+
apiVersion: kuttl.dev/v1beta1
10+
kind: TestAssert
11+
commands:
12+
- timeout: 300
13+
script: |
14+
kubectl wait --for=condition=ClusterConfigured=True cluster/centralized-configuration-injected-ref --timeout 300s --namespace $NAMESPACE
15+
---
16+
apiVersion: kuttl.dev/v1beta1
17+
kind: TestAssert
18+
collectors:
19+
- command: ../../../hack/get-redpanda-info.sh
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: centralized-configuration-injected-ref
5+
spec:
6+
image: "localhost/redpanda"
7+
version: "dev"
8+
replicas: 2
9+
resources:
10+
requests:
11+
cpu: "100m"
12+
memory: 256Mi
13+
limits:
14+
cpu: "100m"
15+
memory: 256Mi
16+
configuration:
17+
rpcServer:
18+
port: 33145
19+
kafkaApi:
20+
- port: 9092
21+
adminApi:
22+
- port: 9644
23+
pandaproxyApi:
24+
- port: 8082
25+
developerMode: true
26+
additionalCommandlineArguments:
27+
dump-memory-diagnostics-on-alloc-failure-kind: all
28+
abort-on-seastar-bad-alloc: ''
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: centralized-configuration-injected-ref
5+
status:
6+
replicas: 2
7+
restarting: false
8+
---
9+
apiVersion: kuttl.dev/v1beta1
10+
kind: TestAssert
11+
commands:
12+
- timeout: 300
13+
script: |
14+
kubectl wait --for=condition=ClusterConfigured=True cluster/centralized-configuration-injected-ref --timeout 300s --namespace $NAMESPACE
15+
---
16+
apiVersion: kuttl.dev/v1beta1
17+
kind: TestAssert
18+
collectors:
19+
- command: ../../../hack/get-redpanda-info.sh
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: injected-value
5+
data:
6+
value-1: |
7+
1004
8+
---
9+
apiVersion: redpanda.vectorized.io/v1alpha1
10+
kind: Cluster
11+
metadata:
12+
name: centralized-configuration-injected-ref
13+
spec:
14+
image: "localhost/redpanda"
15+
version: "dev"
16+
replicas: 2
17+
resources:
18+
requests:
19+
cpu: "100m"
20+
memory: 256Mi
21+
limits:
22+
cpu: "100m"
23+
memory: 256Mi
24+
configuration:
25+
rpcServer:
26+
port: 33145
27+
kafkaApi:
28+
- port: 9092
29+
adminApi:
30+
- port: 9644
31+
pandaproxyApi:
32+
- port: 8082
33+
developerMode: true
34+
additionalCommandlineArguments:
35+
dump-memory-diagnostics-on-alloc-failure-kind: all
36+
abort-on-seastar-bad-alloc: ''
37+
clusterConfiguration:
38+
segment_appender_flush_timeout_ms:
39+
configMapKeyRef:
40+
name: injected-value
41+
key: value-1
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
job-name: get-centralized-config-1-injected-ref
6+
status:
7+
containerStatuses:
8+
- name: curl
9+
state:
10+
terminated:
11+
message: |
12+
1004
13+
phase: Succeeded
14+
---
15+
apiVersion: kuttl.dev/v1beta1
16+
kind: TestAssert
17+
collectors:
18+
- command: ../../../hack/get-redpanda-info.sh
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: get-centralized-config-1-injected-ref
5+
spec:
6+
backoffLimit: 10
7+
template:
8+
spec:
9+
activeDeadlineSeconds: 90
10+
containers:
11+
- name: curl
12+
image: curlimages/curl:latest
13+
env:
14+
- name: NAMESPACE
15+
valueFrom:
16+
fieldRef:
17+
fieldPath: metadata.namespace
18+
command:
19+
- /bin/sh
20+
- -c
21+
- -ex
22+
args:
23+
- >
24+
url=http://centralized-configuration-injected-ref-0.centralized-configuration-injected-ref.$NAMESPACE.svc.cluster.local:9644/v1/config
25+
res=$(curl --silent -L $url | grep -o '\"segment_appender_flush_timeout_ms\":[^,}]*'
26+
| grep -o '[^:]*$') && echo $res > /dev/termination-log && if [[ "$res"
27+
!= "1004" ]]; then
28+
exit 1;
29+
fi
30+
restartPolicy: Never
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestAssert
3+
collectors:
4+
- command: ../../../hack/get-redpanda-info.sh
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
delete:
4+
- apiVersion: redpanda.vectorized.io/v1alpha1
5+
kind: Cluster
6+
name: centralized-configuration-injected-ref
7+
namespace: redpanda-system
8+
- apiVersion: v1
9+
kind: ConfigMap
10+
name: injected-value
11+
namespace: redpanda-system
12+
- apiVersion: v1
13+
kind: PersistentVolumeClaim
14+
name: datadir-centralized-configuration-0
15+
namespace: redpanda-system
16+
- apiVersion: v1
17+
kind: PersistentVolumeClaim
18+
name: datadir-centralized-configuration-1
19+
namespace: redpanda-system
20+
- apiVersion: batch/v1
21+
kind: Job
22+
name: get-centralized-config-1
23+
namespace: redpanda-system
24+
- apiVersion: v1
25+
kind: Pod
26+
labels:
27+
job-name: get-centralized-config-1
28+
namespace: redpanda-system
29+
- apiVersion: batch/v1
30+
kind: Job
31+
name: get-centralized-config-2
32+
namespace: redpanda-system
33+
- apiVersion: v1
34+
kind: Pod
35+
labels:
36+
job-name: get-centralized-config-2
37+
namespace: redpanda-system

operator/tests/e2e/centralized-configuration/05-assert.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: centralized-configuration
5+
status:
6+
restarting: false
7+
---
18
apiVersion: kuttl.dev/v1beta1
29
kind: TestAssert
310
collectors:

0 commit comments

Comments
 (0)