Skip to content

Commit 992b3b2

Browse files
sbernauerTechassi
andauthored
fix: Fix compilation failures when not enabling default features (#1162)
* fix: Fix multiple compilation failures when not enabling default features * Add tokio-ws feature * changelog * Disable cargo test --workspace for now * Add crds feature * Fixup full feature list * refactor: Use cfg! * Add new features to changelog * Update crates/stackable-operator/CHANGELOG.md Co-authored-by: Techassi <git@techassi.dev> * ci: Also disable cargo-test-no-default-features for now * Revert "refactor: Use cfg!" This reverts commit 1e0cde4. It failed compilation, as it always compiles both branches, which fails when the crds feature is not enabled. --------- Co-authored-by: Techassi <git@techassi.dev>
1 parent 53748af commit 992b3b2

File tree

12 files changed

+194
-38
lines changed

12 files changed

+194
-38
lines changed

.pre-commit-config.yaml

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,39 @@ repos:
5555
pass_filenames: false
5656
files: \.rs$|Cargo\.(toml|lock)
5757

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

66+
- id: cargo-doc-all-features
67+
name: cargo-doc-all-features
68+
language: system
69+
entry: cargo doc --all-features --document-private-items
70+
stages: [pre-commit, pre-merge-commit]
71+
pass_filenames: false
72+
files: \.rs$|Cargo\.(toml|lock)
73+
74+
# As long as we run tests for every contained crate (to test turning off all features),
75+
# we don't need to re-run them here
76+
# - id: cargo-test
77+
# name: cargo-test
78+
# language: system
79+
# entry: cargo test --workspace
80+
# stages: [pre-commit, pre-merge-commit]
81+
# pass_filenames: false
82+
# files: \.rs$|Cargo\.(toml|lock)
83+
# - id: cargo-test-no-default-features
84+
# name: cargo-test-no-default-features
85+
# language: system
86+
# entry: cargo test --no-default-features --workspace
87+
# stages: [pre-commit, pre-merge-commit]
88+
# pass_filenames: false
89+
# files: \.rs$|Cargo\.(toml|lock)
90+
6691
- id: cargo-test-all-features
6792
name: cargo-test-all-features
6893
language: system
@@ -71,6 +96,78 @@ repos:
7196
pass_filenames: false
7297
files: \.rs$|Cargo\.(toml|lock)
7398

99+
- id: cargo-test-k8s-version-no-default-features
100+
name: cargo-test-k8s-version-no-default-features
101+
language: system
102+
entry: cargo test --no-default-features --package k8s-version
103+
stages: [pre-commit, pre-merge-commit]
104+
pass_filenames: false
105+
files: \.rs$|Cargo\.(toml|lock)
106+
107+
- id: cargo-test-stackable-certs-no-default-features
108+
name: cargo-test-stackable-certs-no-default-features
109+
language: system
110+
entry: cargo test --no-default-features --package stackable-certs
111+
stages: [pre-commit, pre-merge-commit]
112+
pass_filenames: false
113+
files: \.rs$|Cargo\.(toml|lock)
114+
115+
- id: cargo-test-stackable-operator-no-default-features
116+
name: cargo-test-stackable-operator-no-default-features
117+
language: system
118+
entry: cargo test --no-default-features --package stackable-operator
119+
stages: [pre-commit, pre-merge-commit]
120+
pass_filenames: false
121+
files: \.rs$|Cargo\.(toml|lock)
122+
123+
- id: cargo-test-stackable-operator-derive-no-default-features
124+
name: cargo-test-stackable-operator-derive-no-default-features
125+
language: system
126+
entry: cargo test --no-default-features --package stackable-operator-derive
127+
stages: [pre-commit, pre-merge-commit]
128+
pass_filenames: false
129+
files: \.rs$|Cargo\.(toml|lock)
130+
131+
- id: cargo-test-stackable-shared-no-default-features
132+
name: cargo-test-stackable-shared-no-default-features
133+
language: system
134+
entry: cargo test --no-default-features --package stackable-shared
135+
stages: [pre-commit, pre-merge-commit]
136+
pass_filenames: false
137+
files: \.rs$|Cargo\.(toml|lock)
138+
139+
- id: cargo-test-stackable-telemetry-no-default-features
140+
name: cargo-test-stackable-telemetry-no-default-features
141+
language: system
142+
entry: cargo test --no-default-features --package stackable-telemetry
143+
stages: [pre-commit, pre-merge-commit]
144+
pass_filenames: false
145+
files: \.rs$|Cargo\.(toml|lock)
146+
147+
- id: cargo-test-stackable-versioned-no-default-features
148+
name: cargo-test-stackable-versioned-no-default-features
149+
language: system
150+
entry: cargo test --no-default-features --package stackable-versioned
151+
stages: [pre-commit, pre-merge-commit]
152+
pass_filenames: false
153+
files: \.rs$|Cargo\.(toml|lock)
154+
155+
- id: cargo-test-stackable-versioned-macros-no-default-features
156+
name: cargo-test-stackable-versioned-macros-no-default-features
157+
language: system
158+
entry: cargo test --no-default-features --package stackable-versioned-macros
159+
stages: [pre-commit, pre-merge-commit]
160+
pass_filenames: false
161+
files: \.rs$|Cargo\.(toml|lock)
162+
163+
- id: cargo-test-stackable-webhook-no-default-features
164+
name: cargo-test-stackable-webhook-no-default-features
165+
language: system
166+
entry: cargo test --no-default-features --package stackable-webhook
167+
stages: [pre-commit, pre-merge-commit]
168+
pass_filenames: false
169+
files: \.rs$|Cargo\.(toml|lock)
170+
74171
- id: cargo-rustfmt
75172
name: cargo-rustfmt
76173
language: system

Cargo.lock

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

crates/stackable-operator/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Added two new crate features: `crds` and `kube-ws` ([#1162]).
10+
11+
### Fixed
12+
13+
- BREAKING: Fix compilation failures when not enabling default features ([#1162]).
14+
This is achieved by removing the `clap`, `telemetry` and `versioned` features, which were previously enabled by default.
15+
They have been removed as the stackable-operator code actually always requires them.
16+
17+
[#1162]: https://github.com/stackabletech/operator-rs/pull/1162
18+
719
## [0.106.2] - 2026-02-26
820

921
### Changed

crates/stackable-operator/Cargo.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@ edition.workspace = true
88
repository.workspace = true
99

1010
[features]
11-
full = ["certs", "telemetry", "versioned", "time", "webhook", "clap"]
12-
default = ["telemetry", "versioned", "clap"]
11+
default = ["crds"]
12+
full = ["crds", "certs", "time", "webhook", "kube-ws"]
1313

14-
clap = []
14+
crds = ["dep:stackable-versioned"]
1515
certs = ["dep:stackable-certs"]
16-
telemetry = ["dep:stackable-telemetry"]
1716
time = ["stackable-shared/time"]
18-
versioned = ["dep:stackable-versioned"]
1917
webhook = ["dep:stackable-webhook"]
18+
kube-ws = ["kube/ws"]
2019

2120
[dependencies]
2221
stackable-certs = { path = "../stackable-certs", optional = true }
2322
stackable-operator-derive = { path = "../stackable-operator-derive" }
24-
stackable-shared = { path = "../stackable-shared", features = ["time", "jiff"] }
25-
stackable-telemetry = { path = "../stackable-telemetry", optional = true, features = ["clap"] }
23+
stackable-shared = { path = "../stackable-shared", features = ["jiff"] }
24+
stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"] }
2625
stackable-versioned = { path = "../stackable-versioned", optional = true }
2726
stackable-webhook = { path = "../stackable-webhook", optional = true }
2827

crates/stackable-operator/src/cluster_resources.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use crate::{
3636
ResourceRequirementsExt, ResourceRequirementsType,
3737
},
3838
},
39-
crd::listener,
4039
deep_merger::{self, ObjectOverrides},
4140
kvp::{
4241
Label, LabelError, Labels,
@@ -221,7 +220,8 @@ impl ClusterResource for Service {}
221220
impl ClusterResource for ServiceAccount {}
222221
impl ClusterResource for RoleBinding {}
223222
impl ClusterResource for PodDisruptionBudget {}
224-
impl ClusterResource for listener::v1alpha1::Listener {}
223+
#[cfg(feature = "crds")]
224+
impl ClusterResource for crate::crd::listener::v1alpha1::Listener {}
225225

226226
impl ClusterResource for Job {
227227
fn pod_spec(&self) -> Option<&PodSpec> {
@@ -670,6 +670,13 @@ impl<'a> ClusterResources<'a> {
670670
///
671671
/// * `client` - The client which is used to access Kubernetes
672672
pub async fn delete_orphaned_resources(self, client: &Client) -> Result<()> {
673+
// We can only delete Listeners in case the "crds" feature is enabled, otherwise it's a NOP.
674+
#[cfg(feature = "crds")]
675+
let delete_listeners = self
676+
.delete_orphaned_resources_of_kind::<crate::crd::listener::v1alpha1::Listener>(client);
677+
#[cfg(not(feature = "crds"))]
678+
let delete_listeners = async { Ok(()) };
679+
673680
tokio::try_join!(
674681
self.delete_orphaned_resources_of_kind::<Service>(client),
675682
self.delete_orphaned_resources_of_kind::<StatefulSet>(client),
@@ -680,7 +687,7 @@ impl<'a> ClusterResources<'a> {
680687
self.delete_orphaned_resources_of_kind::<ServiceAccount>(client),
681688
self.delete_orphaned_resources_of_kind::<RoleBinding>(client),
682689
self.delete_orphaned_resources_of_kind::<PodDisruptionBudget>(client),
683-
self.delete_orphaned_resources_of_kind::<listener::v1alpha1::Listener>(client),
690+
delete_listeners
684691
)?;
685692

686693
Ok(())

crates/stackable-operator/src/eos/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,34 @@ use tracing::{Level, instrument};
99
///
1010
/// Additionally, this struct can be used as operator CLI arguments. This functionality is only
1111
/// available if the feature `clap` is enabled.
12-
#[cfg_attr(feature = "clap", derive(clap::Args))]
13-
#[derive(Debug, PartialEq, Eq)]
12+
#[derive(Debug, PartialEq, Eq, clap::Args)]
1413
pub struct EndOfSupportOptions {
1514
/// The end-of-support check mode. Currently, only "offline" is supported.
16-
#[cfg_attr(feature = "clap", arg(
15+
#[arg(
1716
long = "eos-check-mode",
1817
env = "EOS_CHECK_MODE",
1918
default_value_t = EndOfSupportCheckMode::default(),
2019
value_enum
21-
))]
20+
)]
2221
pub check_mode: EndOfSupportCheckMode,
2322

2423
/// The interval in which the end-of-support check should run.
25-
#[cfg_attr(feature = "clap", arg(
24+
#[arg(
2625
long = "eos-interval",
2726
env = "EOS_INTERVAL",
2827
default_value_t = Self::default_interval()
29-
))]
28+
)]
3029
pub interval: Duration,
3130

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

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

@@ -55,8 +54,7 @@ impl EndOfSupportOptions {
5554
}
5655
}
5756

58-
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
59-
#[derive(Clone, Debug, Default, PartialEq, Eq)]
57+
#[derive(Clone, Debug, Default, PartialEq, Eq, clap::ValueEnum)]
6058
pub enum EndOfSupportCheckMode {
6159
#[default]
6260
Offline,

crates/stackable-operator/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod commons;
1414
pub mod config;
1515
pub mod constants;
1616
pub mod cpu;
17+
#[cfg(feature = "crds")]
1718
pub mod crd;
1819
pub mod deep_merger;
1920
pub mod eos;
@@ -42,9 +43,8 @@ pub use schemars;
4243
pub use stackable_certs as certs;
4344
pub use stackable_shared as shared;
4445
pub use stackable_shared::{crd::CustomResourceExt, yaml::YamlSchema};
45-
#[cfg(feature = "telemetry")]
4646
pub use stackable_telemetry as telemetry;
47-
#[cfg(feature = "versioned")]
47+
#[cfg(feature = "crds")]
4848
pub use stackable_versioned as versioned;
4949
#[cfg(feature = "webhook")]
5050
pub use stackable_webhook as webhook;

crates/stackable-operator/src/utils/cluster_info.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,21 @@ pub struct KubernetesClusterInfo {
1515
pub cluster_domain: DomainName,
1616
}
1717

18-
#[cfg_attr(
19-
feature = "clap",
20-
derive(clap::Parser),
21-
command(next_help_heading = "Cluster Options")
22-
)]
18+
#[derive(clap::Parser)]
19+
#[command(next_help_heading = "Cluster Options")]
2320
#[derive(Debug, PartialEq, Eq)]
2421
pub struct KubernetesClusterInfoOptions {
2522
/// Kubernetes cluster domain, usually this is `cluster.local`.
2623
// We are not using a default value here, as we query the cluster if it is not specified.
27-
#[cfg_attr(feature = "clap", arg(long, env))]
24+
#[arg(long, env)]
2825
pub kubernetes_cluster_domain: Option<DomainName>,
2926

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

0 commit comments

Comments
 (0)