Skip to content

Commit

Permalink
Default ZookeeperClusterRef's namespace to the ns of the Znode (#382)
Browse files Browse the repository at this point in the history
## Description

This ensures that references can now work without the manifest knowing which namespace it's being applied to.
  • Loading branch information
nightkr committed Feb 4, 2022
1 parent 86e874f commit f91e9e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- ZookeeperZnode.spec.clusterRef.namespace now defaults to .metadata.namespace ([#382]).

### Changed

- Shut down gracefully ([#338]).
Expand All @@ -13,6 +17,7 @@ All notable changes to this project will be documented in this file.
[#338]: https://github.com/stackabletech/zookeeper-operator/pull/338
[#340]: https://github.com/stackabletech/zookeeper-operator/pull/340
[#352]: https://github.com/stackabletech/zookeeper-operator/pull/352
[#382]: https://github.com/stackabletech/zookeeper-operator/pull/382

## [0.8.0] - 2021-12-22

Expand Down
3 changes: 2 additions & 1 deletion examples/simple-zookeeperznode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ metadata:
spec:
clusterRef:
name: simple-zk
namespace: default
# Optional when ZookeeperZnode is in the same Namespace as the ZookeeperCluster
# namespace: default
15 changes: 10 additions & 5 deletions rust/operator-binary/src/znode_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,16 @@ async fn find_zk_of_znode(
client: &stackable_operator::client::Client,
znode: &ZookeeperZnode,
) -> Result<ZookeeperCluster, Error> {
if let ZookeeperClusterRef {
name: Some(zk_name),
namespace: Some(zk_ns),
} = &znode.spec.cluster_ref
{
let ZookeeperClusterRef {
name: zk_name,
namespace: zk_ns,
} = &znode.spec.cluster_ref;
if let (Some(zk_name), Some(zk_ns)) = (
zk_name,
zk_ns
.as_deref()
.or_else(|| znode.metadata.namespace.as_deref()),
) {
client
.get::<ZookeeperCluster>(zk_name, Some(zk_ns))
.await
Expand Down

0 comments on commit f91e9e4

Please sign in to comment.