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
103 changes: 100 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,39 @@ repos:
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-no-default-features
name: cargo-test-no-default-features
- id: cargo-doc-no-default-features
name: cargo-doc-no-default-features
language: system
entry: cargo test --no-default-features --workspace
entry: cargo doc --no-default-features --document-private-items
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-doc-all-features
name: cargo-doc-all-features
language: system
entry: cargo doc --all-features --document-private-items
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

# As long as we run tests for every contained crate (to test turning off all features),
# we don't need to re-run them here
# - id: cargo-test
# name: cargo-test
# language: system
# entry: cargo test --workspace
# stages: [pre-commit, pre-merge-commit]
# pass_filenames: false
# files: \.rs$|Cargo\.(toml|lock)
# - id: cargo-test-no-default-features
# name: cargo-test-no-default-features
# language: system
# entry: cargo test --no-default-features --workspace
# stages: [pre-commit, pre-merge-commit]
# pass_filenames: false
# files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-all-features
name: cargo-test-all-features
language: system
Expand All @@ -71,6 +96,78 @@ repos:
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-k8s-version-no-default-features
name: cargo-test-k8s-version-no-default-features
language: system
entry: cargo test --no-default-features --package k8s-version
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-certs-no-default-features
name: cargo-test-stackable-certs-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-certs
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-operator-no-default-features
name: cargo-test-stackable-operator-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-operator
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-operator-derive-no-default-features
name: cargo-test-stackable-operator-derive-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-operator-derive
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-shared-no-default-features
name: cargo-test-stackable-shared-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-shared
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-telemetry-no-default-features
name: cargo-test-stackable-telemetry-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-telemetry
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-versioned-no-default-features
name: cargo-test-stackable-versioned-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-versioned
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-versioned-macros-no-default-features
name: cargo-test-stackable-versioned-macros-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-versioned-macros
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-webhook-no-default-features
name: cargo-test-stackable-webhook-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-webhook
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-rustfmt
name: cargo-rustfmt
language: system
Expand Down
42 changes: 42 additions & 0 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Added two new crate features: `crds` and `kube-ws` ([#1162]).

### Fixed

- BREAKING: Fix compilation failures when not enabling default features ([#1162]).
This is achieved by removing the `clap`, `telemetry` and `versioned` features, which were previously enabled by default.
They have been removed as the stackable-operator code actually always requires them.

[#1162]: https://github.com/stackabletech/operator-rs/pull/1162

## [0.106.2] - 2026-02-26

### Changed
Expand Down
13 changes: 6 additions & 7 deletions crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ edition.workspace = true
repository.workspace = true

[features]
full = ["certs", "telemetry", "versioned", "time", "webhook", "clap"]
default = ["telemetry", "versioned", "clap"]
default = ["crds"]
full = ["crds", "certs", "time", "webhook", "kube-ws"]

clap = []
crds = ["dep:stackable-versioned"]
certs = ["dep:stackable-certs"]
telemetry = ["dep:stackable-telemetry"]
time = ["stackable-shared/time"]
versioned = ["dep:stackable-versioned"]
webhook = ["dep:stackable-webhook"]
kube-ws = ["kube/ws"]

[dependencies]
stackable-certs = { path = "../stackable-certs", optional = true }
stackable-operator-derive = { path = "../stackable-operator-derive" }
stackable-shared = { path = "../stackable-shared", features = ["time", "jiff"] }
stackable-telemetry = { path = "../stackable-telemetry", optional = true, features = ["clap"] }
stackable-shared = { path = "../stackable-shared", features = ["jiff"] }
stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"] }
stackable-versioned = { path = "../stackable-versioned", optional = true }
stackable-webhook = { path = "../stackable-webhook", optional = true }

Expand Down
13 changes: 10 additions & 3 deletions crates/stackable-operator/src/cluster_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use crate::{
ResourceRequirementsExt, ResourceRequirementsType,
},
},
crd::listener,
deep_merger::{self, ObjectOverrides},
kvp::{
Label, LabelError, Labels,
Expand Down Expand Up @@ -221,7 +220,8 @@ impl ClusterResource for Service {}
impl ClusterResource for ServiceAccount {}
impl ClusterResource for RoleBinding {}
impl ClusterResource for PodDisruptionBudget {}
impl ClusterResource for listener::v1alpha1::Listener {}
#[cfg(feature = "crds")]
impl ClusterResource for crate::crd::listener::v1alpha1::Listener {}

impl ClusterResource for Job {
fn pod_spec(&self) -> Option<&PodSpec> {
Expand Down Expand Up @@ -670,6 +670,13 @@ impl<'a> ClusterResources<'a> {
///
/// * `client` - The client which is used to access Kubernetes
pub async fn delete_orphaned_resources(self, client: &Client) -> Result<()> {
// We can only delete Listeners in case the "crds" feature is enabled, otherwise it's a NOP.
#[cfg(feature = "crds")]
let delete_listeners = self
.delete_orphaned_resources_of_kind::<crate::crd::listener::v1alpha1::Listener>(client);
#[cfg(not(feature = "crds"))]
let delete_listeners = async { Ok(()) };

tokio::try_join!(
self.delete_orphaned_resources_of_kind::<Service>(client),
self.delete_orphaned_resources_of_kind::<StatefulSet>(client),
Expand All @@ -680,7 +687,7 @@ impl<'a> ClusterResources<'a> {
self.delete_orphaned_resources_of_kind::<ServiceAccount>(client),
self.delete_orphaned_resources_of_kind::<RoleBinding>(client),
self.delete_orphaned_resources_of_kind::<PodDisruptionBudget>(client),
self.delete_orphaned_resources_of_kind::<listener::v1alpha1::Listener>(client),
delete_listeners
)?;

Ok(())
Expand Down
18 changes: 8 additions & 10 deletions crates/stackable-operator/src/eos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,34 @@ use tracing::{Level, instrument};
///
/// Additionally, this struct can be used as operator CLI arguments. This functionality is only
/// available if the feature `clap` is enabled.
#[cfg_attr(feature = "clap", derive(clap::Args))]
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, clap::Args)]
pub struct EndOfSupportOptions {
/// The end-of-support check mode. Currently, only "offline" is supported.
#[cfg_attr(feature = "clap", arg(
#[arg(
long = "eos-check-mode",
env = "EOS_CHECK_MODE",
default_value_t = EndOfSupportCheckMode::default(),
value_enum
))]
)]
pub check_mode: EndOfSupportCheckMode,

/// The interval in which the end-of-support check should run.
#[cfg_attr(feature = "clap", arg(
#[arg(
long = "eos-interval",
env = "EOS_INTERVAL",
default_value_t = Self::default_interval()
))]
)]
pub interval: Duration,

/// If the end-of-support check should be disabled entirely.
#[cfg_attr(feature = "clap", arg(long = "eos-disabled", env = "EOS_DISABLED"))]
#[arg(long = "eos-disabled", env = "EOS_DISABLED")]
pub disabled: bool,

/// The support duration (how long the operator should be considered supported after
/// it's built-date).
///
/// This field is currently not exposed as a CLI argument or environment variable.
#[cfg_attr(feature = "clap", arg(skip = Self::default_support_duration()))]
#[arg(skip = Self::default_support_duration())]
pub support_duration: Duration,
}

Expand All @@ -55,8 +54,7 @@ impl EndOfSupportOptions {
}
}

#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Debug, Default, PartialEq, Eq, clap::ValueEnum)]
pub enum EndOfSupportCheckMode {
#[default]
Offline,
Expand Down
4 changes: 2 additions & 2 deletions crates/stackable-operator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod commons;
pub mod config;
pub mod constants;
pub mod cpu;
#[cfg(feature = "crds")]
pub mod crd;
pub mod deep_merger;
pub mod eos;
Expand Down Expand Up @@ -42,9 +43,8 @@ pub use schemars;
pub use stackable_certs as certs;
pub use stackable_shared as shared;
pub use stackable_shared::{crd::CustomResourceExt, yaml::YamlSchema};
#[cfg(feature = "telemetry")]
pub use stackable_telemetry as telemetry;
#[cfg(feature = "versioned")]
#[cfg(feature = "crds")]
pub use stackable_versioned as versioned;
#[cfg(feature = "webhook")]
pub use stackable_webhook as webhook;
11 changes: 4 additions & 7 deletions crates/stackable-operator/src/utils/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@ pub struct KubernetesClusterInfo {
pub cluster_domain: DomainName,
}

#[cfg_attr(
feature = "clap",
derive(clap::Parser),
command(next_help_heading = "Cluster Options")
)]
#[derive(clap::Parser)]
#[command(next_help_heading = "Cluster Options")]
#[derive(Debug, PartialEq, Eq)]
pub struct KubernetesClusterInfoOptions {
/// Kubernetes cluster domain, usually this is `cluster.local`.
// We are not using a default value here, as we query the cluster if it is not specified.
#[cfg_attr(feature = "clap", arg(long, env))]
#[arg(long, env)]
pub kubernetes_cluster_domain: Option<DomainName>,

/// Name of the Kubernetes Node that the operator is running on.
///
/// Note that when running the operator on Kubernetes we recommend to use the
/// [downward API](https://kubernetes.io/docs/concepts/workloads/pods/downward-api/)
/// to let Kubernetes project the namespace as the `KUBERNETES_NODE_NAME` env variable.
#[cfg_attr(feature = "clap", arg(long, env))]
#[arg(long, env)]
pub kubernetes_node_name: String,
}

Expand Down
Loading
Loading