Skip to content
Draft
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 @@ -29,13 +29,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 ([#814]).
- The operator now watches all resources that it creates and early-exits the reconcile action when the
cluster is marked for deletion ([#821]).

[#801]: https://github.com/stackabletech/hdfs-operator/pull/801
[#806]: https://github.com/stackabletech/hdfs-operator/pull/806
[#810]: https://github.com/stackabletech/hdfs-operator/pull/810
[#811]: https://github.com/stackabletech/hdfs-operator/pull/811
[#814]: https://github.com/stackabletech/hdfs-operator/pull/814
[#819]: https://github.com/stackabletech/hdfs-operator/pull/819
[#821]: https://github.com/stackabletech/hdfs-operator/pull/821

## [26.7.0] - 2026-07-21

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ built = { version = "0.8", features = ["chrono", "git2"] }
clap = "4.6"
const_format = "0.2"
futures = { version = "0.3", features = ["compat"] }
http = "1.3"
indoc = "2.0"
rstest = "0.26"
semver = "1.0"
Expand Down
12 changes: 9 additions & 3 deletions deploy/helm/hdfs-operator/templates/clusterrole-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ rules:
- list
- patch
- watch
# serviceaccounts are applied via SSA and tracked for orphan cleanup.
# serviceaccounts are applied via SSA and tracked for orphan cleanup
# and watched by the controller.
- apiGroups:
- ""
resources:
Expand All @@ -39,7 +40,9 @@ rules:
- get
- list
- patch
# rolebindings are applied via SSA and tracked for orphan cleanup.
- watch
# rolebindings are applied via SSA and tracked for orphan cleanup
# and watched by the controller.
- apiGroups:
- rbac.authorization.k8s.io
resources:
Expand All @@ -50,6 +53,7 @@ rules:
- get
- list
- patch
- watch
# statefulsets are applied via SSA, tracked for orphan cleanup.
- apiGroups:
- apps
Expand All @@ -62,7 +66,8 @@ rules:
- list
- patch
- watch
# poddisruptionbudgets are applied via SSA and tracked for orphan cleanup.
# poddisruptionbudgets are applied via SSA and tracked for orphan cleanup
# and watched by the controller.
- apiGroups:
- policy
resources:
Expand All @@ -73,6 +78,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
1 change: 1 addition & 0 deletions rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tracing-futures.workspace = true
tracing.workspace = true

[dev-dependencies]
http.workspace = true
rstest.workspace = true
serde_yaml.workspace = true

Expand Down
133 changes: 131 additions & 2 deletions rust/operator-binary/src/hdfs_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ pub async fn reconcile_hdfs(
) -> HdfsOperatorResult<Action> {
tracing::info!("Starting reconcile");

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

let hdfs = hdfs
.0
.as_ref()
Expand Down Expand Up @@ -160,13 +164,25 @@ mod test {
use std::str::FromStr;

use stackable_operator::{
builder::pod::PodBuilder, commons::networking::DomainName, kube::api::ObjectMeta,
kvp::Labels, utils::cluster_info::KubernetesClusterInfo,
builder::pod::PodBuilder,
client::Client,
commons::networking::DomainName,
kube::{
Client as KubeClient, Config,
api::ObjectMeta,
runtime::{
controller::Action,
events::{Recorder, Reporter},
},
},
kvp::Labels,
utils::cluster_info::KubernetesClusterInfo,
v2::types::operator::RoleGroupName,
};

use super::*;
use crate::{
HDFS_FULL_CONTROLLER_NAME,
controller::build::container::ContainerConfig,
test_support::{deserialize_cluster, role_group_config, validate_cluster},
};
Expand Down Expand Up @@ -261,4 +277,117 @@ spec:
Some("group-value".to_string())
);
}

/// A [`Ctx`] whose client points at a closed port. Any API call made through it fails the
/// reconciliation, so an `Ok` result proves the reconciler returned before touching the
/// Kubernetes API.
fn unreachable_ctx() -> Arc<Ctx> {
let config = Config::new(
"http://127.0.0.1:1"
.parse::<http::Uri>()
.expect("valid static URI"),
);
let kube_client = KubeClient::try_from(config).expect("client from static config");

Arc::new(Ctx {
client: Client::new(
kube_client.clone(),
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: "hdfs-operator".to_owned(),
image_repository: "oci.stackable.tech/sdp".to_owned(),
},
event_recorder: Arc::new(Recorder::new(
kube_client,
Reporter {
controller: HDFS_FULL_CONTROLLER_NAME.to_string(),
instance: None,
},
)),
})
}

fn reconcile(hdfs: DeserializeGuard<v1alpha1::HdfsCluster>) -> Result<Action, Error> {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("current-thread tokio runtime")
.block_on(async { reconcile_hdfs(Arc::new(hdfs), unreachable_ctx()).await })
}

#[test]
fn reconcile_exits_early_for_deleted_cluster() {
let hdfs = serde_yaml::from_str(
r#"
apiVersion: hdfs.stackable.tech/v1alpha1
kind: HdfsCluster
metadata:
name: hdfs
namespace: default
deletionTimestamp: "2026-08-14T12:00:00Z"
spec:
image:
productVersion: 3.2.2
"#,
)
.expect("valid cluster YAML");

let action = reconcile(hdfs).expect("a deleted cluster reconciles without any API call");

assert_eq!(action, Action::await_change());
}

#[test]
fn reconcile_exits_early_for_deleted_cluster_with_invalid_spec() {
let hdfs = serde_yaml::from_str(
r#"
apiVersion: hdfs.stackable.tech/v1alpha1
kind: HdfsCluster
metadata:
name: hdfs
namespace: default
deletionTimestamp: "2026-08-14T12:00:00Z"
spec: {}
"#,
)
.expect("YAML parses; the invalid spec is captured inside the DeserializeGuard");

let action =
reconcile(hdfs).expect("a deleted cluster reconciles even when its spec is invalid");

assert_eq!(action, Action::await_change());
}

#[test]
fn reconcile_proceeds_for_live_cluster() {
let hdfs = serde_yaml::from_str(
r#"
apiVersion: hdfs.stackable.tech/v1alpha1
kind: HdfsCluster
metadata:
name: hdfs
namespace: default
spec:
image:
productVersion: 3.5.0
clusterConfig:
zookeeperConfigMapName: simple-znode
"#,
)
.expect("valid cluster YAML");

let result = reconcile(hdfs);

assert!(
matches!(result, Err(Error::Dereference { .. })),
"a live cluster must reach the API but when dereferencing against the unreachable test server: {result:?}"
);
}
}
22 changes: 18 additions & 4 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use stackable_operator::{
eos::EndOfSupportChecker,
k8s_openapi::api::{
apps::v1::StatefulSet,
core::v1::{ConfigMap, Service},
core::v1::{ConfigMap, Service, ServiceAccount},
policy::v1::PodDisruptionBudget,
rbac::v1::RoleBinding,
},
kube::{
Api, CustomResourceExt, ResourceExt,
Expand Down Expand Up @@ -156,15 +158,27 @@ async fn main() -> anyhow::Result<()> {
let hdfs_cluster_store = hdfs_controller.store();
let hdfs_controller = hdfs_controller
.owns(
watch_namespace.get_api::<DeserializeGuard<StatefulSet>>(&client),
watch_namespace.get_api::<ConfigMap>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<DeserializeGuard<Service>>(&client),
watch_namespace.get_api::<PodDisruptionBudget>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
watch_namespace.get_api::<RoleBinding>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<Service>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<ServiceAccount>(&client),
watcher::Config::default(),
)
.owns(
watch_namespace.get_api::<StatefulSet>(&client),
watcher::Config::default(),
)
.watches(
Expand Down
Loading
Loading