Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ All notable changes to this project will be documented in this file.
- Fix a longstanding problem of including empty `categories`, `shortNames` and `additionalPrinterColumns` in the CRDs,
which could cause problems with GitOps tools (e.g. ArgoCD) reporting a diff in the custom resources.
See [our internal issue](https://github.com/stackabletech/hdfs-operator/issues/626) and [the fix](https://github.com/kube-rs/kube/pull/2042) for details ([#860]).
- The operator now watches all resources that it creates and early-exits the reconcile action when the
cluster is marked for deletion ([#867]).

[#841]: https://github.com/stackabletech/druid-operator/pull/841
[#846]: https://github.com/stackabletech/druid-operator/pull/846
[#855]: https://github.com/stackabletech/druid-operator/pull/855
[#856]: https://github.com/stackabletech/druid-operator/pull/856
[#860]: https://github.com/stackabletech/druid-operator/pull/860
[#865]: https://github.com/stackabletech/druid-operator/pull/865
[#867]: https://github.com/stackabletech/druid-operator/pull/867

## [26.7.0] - 2026-07-21

Expand Down
41 changes: 12 additions & 29 deletions deploy/helm/druid-operator/templates/clusterrole-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,28 @@ rules:
- nodes/proxy
verbs:
- get
# Manage core workload resources created per DruidCluster.
# All resources are applied via Server-Side Apply (create + patch) and tracked for
# orphan cleanup (list + delete).
# Manage core workload resources created per DruidCluster: ConfigMaps and Services,
# the shared internal authentication Secret (cookie passphrase and internal client
# password; no orphan cleanup — Kubernetes GC via owner reference instead), and the
# ServiceAccount providing workload pod identity. All are applied via Server-Side
# Apply (create + patch), tracked for orphan cleanup where applicable (list +
# delete) and watched by the controller (`.owns()` lists before it watches).
- apiGroups:
- ""
resources:
- configmaps
- services
verbs:
- create
- delete
- get
- list
- patch
- watch
# Shared internal authentication secret (cookie passphrase and internal client password).
# Orphan cleanup not needed (instead, Kubernetes GC via owner reference).
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- delete
- get
- patch
# ServiceAccount created per DruidCluster for workload pod identity.
# Applied via SSA and tracked for orphan cleanup. Not watched by the controller.
- apiGroups:
- ""
resources:
- serviceaccounts
- services
verbs:
- create
- delete
- get
- list
- patch
- watch
# RoleBinding created per DruidCluster to bind the product ClusterRole to the workload
# ServiceAccount. Applied via SSA and tracked for orphan cleanup. Not watched by the controller.
# ServiceAccount. Applied via SSA and tracked for orphan cleanup and watched by the controller.
- apiGroups:
- rbac.authorization.k8s.io
resources:
Expand All @@ -63,6 +45,7 @@ rules:
- get
- list
- patch
- watch
# Required to bind the product ClusterRole to the per-cluster ServiceAccount.
- apiGroups:
- rbac.authorization.k8s.io
Expand All @@ -85,8 +68,7 @@ rules:
- list
- patch
- watch
# PodDisruptionBudget created per role. Applied via SSA and tracked for orphan cleanup.
# Not watched by the controller.
# PodDisruptionBudget created per role. Applied via SSA and tracked for orphan cleanup and watched by the controller.
- apiGroups:
- policy
resources:
Expand All @@ -97,6 +79,7 @@ rules:
- get
- list
- patch
- watch
# Required for maintaining the CRDs within the operator (including the conversion webhook info).
# Also for the startup condition check before the controller can run.
- apiGroups:
Expand Down
66 changes: 64 additions & 2 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use stackable_operator::{
rbac::v1::RoleBinding,
},
kube::{
Resource,
core::{DeserializeGuard, error_boundary},
runtime::controller::Action,
},
Expand Down Expand Up @@ -115,6 +116,11 @@ pub async fn reconcile_druid(
ctx: Arc<Ctx>,
) -> Result<Action> {
tracing::info!("Starting reconcile");

if druid.meta().deletion_timestamp.is_some() {
return Ok(Action::await_change());
}

let druid = druid
.0
.as_ref()
Expand Down Expand Up @@ -173,9 +179,15 @@ mod test {
use std::str::FromStr;

use rstest::*;
use stackable_operator::v2::types::operator::RoleGroupName;
use stackable_operator::{
client::Client,
commons::networking::DomainName,
kube::{Client as KubeClient, Config, runtime::controller::Action},
utils::cluster_info::KubernetesClusterInfo,
v2::types::operator::RoleGroupName,
};

use super::{CONTROLLER_NAME, OPERATOR_NAME, PRODUCT_NAME};
use super::{CONTROLLER_NAME, OPERATOR_NAME, PRODUCT_NAME, *};
use crate::{
controller::build::{
properties::ConfigFileName, resource::config_map::build_rolegroup_config_map,
Expand Down Expand Up @@ -254,4 +266,54 @@ mod test {
"role group {tested_rolegroup_name}"
);
}

/// The client points at a closed port, so any API call would fail the reconciliation: an `Ok`
/// proves that a cluster being deleted returns before the reconciler touches the Kubernetes
/// API, and because the spec is invalid, before the [`DeserializeGuard`] is unwrapped.
#[test]
fn reconcile_exits_early_for_deleted_cluster() {
let druid = serde_yaml::from_str(
r#"
apiVersion: druid.stackable.tech/v1alpha1
kind: DruidCluster
metadata:
name: druid
namespace: default
deletionTimestamp: "2026-08-14T12:00:00Z"
spec: {}
"#,
)
.expect("YAML parses; the invalid spec is captured inside the DeserializeGuard");

let action = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("current-thread tokio runtime")
.block_on(async {
let ctx = Arc::new(Ctx {
client: Client::new(
KubeClient::try_from(Config::new(
"http://127.0.0.1:1".parse().expect("valid static URI"),
))
.expect("client from static config"),
None,
"default".to_owned(),
KubernetesClusterInfo {
cluster_domain: DomainName::from_str("cluster.local")
.expect("valid cluster domain"),
},
),
operator_environment: OperatorEnvironmentOptions {
operator_namespace: "stackable-operators".to_owned(),
operator_service_name: "druid-operator".to_owned(),
image_repository: "oci.stackable.tech/sdp".to_owned(),
},
});

reconcile_druid(Arc::new(druid), ctx).await
})
.expect("a deleted cluster reconciles without any API call");

assert_eq!(action, Action::await_change());
}
}
28 changes: 23 additions & 5 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use stackable_operator::{
eos::EndOfSupportChecker,
k8s_openapi::api::{
apps::v1::StatefulSet,
core::v1::{ConfigMap, Service},
core::v1::{ConfigMap, Secret, Service, ServiceAccount},
policy::v1::PodDisruptionBudget,
rbac::v1::RoleBinding,
},
kube::{
CustomResourceExt, ResourceExt,
Expand Down Expand Up @@ -125,19 +127,35 @@ async fn main() -> anyhow::Result<()> {
let config_map_store = druid_controller.store();
let druid_controller = druid_controller
.owns(
watch_namespace.get_api::<Service>(&client),
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<DeserializeGuard<Listener>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<DeserializeGuard<PodDisruptionBudget>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<DeserializeGuard<RoleBinding>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<DeserializeGuard<Secret>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<StatefulSet>(&client),
watch_namespace.get_api::<DeserializeGuard<Service>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<ConfigMap>(&client),
watch_namespace.get_api::<DeserializeGuard<ServiceAccount>>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<Listener>(&client),
watch_namespace.get_api::<DeserializeGuard<StatefulSet>>(&client),
watcher::Config::default(),
)
.watches(
Expand Down
Loading
Loading