Skip to content

Commit f4f678b

Browse files
committed
chore: Update to operator-rs 0.84.0
1 parent bf6714b commit f4f678b

File tree

8 files changed

+1242
-483
lines changed

8 files changed

+1242
-483
lines changed

Cargo.lock

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

Cargo.nix

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ futures = { version = "0.3", features = ["compat"] }
1717
serde = { version = "1.0", features = ["derive"] }
1818
serde_json = "1.0"
1919
snafu = "0.8"
20-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.83.0" }
20+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.84.0" }
2121
strum = { version = "0.26", features = ["derive"] }
2222
tokio = { version = "1.40", features = ["full"] }
2323
tracing = "0.1"

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/commons-operator/templates/roles.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ rules:
3232
- events
3333
verbs:
3434
- create
35+
- patch
3536
- apiGroups:
3637
- ""
3738
resources:

rust/operator-binary/src/pod_enrichment_controller.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ use stackable_operator::{
88
k8s_openapi::api::core::v1::{Node, Pod},
99
kube::{
1010
core::{error_boundary, DeserializeGuard, ObjectMeta},
11-
runtime::{controller, reflector::ObjectRef, watcher, Controller},
11+
runtime::{
12+
controller,
13+
events::{Recorder, Reporter},
14+
reflector::ObjectRef,
15+
watcher, Controller,
16+
},
1217
Resource,
1318
},
1419
logging::controller::{report_controller_reconciled, ReconcilerError},
1520
namespace::WatchNamespace,
1621
};
1722
use strum::{EnumDiscriminants, IntoStaticStr};
1823

24+
const FULL_CONTROLLER_NAME: &str = "pod.enrichment.commons.stackable.tech";
1925
const FIELD_MANAGER_SCOPE: &str = "enrichment.stackable.tech/pod";
2026
const ANNOTATION_NODE_ADDRESS: &str = "enrichment.stackable.tech/node-address";
2127

@@ -58,6 +64,13 @@ impl ReconcilerError for Error {
5864
}
5965

6066
pub async fn start(client: &stackable_operator::client::Client, watch_namespace: &WatchNamespace) {
67+
let event_recorder = Arc::new(Recorder::new(
68+
client.as_kube_client(),
69+
Reporter {
70+
controller: FULL_CONTROLLER_NAME.to_string(),
71+
instance: None,
72+
},
73+
));
6174
let controller = Controller::new(
6275
watch_namespace.get_api::<DeserializeGuard<Pod>>(client),
6376
watcher::Config::default().labels("enrichment.stackable.tech/enabled=true"),
@@ -87,9 +100,19 @@ pub async fn start(client: &stackable_operator::client::Client, watch_namespace:
87100
client: client.clone(),
88101
}),
89102
)
90-
.for_each(|res| async move {
91-
report_controller_reconciled(client, "pod.enrichment.commons.stackable.tech", &res)
92-
})
103+
// We can let the reporting happen in the background
104+
.for_each_concurrent(
105+
16, // concurrency limit
106+
|result| {
107+
// The event_recorder needs to be shared across all invocations, so that
108+
// events are correctly aggregated
109+
let event_recorder = event_recorder.clone();
110+
async move {
111+
report_controller_reconciled(&event_recorder, FULL_CONTROLLER_NAME, &result)
112+
.await;
113+
}
114+
},
115+
)
93116
.await;
94117
}
95118

rust/operator-binary/src/restart_controller/pod.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ use stackable_operator::{
1212
self,
1313
api::{EvictParams, PartialObjectMeta},
1414
core::DynamicObject,
15-
runtime::{controller::Action, reflector::ObjectRef, watcher, Controller},
15+
runtime::{
16+
controller::Action,
17+
events::{Recorder, Reporter},
18+
reflector::ObjectRef,
19+
watcher, Controller,
20+
},
1621
},
1722
logging::controller::{report_controller_reconciled, ReconcilerError},
1823
namespace::WatchNamespace,
1924
};
2025
use strum::{EnumDiscriminants, IntoStaticStr};
2126

27+
const FULL_CONTROLLER_NAME: &str = "pod.restarter.commons.stackable.tech";
28+
2229
struct Ctx {
2330
client: Client,
2431
}
@@ -66,6 +73,13 @@ pub async fn start(client: &Client, watch_namespace: &WatchNamespace) {
6673
watch_namespace.get_api::<PartialObjectMeta<Pod>>(client),
6774
watcher::Config::default(),
6875
);
76+
let event_recorder = Arc::new(Recorder::new(
77+
client.as_kube_client(),
78+
Reporter {
79+
controller: FULL_CONTROLLER_NAME.to_string(),
80+
instance: None,
81+
},
82+
));
6983
controller
7084
.run(
7185
reconcile,
@@ -74,9 +88,19 @@ pub async fn start(client: &Client, watch_namespace: &WatchNamespace) {
7488
client: client.clone(),
7589
}),
7690
)
77-
.for_each(|res| async move {
78-
report_controller_reconciled(client, "pod.restarter.commons.stackable.tech", &res)
79-
})
91+
// We can let the reporting happen in the background
92+
.for_each_concurrent(
93+
16, // concurrency limit
94+
|result| {
95+
// The event_recorder needs to be shared across all invocations, so that
96+
// events are correctly aggregated
97+
let event_recorder = event_recorder.clone();
98+
async move {
99+
report_controller_reconciled(&event_recorder, FULL_CONTROLLER_NAME, &result)
100+
.await;
101+
}
102+
},
103+
)
80104
.await;
81105
}
82106

rust/operator-binary/src/restart_controller/statefulset.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use stackable_operator::kube::core::{error_boundary, DeserializeGuard, DynamicOb
1717
use stackable_operator::kube::runtime::controller::{
1818
trigger_self, trigger_with, Action, ReconcileRequest,
1919
};
20+
use stackable_operator::kube::runtime::events::{Recorder, Reporter};
2021
use stackable_operator::kube::runtime::reflector::{ObjectRef, Store};
2122
use stackable_operator::kube::runtime::{
2223
applier, metadata_watcher, reflector, watcher, Config, WatchStreamExt,
@@ -26,6 +27,8 @@ use stackable_operator::logging::controller::{report_controller_reconciled, Reco
2627
use stackable_operator::namespace::WatchNamespace;
2728
use strum::{EnumDiscriminants, IntoStaticStr};
2829

30+
const FULL_CONTROLLER_NAME: &str = "statefulset.restarter.commons.stackable.tech";
31+
2932
struct Ctx {
3033
kube: kube::Client,
3134
cms: Store<PartialObjectMeta<ConfigMap>>,
@@ -79,6 +82,13 @@ pub async fn start(client: &Client, watch_namespace: &WatchNamespace) {
7982
let secret_store = reflector::store::Writer::<PartialObjectMeta<Secret>>::new(());
8083
let cms_inited = Arc::new(AtomicBool::from(false));
8184
let secrets_inited = Arc::new(AtomicBool::from(false));
85+
let event_recorder = Arc::new(Recorder::new(
86+
client.as_kube_client(),
87+
Reporter {
88+
controller: FULL_CONTROLLER_NAME.to_string(),
89+
instance: None,
90+
},
91+
));
8292

8393
applier(
8494
|sts, ctx| Box::pin(reconcile(sts, ctx)),
@@ -123,9 +133,18 @@ pub async fn start(client: &Client, watch_namespace: &WatchNamespace) {
123133
),
124134
Config::default(),
125135
)
126-
.for_each(|res| async move {
127-
report_controller_reconciled(client, "statefulset.restarter.commons.stackable.tech", &res)
128-
})
136+
// We can let the reporting happen in the background
137+
.for_each_concurrent(
138+
16, // concurrency limit
139+
|result| {
140+
// The event_recorder needs to be shared across all invocations, so that
141+
// events are correctly aggregated
142+
let event_recorder = event_recorder.clone();
143+
async move {
144+
report_controller_reconciled(&event_recorder, FULL_CONTROLLER_NAME, &result).await;
145+
}
146+
},
147+
)
129148
.await;
130149
}
131150

0 commit comments

Comments
 (0)