Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed

- Respect `--watch-namespace` CLI argument ([#193]).

[#193]: https://github.com/stackabletech/commons-operator/pull/193

## [23.11.0] - 2023-11-24

## [23.7.0] - 2023-07-14
Expand Down
10 changes: 6 additions & 4 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn main() -> anyhow::Result<()> {
}
Command::Run(ProductOperatorRun {
product_config: _,
watch_namespace: _,
watch_namespace,
tracing_target,
}) => {
stackable_operator::logging::initialize_logging(
Expand All @@ -58,9 +58,11 @@ async fn main() -> anyhow::Result<()> {
))
.await?;

let sts_restart_controller = restart_controller::statefulset::start(&client);
let pod_restart_controller = restart_controller::pod::start(&client);
let pod_enrichment_controller = pod_enrichment_controller::start(&client);
let sts_restart_controller =
restart_controller::statefulset::start(&client, &watch_namespace);
let pod_restart_controller = restart_controller::pod::start(&client, &watch_namespace);
let pod_enrichment_controller =
pod_enrichment_controller::start(&client, &watch_namespace);
pin_mut!(
sts_restart_controller,
pod_restart_controller,
Expand Down
5 changes: 3 additions & 2 deletions rust/operator-binary/src/pod_enrichment_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use stackable_operator::{
runtime::{controller, reflector::ObjectRef, watcher, Controller},
},
logging::controller::{report_controller_reconciled, ReconcilerError},
namespace::WatchNamespace,
};
use strum::{EnumDiscriminants, IntoStaticStr};

Expand Down Expand Up @@ -46,9 +47,9 @@ impl ReconcilerError for Error {
}
}

pub async fn start(client: &stackable_operator::client::Client) {
pub async fn start(client: &stackable_operator::client::Client, watch_namespace: &WatchNamespace) {
let controller = Controller::new(
client.get_all_api::<Pod>(),
watch_namespace.get_api::<Pod>(client),
watcher::Config::default().labels("enrichment.stackable.tech/enabled=true"),
);
let pods = controller.store();
Expand Down
8 changes: 6 additions & 2 deletions rust/operator-binary/src/restart_controller/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use stackable_operator::{
runtime::{controller::Action, reflector::ObjectRef, watcher, Controller},
},
logging::controller::{report_controller_reconciled, ReconcilerError},
namespace::WatchNamespace,
};
use strum::{EnumDiscriminants, IntoStaticStr};

Expand Down Expand Up @@ -60,8 +61,11 @@ impl ReconcilerError for Error {
}
}

pub async fn start(client: &Client) {
let controller = Controller::new(client.get_all_api::<Pod>(), watcher::Config::default());
pub async fn start(client: &Client, watch_namespace: &WatchNamespace) {
let controller = Controller::new(
watch_namespace.get_api::<Pod>(client),
watcher::Config::default(),
);
controller
.run(
reconcile,
Expand Down
12 changes: 6 additions & 6 deletions rust/operator-binary/src/restart_controller/statefulset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use stackable_operator::kube::runtime::reflector::{ObjectRef, Store};
use stackable_operator::kube::runtime::{applier, reflector, watcher, Config, WatchStreamExt};
use stackable_operator::kube::{Resource, ResourceExt};
use stackable_operator::logging::controller::{report_controller_reconciled, ReconcilerError};
use stackable_operator::namespace::WatchNamespace;
use strum::{EnumDiscriminants, IntoStaticStr};

struct Ctx {
Expand Down Expand Up @@ -59,11 +60,10 @@ impl ReconcilerError for Error {
}
}

pub async fn start(client: &Client) {
let kube = client.as_kube_client();
let stses = kube::Api::<StatefulSet>::all(kube.clone());
let cms = kube::Api::<ConfigMap>::all(kube.clone());
let secrets = kube::Api::<Secret>::all(kube.clone());
pub async fn start(client: &Client, watch_namespace: &WatchNamespace) {
let stses = watch_namespace.get_api::<StatefulSet>(client);
let cms = watch_namespace.get_api::<ConfigMap>(client);
let secrets = watch_namespace.get_api::<Secret>(client);
let sts_store = reflector::store::Writer::new(());
let cm_store = reflector::store::Writer::new(());
let secret_store = reflector::store::Writer::new(());
Expand All @@ -74,7 +74,7 @@ pub async fn start(client: &Client) {
|sts, ctx| Box::pin(reconcile(sts, ctx)),
error_policy,
Arc::new(Ctx {
kube,
kube: client.as_kube_client(),
cms: cm_store.as_reader(),
secrets: secret_store.as_reader(),
cms_inited: cms_inited.clone(),
Expand Down