Skip to content

Commit ff69858

Browse files
committed
Fix znode bug (#592)
# Description When testing with Kafka, the ZooKeeper operator does no longer create respective ZNodes due to: ``` ERROR stackable_operator::logging::controller: Failed to reconcile object controller.name="znode.zookeeper.stackable.tech" error=reconciler for object ZookeeperZnode.v1alpha1.zookeeper.stackable.tech/simp le-znode.default failed error.sources=[failed to save discovery information to ConfigMap.v1./simple-znode.default, Label contains unexpected content. Expected: app.kubernetes.io/instance=simple-znode, actual: app.kubernetes.io/insta nce=simple-zk] ``` This was introduced in #591 Added testcase to check if a znode ConfigMap is created successfully. Test: https://ci.stackable.tech/view/02%20Operator%20Tests%20(custom)/job/zookeeper-operator-it-custom/21/ Co-authored-by: Malte Sander <[email protected]>
1 parent 1c43089 commit ff69858

File tree

7 files changed

+74
-15
lines changed

7 files changed

+74
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ All notable changes to this project will be documented in this file.
88

99
- Updated stackable image versions ([#586]).
1010
- Operator-rs: 0.25.3 -> 0.27.1 ([#591]).
11+
- Fixed bug where ZNode ConfigMaps were not created due to labeling issues ([#592]).
1112

1213
[#586]: https://github.com/stackabletech/zookeeper-operator/pull/586
1314
[#591]: https://github.com/stackabletech/zookeeper-operator/pull/591
15+
[#592]: https://github.com/stackabletech/zookeeper-operator/pull/592
1416

1517
## [0.12.0] - 2022-11-07
1618

rust/operator-binary/src/discovery.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::utils::build_recommended_labels;
2-
use crate::ZK_CONTROLLER_NAME;
32

43
use snafu::{OptionExt, ResultExt, Snafu};
54
use stackable_operator::{
@@ -53,16 +52,18 @@ pub async fn build_discovery_configmaps(
5352
zk: &ZookeeperCluster,
5453
owner: &impl Resource<DynamicType = ()>,
5554
client: &stackable_operator::client::Client,
55+
controller_name: &str,
5656
svc: &Service,
5757
chroot: Option<&str>,
5858
) -> Result<Vec<ConfigMap>, Error> {
5959
let name = owner.meta().name.as_deref().context(NoNameSnafu)?;
6060
Ok(vec![
61-
build_discovery_configmap(name, owner, zk, chroot, pod_hosts(zk)?)?,
61+
build_discovery_configmap(zk, owner, name, controller_name, chroot, pod_hosts(zk)?)?,
6262
build_discovery_configmap(
63-
&format!("{}-nodeport", name),
64-
owner,
6563
zk,
64+
owner,
65+
&format!("{}-nodeport", name),
66+
controller_name,
6667
chroot,
6768
nodeport_hosts(client, svc, "zk").await?,
6869
)?,
@@ -73,9 +74,10 @@ pub async fn build_discovery_configmaps(
7374
///
7475
/// `hosts` will usually come from either [`pod_hosts`] or [`nodeport_hosts`].
7576
fn build_discovery_configmap(
76-
name: &str,
77-
owner: &impl Resource<DynamicType = ()>,
7877
zk: &ZookeeperCluster,
78+
owner: &impl Resource<DynamicType = ()>,
79+
name: &str,
80+
controller_name: &str,
7981
chroot: Option<&str>,
8082
hosts: impl IntoIterator<Item = (impl Into<String>, u16)>,
8183
) -> Result<ConfigMap, Error> {
@@ -104,8 +106,8 @@ fn build_discovery_configmap(
104106
zk: ObjectRef::from_obj(zk),
105107
})?
106108
.with_recommended_labels(build_recommended_labels(
107-
zk,
108-
ZK_CONTROLLER_NAME,
109+
owner,
110+
controller_name,
109111
zk.image_version().context(NoVersionSnafu)?,
110112
&ZookeeperRole::Server.to_string(),
111113
"discovery",

rust/operator-binary/src/zk_controller.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,16 @@ pub async fn reconcile_zk(zk: Arc<ZookeeperCluster>, ctx: Arc<Ctx>) -> Result<co
311311
// std's SipHasher is deprecated, and DefaultHasher is unstable across Rust releases.
312312
// We don't /need/ stability, but it's still nice to avoid spurious changes where possible.
313313
let mut discovery_hash = FnvHasher::with_key(0);
314-
for discovery_cm in build_discovery_configmaps(&zk, &*zk, client, &server_role_service, None)
315-
.await
316-
.context(BuildDiscoveryConfigSnafu)?
314+
for discovery_cm in build_discovery_configmaps(
315+
&zk,
316+
&*zk,
317+
client,
318+
ZK_CONTROLLER_NAME,
319+
&server_role_service,
320+
None,
321+
)
322+
.await
323+
.context(BuildDiscoveryConfigSnafu)?
317324
{
318325
let discovery_cm = cluster_resources
319326
.add(client, &discovery_cm)

rust/operator-binary/src/znode_controller.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,16 @@ async fn reconcile_apply(
214214
.context(FindZkSvcSnafu {
215215
zk: ObjectRef::from_obj(&zk),
216216
})?;
217-
for discovery_cm in
218-
build_discovery_configmaps(&zk, znode, client, &server_role_service, Some(znode_path))
219-
.await
220-
.context(BuildDiscoveryConfigMapSnafu)?
217+
for discovery_cm in build_discovery_configmaps(
218+
&zk,
219+
znode,
220+
client,
221+
ZNODE_CONTROLLER_NAME,
222+
&server_role_service,
223+
Some(znode_path),
224+
)
225+
.await
226+
.context(BuildDiscoveryConfigMapSnafu)?
221227
{
222228
cluster_resources
223229
.add(client, &discovery_cm)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
timeout: 600
5+
---
6+
apiVersion: apps/v1
7+
kind: StatefulSet
8+
metadata:
9+
name: test-zk-server-default
10+
status:
11+
readyReplicas: 1
12+
replicas: 1
13+
---
14+
apiVersion: v1
15+
kind: ConfigMap
16+
metadata:
17+
name: test-znode
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
apiVersion: zookeeper.stackable.tech/v1alpha1
3+
kind: ZookeeperCluster
4+
metadata:
5+
name: test-zk
6+
spec:
7+
version: {{ test_scenario['values']['zookeeper-latest'] }}
8+
servers:
9+
roleGroups:
10+
default:
11+
replicas: 1
12+
---
13+
apiVersion: zookeeper.stackable.tech/v1alpha1
14+
kind: ZookeeperZnode
15+
metadata:
16+
name: test-znode
17+
spec:
18+
clusterRef:
19+
name: test-zk

tests/test-definition.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ dimensions:
66
- 3.6.3-stackable0.8.0
77
- 3.7.0-stackable0.8.0
88
- 3.8.0-stackable0.8.0
9+
- name: zookeeper-latest
10+
values:
11+
- 3.8.0-stackable0.8.0
912
- name: use-client-tls
1013
values:
1114
- "true"
@@ -23,3 +26,6 @@ tests:
2326
- name: delete-rolegroup
2427
dimensions:
2528
- zookeeper
29+
- name: znode
30+
dimensions:
31+
- zookeeper-latest

0 commit comments

Comments
 (0)