Skip to content

Commit f856543

Browse files
committed
chore: Update to operator-rs 0.84.0
1 parent 9e4ad0e commit f856543

File tree

10 files changed

+1292
-542
lines changed

10 files changed

+1292
-542
lines changed

Cargo.lock

Lines changed: 215 additions & 204 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 995 additions & 305 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repository = "https://github.com/stackabletech/zookeeper-operator"
1313
anyhow = "1.0"
1414
built = { version = "0.7", features = ["chrono", "git2"] }
1515
clap = "4.5"
16+
const_format = "0.2"
1617
fnv = "1.0"
1718
futures = { version = "0.3", features = ["compat"] }
1819
indoc = "2.0"
@@ -22,7 +23,7 @@ serde = { version = "1.0", features = ["derive"] }
2223
serde_json = "1.0"
2324
serde_yaml = "0.9"
2425
snafu = "0.8"
25-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.83.0" }
26+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.84.0" }
2627
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2728
strum = { version = "0.26", features = ["derive"] }
2829
tokio = { version = "1.40", features = ["full"] }

crate-hashes.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/zookeeper-operator/templates/roles.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ rules:
106106
- events
107107
verbs:
108108
- create
109+
- patch
109110
- apiGroups:
110111
- {{ include "operator.name" . }}.stackable.tech
111112
resources:

rust/crd/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use stackable_operator::{
2525
memory::{BinaryMultiple, MemoryQuantity},
2626
product_config_utils::{self, Configuration},
2727
product_logging::{self, spec::Logging},
28-
role_utils::{GenericRoleConfig, Role, RoleGroup, RoleGroupRef},
28+
role_utils::{
29+
GenericProductSpecificCommonConfig, GenericRoleConfig, Role, RoleGroup, RoleGroupRef,
30+
},
2931
schemars::{self, JsonSchema},
3032
status::condition::{ClusterCondition, HasStatusCondition},
3133
time::Duration,
@@ -517,7 +519,7 @@ impl ZookeeperCluster {
517519
pub fn rolegroup(
518520
&self,
519521
rolegroup_ref: &RoleGroupRef<ZookeeperCluster>,
520-
) -> Result<RoleGroup<ZookeeperConfigFragment>, Error> {
522+
) -> Result<RoleGroup<ZookeeperConfigFragment, GenericProductSpecificCommonConfig>, Error> {
521523
let role_variant = ZookeeperRole::from_str(&rolegroup_ref.role).with_context(|_| {
522524
UnknownZookeeperRoleSnafu {
523525
role: rolegroup_ref.role.to_owned(),

rust/operator-binary/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ stackable-zookeeper-crd = { path = "../crd" }
1414

1515
anyhow.workspace = true
1616
clap.workspace = true
17+
const_format.workspace = true
1718
fnv.workspace = true
1819
futures.workspace = true
1920
indoc.workspace = true

rust/operator-binary/src/main.rs

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::Arc;
22

33
use clap::{crate_description, crate_version, Parser};
4-
use futures::StreamExt;
4+
use futures::{pin_mut, StreamExt};
55
use stackable_operator::{
66
cli::{Command, ProductOperatorRun},
77
k8s_openapi::api::{
@@ -10,16 +10,19 @@ use stackable_operator::{
1010
},
1111
kube::{
1212
core::DeserializeGuard,
13-
runtime::{reflector::ObjectRef, watcher, Controller},
13+
runtime::{
14+
events::{Recorder, Reporter},
15+
reflector::ObjectRef,
16+
watcher, Controller,
17+
},
1418
Resource,
1519
},
1620
logging::controller::report_controller_reconciled,
1721
CustomResourceExt,
1822
};
1923
use stackable_zookeeper_crd::{ZookeeperCluster, ZookeeperZnode, APP_NAME, OPERATOR_NAME};
2024

21-
use crate::zk_controller::ZK_CONTROLLER_NAME;
22-
use crate::znode_controller::ZNODE_CONTROLLER_NAME;
25+
use crate::{zk_controller::ZK_FULL_CONTROLLER_NAME, znode_controller::ZNODE_FULL_CONTROLLER_NAME};
2326

2427
mod command;
2528
mod discovery;
@@ -79,13 +82,20 @@ async fn main() -> anyhow::Result<()> {
7982
)
8083
.await?;
8184

82-
let zk_controller_builder = Controller::new(
85+
let zk_controller = Controller::new(
8386
watch_namespace.get_api::<DeserializeGuard<ZookeeperCluster>>(&client),
8487
watcher::Config::default(),
8588
);
8689

87-
let zk_store = zk_controller_builder.store();
88-
let zk_controller = zk_controller_builder
90+
let zk_event_recorder = Arc::new(Recorder::new(
91+
client.as_kube_client(),
92+
Reporter {
93+
controller: ZK_FULL_CONTROLLER_NAME.to_string(),
94+
instance: None,
95+
},
96+
));
97+
let zk_store = zk_controller.store();
98+
let zk_controller = zk_controller
8999
.owns(
90100
watch_namespace.get_api::<DeserializeGuard<Service>>(&client),
91101
watcher::Config::default(),
@@ -125,19 +135,38 @@ async fn main() -> anyhow::Result<()> {
125135
product_config,
126136
}),
127137
)
128-
.map(|res| {
129-
report_controller_reconciled(
130-
&client,
131-
&format!("{ZK_CONTROLLER_NAME}.{OPERATOR_NAME}"),
132-
&res,
133-
);
134-
});
135-
let znode_controller_builder = Controller::new(
138+
// We can let the reporting happen in the background
139+
.for_each_concurrent(
140+
16, // concurrency limit
141+
|result| {
142+
// The event_recorder needs to be shared across all invocations, so that
143+
// events are correctly aggregated
144+
let event_recorder = zk_event_recorder.clone();
145+
async move {
146+
report_controller_reconciled(
147+
&event_recorder,
148+
ZK_FULL_CONTROLLER_NAME,
149+
&result,
150+
)
151+
.await;
152+
}
153+
},
154+
);
155+
156+
let znode_controller = Controller::new(
136157
watch_namespace.get_api::<DeserializeGuard<ZookeeperZnode>>(&client),
137158
watcher::Config::default(),
138159
);
139-
let znode_store = znode_controller_builder.store();
140-
let znode_controller = znode_controller_builder
160+
let znode_event_recorder = Arc::new(Recorder::new(
161+
client.as_kube_client(),
162+
Reporter {
163+
controller: ZNODE_FULL_CONTROLLER_NAME.to_string(),
164+
instance: None,
165+
},
166+
));
167+
168+
let znode_store = znode_controller.store();
169+
let znode_controller = znode_controller
141170
.owns(
142171
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
143172
watcher::Config::default(),
@@ -168,17 +197,27 @@ async fn main() -> anyhow::Result<()> {
168197
client: client.clone(),
169198
}),
170199
)
171-
.map(|res| {
172-
report_controller_reconciled(
173-
&client,
174-
&format!("{ZNODE_CONTROLLER_NAME}.{OPERATOR_NAME}"),
175-
&res,
176-
);
177-
});
200+
// We can let the reporting happen in the background
201+
.for_each_concurrent(
202+
16, // concurrency limit
203+
move |result| {
204+
// The event_recorder needs to be shared across all invocations, so that
205+
// events are correctly aggregated
206+
let event_recorder = znode_event_recorder.clone();
207+
async move {
208+
report_controller_reconciled(
209+
&event_recorder,
210+
ZNODE_FULL_CONTROLLER_NAME,
211+
&result,
212+
)
213+
.await;
214+
}
215+
},
216+
);
178217

179-
futures::stream::select(zk_controller, znode_controller)
180-
.collect::<()>()
181-
.await;
218+
pin_mut!(zk_controller, znode_controller);
219+
// kube-runtime's Controller will tokio::spawn each reconciliation, so this only concerns the internal watch machinery
220+
futures::future::select(zk_controller, znode_controller).await;
182221
}
183222
}
184223

rust/operator-binary/src/zk_controller.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{
77
sync::Arc,
88
};
99

10+
use const_format::concatcp;
1011
use fnv::FnvHasher;
1112
use indoc::formatdoc;
1213
use product_config::{
@@ -82,6 +83,8 @@ use crate::{
8283
};
8384

8485
pub const ZK_CONTROLLER_NAME: &str = "zookeepercluster";
86+
pub const ZK_FULL_CONTROLLER_NAME: &str = concatcp!(ZK_CONTROLLER_NAME, '.', OPERATOR_NAME);
87+
8588
pub const ZK_UID: i64 = 1000;
8689
pub struct Ctx {
8790
pub client: stackable_operator::client::Client,

rust/operator-binary/src/znode_controller.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! See [`ZookeeperZnode`] for more details.
44
use std::{borrow::Cow, convert::Infallible, sync::Arc};
55

6+
use const_format::concatcp;
67
use snafu::{OptionExt, ResultExt, Snafu};
78
use stackable_operator::{
89
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
@@ -32,6 +33,7 @@ use crate::{
3233
};
3334

3435
pub const ZNODE_CONTROLLER_NAME: &str = "znode";
36+
pub const ZNODE_FULL_CONTROLLER_NAME: &str = concatcp!(ZNODE_CONTROLLER_NAME, '.', OPERATOR_NAME);
3537

3638
pub struct Ctx {
3739
pub client: stackable_operator::client::Client,

0 commit comments

Comments
 (0)