From 40ae1a15bd0856539bb863dd7345473b2c1a35d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teo=20Klestrup=20R=C3=B6ijezon?= Date: Fri, 4 Feb 2022 15:28:25 +0000 Subject: [PATCH] Use upstream ClusterRef over ZookeeperClusterRef (#383) ## Description This also incorporates the namespace-defaulting from #382 and, as such, supersedes it. Co-authored-by: Stacky McStackface --- Cargo.lock | 175 +++++++++--------- deploy/crd/zookeeperznode.crd.yaml | 8 +- deploy/helm/zookeeper-operator/crds/crds.yaml | 8 +- deploy/manifests/crds.yaml | 8 +- rust/crd/Cargo.toml | 2 +- rust/crd/src/lib.rs | 13 +- rust/operator-binary/Cargo.toml | 4 +- rust/operator-binary/src/main.rs | 4 +- rust/operator-binary/src/zk_controller.rs | 12 +- rust/operator-binary/src/znode_controller.rs | 20 +- 10 files changed, 134 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0508cbb3..86a6b6e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -37,9 +48,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.52" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" +checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" [[package]] name = "async-trait" @@ -82,9 +93,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" +checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" dependencies = [ "addr2line", "cc", @@ -189,9 +200,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.9" +version = "3.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c506244a13c87262f84bf16369740d0b7c3850901b6a642aa41b031a710c473" +checksum = "b63edc3f163b3c71ec8aa23f9bd6070f77edbf3d1d198b164afa90ff00e4ec62" dependencies = [ "atty", "bitflags", @@ -206,9 +217,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.0.6" +version = "3.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517358c28fcef6607bf6f76108e02afad7e82297d132a6b846dcc1fc3efcd153" +checksum = "9a1132dc3944b31c20dd8b906b3a9f0a5d0243e092d59171414969657ac6aa85" dependencies = [ "heck 0.4.0", "proc-macro-error", @@ -345,16 +356,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dashmap" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" -dependencies = [ - "cfg-if 1.0.0", - "num_cpus", -] - [[package]] name = "derivative" version = "2.2.0" @@ -493,9 +494,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ "instant", ] @@ -760,7 +761,7 @@ dependencies = [ "itoa 0.4.8", "pin-project-lite", "socket2", - "tokio 1.15.0", + "tokio 1.16.1", "tower-service", "tracing", "want", @@ -774,7 +775,7 @@ checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ "hyper", "pin-project-lite", - "tokio 1.15.0", + "tokio 1.16.1", "tokio-io-timeout", ] @@ -787,7 +788,7 @@ dependencies = [ "bytes 1.1.0", "hyper", "native-tls", - "tokio 1.15.0", + "tokio 1.16.1", "tokio-native-tls", ] @@ -892,9 +893,9 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f8de9873b904e74b3533f77493731ee26742418077503683db44e1b3c54aa5c" +checksum = "0489fc937cc7616a9abfa61bf39c250d7e32e1325ef028c8d9278dd24ea395b3" dependencies = [ "base64", "bytes 1.1.0", @@ -917,9 +918,9 @@ dependencies = [ [[package]] name = "kube" -version = "0.66.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4b96944d327b752df4f62f3a31d8694892af06fb585747c0b5e664927823d1a" +checksum = "d41f782ddd187a0d8965607679bbd741052106b75330696ce7d7712b13194d88" dependencies = [ "k8s-openapi", "kube-client", @@ -930,9 +931,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "0.66.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232db1af3d3680f9289cf0b4db51b2b9fee22550fc65d25869e39b23e0aaa696" +checksum = "cced1a3e738c2a4bccb52d33066632369c668f366a71c9c58139d9360e1a341d" dependencies = [ "base64", "bytes 1.1.0", @@ -956,7 +957,7 @@ dependencies = [ "serde_json", "serde_yaml", "thiserror", - "tokio 1.15.0", + "tokio 1.16.1", "tokio-native-tls", "tokio-util", "tower", @@ -966,9 +967,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "0.66.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de491f8c9ee97117e0b47a629753e939c2392d5d0a40f6928e582a5fba328098" +checksum = "6878656f5e349ef08b0a48d2b1841f1e68c4cf1ef42524feadad2f9a109dd888" dependencies = [ "chrono", "form_urlencoded", @@ -984,9 +985,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "0.66.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcbb86bb3607245a67c8ad3a52aff41108f36b0d1e9e3e82ffb5760bfd84b965" +checksum = "73f5fa510a64791242047fea4d807a5da06514ee714cace4b942d38a1126f0a8" dependencies = [ "darling", "proc-macro2", @@ -997,23 +998,24 @@ dependencies = [ [[package]] name = "kube-runtime" -version = "0.66.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "710729592eb30219b4e84898e91dc991fe09ccafe2c17fec4e45c3426c61abe0" +checksum = "0990fe3ab89a1217e6a4d4952e1ab0a24783265ed413228efbc489a00f86b3da" dependencies = [ + "ahash", "backoff", - "dashmap", "derivative", "futures 0.3.19", "json-patch", "k8s-openapi", "kube-client", + "parking_lot 0.11.2", "pin-project", "serde", "serde_json", "smallvec 1.8.0", "thiserror", - "tokio 1.15.0", + "tokio 1.16.1", "tokio-util", "tracing", ] @@ -1026,9 +1028,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "libgit2-sys" @@ -1071,9 +1073,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -1348,7 +1350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", - "lock_api 0.4.5", + "lock_api 0.4.6", "parking_lot_core 0.8.5", ] @@ -1491,9 +1493,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -1677,9 +1679,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce" +checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac" dependencies = [ "bitflags", "core-foundation", @@ -1690,9 +1692,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7" +checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c" dependencies = [ "core-foundation-sys", "libc", @@ -1724,9 +1726,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.133" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] @@ -1743,9 +1745,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.133" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -1765,9 +1767,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.75" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79" +checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" dependencies = [ "indexmap", "itoa 1.0.1", @@ -1856,9 +1858,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi 0.3.9", @@ -1866,8 +1868,8 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.8.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.8.0#e7ffe8e5804e62ee6c33a0e0d6a85e17f21bf0fd" +version = "0.10.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.10.0#143165cf58e66b5e36d9774c188821248e5e4009" dependencies = [ "async-trait", "backoff", @@ -1891,7 +1893,7 @@ dependencies = [ "strum", "strum_macros", "thiserror", - "tokio 1.15.0", + "tokio 1.16.1", "tracing", "tracing-futures", "tracing-subscriber", @@ -1930,7 +1932,7 @@ dependencies = [ "strum", "strum_macros", "tokio 0.1.22", - "tokio 1.15.0", + "tokio 1.16.1", "tokio-executor", "tokio-zookeeper", "tracing", @@ -1966,9 +1968,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -2038,9 +2040,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ "once_cell", ] @@ -2097,9 +2099,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" dependencies = [ "bytes 1.1.0", "libc", @@ -2174,7 +2176,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" dependencies = [ "pin-project-lite", - "tokio 1.15.0", + "tokio 1.16.1", ] [[package]] @@ -2195,7 +2197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", - "tokio 1.15.0", + "tokio 1.16.1", ] [[package]] @@ -2315,7 +2317,7 @@ dependencies = [ "log", "pin-project-lite", "slab", - "tokio 1.15.0", + "tokio 1.16.1", ] [[package]] @@ -2351,7 +2353,7 @@ dependencies = [ "futures-util", "pin-project", "pin-project-lite", - "tokio 1.15.0", + "tokio 1.16.1", "tokio-util", "tower-layer", "tower-service", @@ -2360,9 +2362,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ee603d6e665ecc7e0f8d479eedb4626bd4726f0ee6119cee5b3a6bf184cac0" +checksum = "03650267ad175b51c47d02ed9547fc7d4ba2c7e5cb76df0bed67edd1825ae297" dependencies = [ "base64", "bitflags", @@ -2392,9 +2394,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9" dependencies = [ "cfg-if 1.0.0", "log", @@ -2405,9 +2407,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716" dependencies = [ "proc-macro2", "quote", @@ -2416,11 +2418,12 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" dependencies = [ "lazy_static", + "valuable", ] [[package]] @@ -2446,9 +2449,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77be66445c4eeebb934a7340f227bfe7b338173d3f8c00a60a5a58005c9faecf" +checksum = "5312f325fe3588e277415f5a6cca1f4ccad0f248c4cd5a4bd33032d7286abc22" dependencies = [ "ansi_term", "lazy_static", @@ -2525,6 +2528,12 @@ dependencies = [ "getrandom", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2623,6 +2632,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc222aec311c323c717f56060324f32b82da1ce1dd81d9a09aa6a9030bfe08db" +checksum = "7c88870063c39ee00ec285a2f8d6a966e5b6fb2becc4e8dac77ed0d370ed6006" diff --git a/deploy/crd/zookeeperznode.crd.yaml b/deploy/crd/zookeeperznode.crd.yaml index 064bc4d0..3b67faea 100644 --- a/deploy/crd/zookeeperznode.crd.yaml +++ b/deploy/crd/zookeeperznode.crd.yaml @@ -25,13 +25,17 @@ spec: description: "A claim for a single ZooKeeper ZNode tree (filesystem node)\n\nA `ConfigMap` will automatically be created with the same name, containing the connection string in the field `ZOOKEEPER`. Each `ZookeeperZnode` gets an isolated ZNode chroot, which the `ZOOKEEPER` automatically contains. All data inside of this chroot will be deleted when the corresponding `ZookeeperZnode` is.\n\n`ZookeeperZnode` is *not* designed to manage the contents of this ZNode. Instead, it should be used to create a chroot for an installation of an application to work inside. Initializing the contents is the responsibility of the application." properties: clusterRef: - default: {} - description: "A reference to a [`ZookeeperCluster`]" + default: + name: ~ + namespace: ~ + description: "A reference to a product cluster (for example, a `ZookeeperCluster`)\n\n`namespace`'s defaulting only applies when retrieved via [`ClusterRef::namespace_relative_from`]" properties: name: + description: The name of the cluster nullable: true type: string namespace: + description: "The namespace of the cluster\n\nThis field is optional, and will default to the namespace of the referring object." nullable: true type: string type: object diff --git a/deploy/helm/zookeeper-operator/crds/crds.yaml b/deploy/helm/zookeeper-operator/crds/crds.yaml index 0f74ac6c..5a59580a 100644 --- a/deploy/helm/zookeeper-operator/crds/crds.yaml +++ b/deploy/helm/zookeeper-operator/crds/crds.yaml @@ -208,13 +208,17 @@ spec: description: "A claim for a single ZooKeeper ZNode tree (filesystem node)\n\nA `ConfigMap` will automatically be created with the same name, containing the connection string in the field `ZOOKEEPER`. Each `ZookeeperZnode` gets an isolated ZNode chroot, which the `ZOOKEEPER` automatically contains. All data inside of this chroot will be deleted when the corresponding `ZookeeperZnode` is.\n\n`ZookeeperZnode` is *not* designed to manage the contents of this ZNode. Instead, it should be used to create a chroot for an installation of an application to work inside. Initializing the contents is the responsibility of the application." properties: clusterRef: - default: {} - description: "A reference to a [`ZookeeperCluster`]" + default: + name: ~ + namespace: ~ + description: "A reference to a product cluster (for example, a `ZookeeperCluster`)\n\n`namespace`'s defaulting only applies when retrieved via [`ClusterRef::namespace_relative_from`]" properties: name: + description: The name of the cluster nullable: true type: string namespace: + description: "The namespace of the cluster\n\nThis field is optional, and will default to the namespace of the referring object." nullable: true type: string type: object diff --git a/deploy/manifests/crds.yaml b/deploy/manifests/crds.yaml index 7892846c..f9dbdd71 100644 --- a/deploy/manifests/crds.yaml +++ b/deploy/manifests/crds.yaml @@ -209,13 +209,17 @@ spec: description: "A claim for a single ZooKeeper ZNode tree (filesystem node)\n\nA `ConfigMap` will automatically be created with the same name, containing the connection string in the field `ZOOKEEPER`. Each `ZookeeperZnode` gets an isolated ZNode chroot, which the `ZOOKEEPER` automatically contains. All data inside of this chroot will be deleted when the corresponding `ZookeeperZnode` is.\n\n`ZookeeperZnode` is *not* designed to manage the contents of this ZNode. Instead, it should be used to create a chroot for an installation of an application to work inside. Initializing the contents is the responsibility of the application." properties: clusterRef: - default: {} - description: "A reference to a [`ZookeeperCluster`]" + default: + name: ~ + namespace: ~ + description: "A reference to a product cluster (for example, a `ZookeeperCluster`)\n\n`namespace`'s defaulting only applies when retrieved via [`ClusterRef::namespace_relative_from`]" properties: name: + description: The name of the cluster nullable: true type: string namespace: + description: "The namespace of the cluster\n\nThis field is optional, and will default to the namespace of the referring object." nullable: true type: string type: object diff --git a/rust/crd/Cargo.toml b/rust/crd/Cargo.toml index 1a0f2da3..b58710d8 100644 --- a/rust/crd/Cargo.toml +++ b/rust/crd/Cargo.toml @@ -11,5 +11,5 @@ repository = "https://github.com/stackabletech/zookeeper-operator" serde = "1.0.133" serde_json = "1.0.75" snafu = "0.7.0" -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.8.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.10.0" } strum = { version = "0.23.0", features = ["derive"] } diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 1d07d660..40e557dc 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -3,6 +3,7 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, Snafu}; use stackable_operator::{ + crd::ClusterRef, kube::{runtime::reflector::ObjectRef, CustomResource}, product_config_utils::{ConfigError, Configuration}, role_utils::{Role, RoleGroupRef}, @@ -225,15 +226,5 @@ impl ZookeeperPodRef { #[serde(rename_all = "camelCase")] pub struct ZookeeperZnodeSpec { #[serde(default)] - pub cluster_ref: ZookeeperClusterRef, -} - -/// A reference to a [`ZookeeperCluster`] -#[derive(Clone, Default, Debug, Deserialize, JsonSchema, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct ZookeeperClusterRef { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, + pub cluster_ref: ClusterRef, } diff --git a/rust/operator-binary/Cargo.toml b/rust/operator-binary/Cargo.toml index 6f5c93fd..cc8b87dd 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -23,7 +23,7 @@ tokio-executor = "0.1.10" tokio-zookeeper = "0.1.3" tracing = "0.1.29" pin-project = "1.0.10" -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.8.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.10.0" } stackable-zookeeper-crd = { path = "../crd" } anyhow = "1.0.52" fnv = "1.0.7" @@ -31,5 +31,5 @@ clap = { version = "3.0.9", features = ["derive"] } [build-dependencies] built = { version = "0.5.1", features = ["chrono", "git2"] } -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.8.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.10.0" } stackable-zookeeper-crd = { path = "../crd" } diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index 78e90d54..1bf5d0c8 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -97,7 +97,7 @@ async fn main() -> anyhow::Result<()> { zk.metadata.namespace == endpoints.metadata.namespace && zk.server_role_service_name() == endpoints.metadata.name }) - .map(|zk| ObjectRef::from_obj(&zk)) + .map(|zk| ObjectRef::from_obj(&*zk)) }, ) .owns(client.get_all_api::(), ListParams::default()) @@ -129,7 +129,7 @@ async fn main() -> anyhow::Result<()> { zk.metadata.namespace == znode.spec.cluster_ref.namespace && zk.metadata.name == znode.spec.cluster_ref.name }) - .map(|znode| ObjectRef::from_obj(&znode)) + .map(|znode| ObjectRef::from_obj(&*znode)) }, ) .shutdown_on_signal() diff --git a/rust/operator-binary/src/zk_controller.rs b/rust/operator-binary/src/zk_controller.rs index e765217c..0b345e1a 100644 --- a/rust/operator-binary/src/zk_controller.rs +++ b/rust/operator-binary/src/zk_controller.rs @@ -4,6 +4,7 @@ use std::{ borrow::Cow, collections::{BTreeMap, HashMap}, hash::Hasher, + sync::Arc, time::Duration, }; @@ -117,14 +118,17 @@ type Result = std::result::Result; const PROPERTIES_FILE: &str = "zoo.cfg"; -pub async fn reconcile_zk(zk: ZookeeperCluster, ctx: Context) -> Result { +pub async fn reconcile_zk( + zk: Arc, + ctx: Context, +) -> Result { tracing::info!("Starting reconcile"); let client = &ctx.get_ref().client; let validated_config = validate_all_roles_and_groups_config( zk_version(&zk)?, &transform_all_roles_to_config( - &zk, + &*zk, [( ZookeeperRole::Server.to_string(), ( @@ -186,7 +190,7 @@ pub async fn reconcile_zk(zk: ZookeeperCluster, ctx: Context) -> Result) -> Result) -> Result { +pub async fn reconcile_znode( + znode: Arc, + ctx: Context, +) -> Result { tracing::info!("Starting reconcile"); let (ns, uid) = if let ObjectMeta { namespace: Some(ns), @@ -227,15 +230,10 @@ async fn find_zk_of_znode( client: &stackable_operator::client::Client, znode: &ZookeeperZnode, ) -> Result { - let ZookeeperClusterRef { - name: zk_name, - namespace: zk_ns, - } = &znode.spec.cluster_ref; + let zk_ref = &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()), + zk_ref.name.as_deref(), + zk_ref.namespace_relative_from(znode), ) { match client.get::(zk_name, Some(zk_ns)).await { Ok(zk) => Ok(zk),