Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Default ZookeeperClusterRef's namespace to the ns of the Znode #382

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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