Skip to content

fix: Fix compilation failures when not enabling default features#1162

Merged
sbernauer merged 13 commits intomainfrom
fix/crate-features
Mar 9, 2026
Merged

fix: Fix compilation failures when not enabling default features#1162
sbernauer merged 13 commits intomainfrom
fix/crate-features

Conversation

@sbernauer
Copy link
Member

@sbernauer sbernauer commented Feb 27, 2026

Needed for stackabletech/containerdebug#52

Problem

Some of our crates (notable stackable-operator) produce lot's of compilation errors when being pulled in with no default features, e.g.

stackable-operator = { git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.106.2", default-features = false }

produces error: could not compile stackable-operator (lib) due to 237 previous errors

stackable-telemetry is even worse, as it is broken using default features:

stackable-telemetry = {git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.106.2" }

causes

error[E0432]: unresolved import `clap`
  --> /home/sbernauer/.cargo/git/checkouts/operator-rs-10d25a4c6a1c49cf/f9b117c/crates/stackable-telemetry/src/tracing/mod.rs:12:5
   |
12 | use clap;
   |     ^^^^ no external crate `clap`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `stackable-telemetry` (lib) due to 1 previous error

Fix

This PR fixes the stackable-operator and stackable-telemetry by making mandatory features actually mandatory.
I also added pre-commit checks to prevent this from happening again.

With this fix I can now pull in exactly what I need in containerdebug:

stackable-shared = {git = "https://github.com/stackabletech/operator-rs", branch = "fix/crate-features" }
stackable-telemetry = {git = "https://github.com/stackabletech/operator-rs", branch = "fix/crate-features", features = ["clap"] }

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

@sbernauer sbernauer changed the title fix: Fix multiple compilation failures when not enabling default features fix: Fix compilation failures when not enabling default features Feb 27, 2026
@sbernauer sbernauer marked this pull request as ready for review February 27, 2026 07:47
@sbernauer sbernauer self-assigned this Feb 27, 2026
@sbernauer sbernauer moved this to Development: Waiting for Review in Stackable Engineering Feb 27, 2026
Copy link
Member

@Techassi Techassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking this for now, because I think this is the wrong approach to this issue.

@Techassi
Copy link
Member

Techassi commented Mar 2, 2026

These changes unblock containerdebug to use default-features = false: https://github.com/stackabletech/operator-rs/tree/fix/features

I will do some research on how we can better detect this kind of stuff in the future. https://github.com/obi1kenobi/cargo-semver-checks might be the right tool for this job (and many others).

@sbernauer
Copy link
Member Author

I quickly tried cargo test --no-default-features --package stackable-operator in your branch, looks like the problems aren't fixed yet. cargo test --no-default-features --package stackable-telemetry also doesn't work.
Also we should really have a CI action to prevent this in the future.

My PR also simplified the features quite a bit, it e.g. removed the clap feature from stackable-operator. Having it on stackable-telemetry makes sense, so I kept it, but stackable-operator always pulls in the clap crate, so from my perspective there is nothing to optimize for, it just complicates lot's of things. I also don't really like the idea that CLI flags depend on a rather technical Rust crate feature. operator-templating and the helm-charts don't know know and/or care about the Rust flag. They add a --eos-disabled (or similar), that works on 9 operators but fails on 3.

This PR solves all to me known problems and reduces complexity and is less error-prone. It also adds CI checks. So I personally would prefer to move along with it (happy to do some tweaks if needed).

@Techassi Techassi moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Mar 5, 2026
@sbernauer sbernauer requested a review from Techassi March 6, 2026 09:33
Copy link
Member

@Techassi Techassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much ready to go, just three minor comments.

@sbernauer sbernauer requested a review from Techassi March 9, 2026 09:36
This reverts commit 1e0cde4.

It failed compilation, as it always compiles both branches, which fails
when the crds feature is not enabled.
@sbernauer sbernauer added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 992b3b2 Mar 9, 2026
5 checks passed
@sbernauer sbernauer deleted the fix/crate-features branch March 9, 2026 10:48
@Techassi Techassi moved this from Development: In Review to Development: Done in Stackable Engineering Mar 9, 2026
@lfrancke lfrancke moved this from Development: Done to Done in Stackable Engineering Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants