Skip to content

Commit ec9fd3c

Browse files
committed
fix upgrade tests
1 parent 094ecaa commit ec9fd3c

9 files changed

Lines changed: 64 additions & 40 deletions

File tree

rust/operator-binary/src/config/command.rs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ fn broker_start_command(
8282
let client_port = kafka_security.client_port();
8383

8484
// TODO: copy to tmp? mount readwrite folder?
85+
// TODO: do "cat /tmp/{properties_file}" ?
8586
if kafka.is_controller_configured() {
8687
formatdoc! {"
8788
export REPLICA_ID=$(echo \"$POD_NAME\" | grep -oE '[0-9]+$')
@@ -92,7 +93,7 @@ fn broker_start_command(
9293
echo \"{KAFKA_LISTENERS}={listeners}\" >> /tmp/{properties_file}
9394
echo \"{KAFKA_ADVERTISED_LISTENERS}={advertised_listeners}\" >> /tmp/{properties_file}
9495
echo \"{KAFKA_LISTENER_SECURITY_PROTOCOL_MAP}={listener_security_protocol_map}\" >> /tmp/{properties_file}
95-
{controller_quorum_voters}
96+
echo \"{KAFKA_CONTROLLER_QUORUM_VOTERS}={controller_quorum_voters}\" >> /tmp/{properties_file}
9697
9798
bin/kafka-storage.sh format --cluster-id {cluster_id} --config /tmp/{properties_file} --ignore-formatted {initial_controller_command}
9899
bin/kafka-server-start.sh /tmp/{properties_file} {opa_config}{jaas_config} &
@@ -103,11 +104,7 @@ fn broker_start_command(
103104
listeners = kafka_listeners.listeners(),
104105
advertised_listeners = kafka_listeners.advertised_listeners(),
105106
listener_security_protocol_map = kafka_listeners.listener_security_protocol_map(),
106-
controller_quorum_voters = controller_quorum_voters_command(
107-
product_version,
108-
BROKER_PROPERTIES_FILE,
109-
&to_quorum_voters(&controller_descriptors, client_port)
110-
),
107+
controller_quorum_voters = to_quorum_voters(&controller_descriptors, client_port),
111108
initial_controller_command = initial_controllers_command(&controller_descriptors, product_version, client_port),
112109
}
113110
} else {
@@ -152,8 +149,7 @@ pub fn controller_kafka_container_command(
152149
echo \"{KAFKA_CONTROLLER_QUORUM_BOOTSTRAP_SERVERS}={bootstrap_servers}\" >> /tmp/{properties_file}
153150
echo \"{KAFKA_LISTENERS}={listeners}\" >> /tmp/{properties_file}
154151
echo \"{KAFKA_LISTENER_SECURITY_PROTOCOL_MAP}={listener_security_protocol_map}\" >> /tmp/{properties_file}
155-
{controller_quorum_voters}
156-
cat /tmp/{properties_file}
152+
echo \"{KAFKA_CONTROLLER_QUORUM_VOTERS}={controller_quorum_voters}\" >> /tmp/{properties_file}
157153
158154
bin/kafka-storage.sh format --cluster-id {cluster_id} --config /tmp/{properties_file} --ignore-formatted {initial_controller_command}
159155
bin/kafka-server-start.sh /tmp/{properties_file} &
@@ -168,11 +164,7 @@ pub fn controller_kafka_container_command(
168164
listeners = to_listeners(client_port),
169165
listener_security_protocol_map = to_listener_security_protocol_map(kafka_listeners),
170166
initial_controller_command = initial_controllers_command(&controller_descriptors, product_version, client_port),
171-
controller_quorum_voters = controller_quorum_voters_command(
172-
product_version,
173-
CONTROLLER_PROPERTIES_FILE,
174-
&to_quorum_voters(&controller_descriptors, client_port)
175-
),
167+
controller_quorum_voters = to_quorum_voters(&controller_descriptors, client_port),
176168
create_vector_shutdown_file_command = create_vector_shutdown_file_command(STACKABLE_LOG_DIR)
177169
}
178170
}
@@ -232,16 +224,3 @@ fn initial_controllers_command(
232224
),
233225
}
234226
}
235-
236-
fn controller_quorum_voters_command(
237-
product_version: &str,
238-
properties_file: &str,
239-
quorum_voters: &str,
240-
) -> String {
241-
match product_version.starts_with("3.7") {
242-
true => format!(
243-
"echo \"{KAFKA_CONTROLLER_QUORUM_VOTERS}={quorum_voters}\" >> /tmp/{properties_file}"
244-
),
245-
false => "".to_string(),
246-
}
247-
}

rust/operator-binary/src/resource/statefulset.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use stackable_operator::{
2020
k8s_openapi::{
2121
DeepMerge,
2222
api::{
23-
apps::v1::{StatefulSet, StatefulSetSpec},
23+
apps::v1::{StatefulSet, StatefulSetSpec, StatefulSetUpdateStrategy},
2424
core::v1::{
2525
ConfigMapKeySelector, ConfigMapVolumeSource, ContainerPort, EnvVar, EnvVarSource,
2626
ExecAction, ObjectFieldSelector, PodSpec, Probe, ServiceAccount, TCPSocketAction,
@@ -839,6 +839,10 @@ pub fn build_controller_rolegroup_statefulset(
839839
.build(),
840840
spec: Some(StatefulSetSpec {
841841
pod_management_policy: Some("Parallel".to_string()),
842+
update_strategy: Some(StatefulSetUpdateStrategy {
843+
type_: Some("RollingUpdate".to_string()),
844+
..StatefulSetUpdateStrategy::default()
845+
}),
842846
replicas: kafka_role
843847
.replicas(kafka, &rolegroup_ref.role_group)
844848
.context(RoleGroupReplicasSnafu)?

tests/templates/kuttl/upgrade/01-assert.yaml renamed to tests/templates/kuttl/upgrade/01-assert.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% if test_scenario['values']['use-kraft-controller'] == 'false' %}
12
---
23
apiVersion: kuttl.dev/v1beta1
34
kind: TestAssert
@@ -10,3 +11,4 @@ metadata:
1011
status:
1112
readyReplicas: 1
1213
replicas: 1
14+
{% endif %}

tests/templates/kuttl/upgrade/01-install-zk.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% if test_scenario['values']['use-kraft-controller'] == 'false' %}
12
---
23
apiVersion: zookeeper.stackable.tech/v1alpha1
34
kind: ZookeeperCluster
@@ -18,3 +19,4 @@ spec:
1819
roleGroups:
1920
default:
2021
replicas: 1
22+
{% endif %}

tests/templates/kuttl/upgrade/02-assert.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
timeout: 300
5+
---
6+
apiVersion: apps/v1
7+
kind: StatefulSet
8+
metadata:
9+
name: test-kafka-broker-default
10+
status:
11+
readyReplicas: 1
12+
replicas: 1
13+
{% if test_scenario['values']['use-kraft-controller'] == 'true' %}
14+
---
15+
apiVersion: apps/v1
16+
kind: StatefulSet
17+
metadata:
18+
name: test-kafka-controller-default
19+
status:
20+
readyReplicas: 3
21+
replicas: 3
22+
{% endif %}

tests/templates/kuttl/upgrade/02-install-kafka.yaml.j2

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,21 @@ spec:
5353
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
5454
vectorAggregatorConfigMapName: vector-aggregator-discovery
5555
{% endif %}
56-
zookeeperConfigMapName: test-kafka-znode
56+
{% if test_scenario['values']['use-kraft-controller'] == 'false' %}
57+
zookeeperConfigMapName: test-zk
58+
{% else %}
59+
controllers:
60+
config:
61+
gracefulShutdownTimeout: 30s # speed up tests
62+
logging:
63+
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
64+
roleGroups:
65+
default:
66+
replicas: 3
67+
{% endif %}
5768
brokers:
5869
config:
70+
gracefulShutdownTimeout: 30s # speed up tests
5971
logging:
6072
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
6173
roleGroups:

tests/templates/kuttl/upgrade/04-assert.yaml.j2

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@ status:
1414
replicas: 1
1515
currentReplicas: 1
1616
updatedReplicas: 1
17+
{% if test_scenario['values']['use-kraft-controller'] == 'true' %}
18+
---
19+
apiVersion: apps/v1
20+
kind: StatefulSet
21+
metadata:
22+
name: test-kafka-controller-default
23+
labels:
24+
app.kubernetes.io/version: "{{ test_scenario['values']['upgrade_new'] }}-stackable0.0.0-dev"
25+
status:
26+
readyReplicas: 3
27+
replicas: 3
28+
currentReplicas: 3
29+
updatedReplicas: 3
30+
{% endif %}

tests/test-definition.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ tests:
8585
- upgrade_old
8686
- use-client-tls
8787
- use-client-auth-tls
88+
- use-kraft-controller
8889
- openshift
8990
- name: tls
9091
dimensions:

0 commit comments

Comments
 (0)