Closed notjames closed 1 year ago
kube
needs to depend on an explicit version of k8s-openapi
(without features). Your kube
version is 0.52 which pulls in k8s-openapi
0.11 (which you haven't selected versions for).
You need to upgrade to the latest kube release if you want to use k8s-openapi
0.15
looking more closely at your toml, you are actually pulling in kube components twice (at different versions):
kube = { version = "~0.70", default-features = true, features = ["runtime", "derive"] }
k8s-openapi = { version = "~0.15", features = ["v1_21"] }
kube-derive = "~0.52"
kube-runtime = "~0.52"
this is probably a mistake, you probably want either:
kube = { version = "~0.70", features = ["runtime", "derive"] }
k8s-openapi = { version = "~0.14", features = ["v1_21"] }
or
kube = { version = "~0.73", features = ["runtime", "derive"] }
k8s-openapi = { version = "~0.15", features = ["v1_21"] }
and then refer to the exports from kube-runtime/kube-derive via the entry point crate.
@clux thanks for your assistance. I've tried both configurations stated above and neither works, unfortunately.
I even tried removing an entry for k8s-openapi with hopes that kube
would pull it in automatically (not sure that would work or not), but that failed.
This is from using
kube = { version = "~0.73", features = ["runtime", "derive"] }
k8s-openapi = { version = "~0.15", features = ["v1_21"] }
here:
$ cargo clean
# edited Cargo.toml
$ cargo build
...
...
Compiling ahash v0.7.6
error: failed to run custom build command for `k8s-openapi v0.11.0`
Caused by:
process didn't exit successfully: `/home/me/projects/my/projects/k8s-operators/cred-rotator/operator/target/debug/build/k8s-openapi-4ce909515dc1cfbe/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at '
None of the v1_* features are enabled on the k8s-openapi crate.
The k8s-openapi crate requires a feature to be enabled to indicate which version of Kubernetes it should support.
If you're using k8s-openapi in a binary crate, enable the feature corresponding to the minimum version of API server that you want to support. It may be possible that your binary crate does not directly depend on k8s-openapi. In this case, add a dependency on k8s-openapi, then enable the corresponding feature.
If you're using k8s-openapi in a library crate, add a dev-dependency on k8s-openapi and enable one of the features there. This way the feature will be enabled when buildings tests and examples of your library, but not when building the library itself. It may be possible that your library crate does not directly depend on k8s-openapi. In this case, add a dev-dependency on k8s-openapi, then enable the corresponding feature.
Library crates *must not* enable any features in their direct dependency on k8s-openapi, only in their dev-dependency. The choice of Kubernetes version to support should be left to the final binary crate, so only the binary crate should enable a specific feature. If library crates also enable features, it can cause multiple features to be enabled simultaneously, which k8s-openapi does not support.
If you want to restrict your library crate to support only a single specific version or range of versions of Kubernetes, please use the k8s_* version-specific macros to emit different code based on which feature gets enabled in the end.', /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/k8s-openapi-0.11.0/build.rs:9:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Noticing that the version failed for build command for k8s-openapi v0.11.0
, which confuses me. Maybe I'm missing a step before attempting to build?
Something in your dependency tree is pulling in an older version of k8s-openapi
. Try to look at cargo tree -i k8s-openapi
to see what that is.
As the error tells you, you still have k8s-openapi 0.11.0 somewhere in your lockfile, so read it to figure out what's pulling it in.
great pointers...I had to tweak the arguments a little for the cargo tree
command...
✦ at 13:01:28 ❯ cargo tree -i k8s-openapi:0.11.0
warning: Patch `openssl v0.9.24 (https://github.com/ishitatsuyuki/rust-openssl?branch=0.9.x#3b73dda4)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
k8s-openapi v0.11.0
├── kube v0.52.0
│ └── kube-runtime v0.52.0
│ └── credrotate-k8s-operator v0.0.1 (/home/me/projects/src/my/projects/k8s-operators/cred-rotator/operator)
└── kube-runtime v0.52.0 (*)
└>jimconn on vmlinux in k8s-operators/cred-rotator/operator ・
✦ at 13:01:58 ❯ cargo tree -i k8s-openapi:0.15.0
warning: Patch `openssl v0.9.24 (https://github.com/ishitatsuyuki/rust-openssl?branch=0.9.x#3b73dda4)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
k8s-openapi v0.15.0
├── credrotate-k8s-operator v0.0.1 (/home/me/projects/src/my/projects/k8s-operators/cred-rotator/operator)
├── kube v0.73.0
│ └── credrotate-k8s-operator v0.0.1 (/home/me/projects/src/my/projects/k8s-operators/cred-rotator/operator)
├── kube-client v0.73.0
│ ├── kube v0.73.0 (*)
│ └── kube-runtime v0.73.0
│ └── kube v0.73.0 (*)
├── kube-core v0.73.0
│ ├── kube v0.73.0 (*)
│ └── kube-client v0.73.0 (*)
└── kube-runtime v0.73.0 (*)
Looking at this output, it seems like kube-runtime
is my culprit.
great pointers...I had to tweak the arguments a little for the
cargo tree
command...✦ at 13:01:28 ❯ cargo tree -i k8s-openapi:0.11.0 warning: Patch `openssl v0.9.24 (https://github.com/ishitatsuyuki/rust-openssl?branch=0.9.x#3b73dda4)` was not used in the crate graph. Check that the patched package version and available features are compatible with the dependency requirements. If the patch has a different version from what is locked in the Cargo.lock file, run `cargo update` to use the new version. This may also occur with an optional dependency that is not enabled. k8s-openapi v0.11.0 ├── kube v0.52.0 │ └── kube-runtime v0.52.0 │ └── credrotate-k8s-operator v0.0.1 (/home/me/projects/src/my/projects/k8s-operators/cred-rotator/operator) └── kube-runtime v0.52.0 (*) └>jimconn on vmlinux in k8s-operators/cred-rotator/operator ・ ✦ at 13:01:58 ❯ cargo tree -i k8s-openapi:0.15.0 warning: Patch `openssl v0.9.24 (https://github.com/ishitatsuyuki/rust-openssl?branch=0.9.x#3b73dda4)` was not used in the crate graph. Check that the patched package version and available features are compatible with the dependency requirements. If the patch has a different version from what is locked in the Cargo.lock file, run `cargo update` to use the new version. This may also occur with an optional dependency that is not enabled. k8s-openapi v0.15.0 ├── credrotate-k8s-operator v0.0.1 (/home/me/projects/src/my/projects/k8s-operators/cred-rotator/operator) ├── kube v0.73.0 │ └── credrotate-k8s-operator v0.0.1 (/home/me/projects/src/my/projects/k8s-operators/cred-rotator/operator) ├── kube-client v0.73.0 │ ├── kube v0.73.0 (*) │ └── kube-runtime v0.73.0 │ └── kube v0.73.0 (*) ├── kube-core v0.73.0 │ ├── kube v0.73.0 (*) │ └── kube-client v0.73.0 (*) └── kube-runtime v0.73.0 (*)
Looking at this output, it seems like
kube-runtime
is my culprit.
OK, this worked:
kube = { version = "~0.73", features = ["runtime", "derive"] }
k8s-openapi = { version = "~0.15", features = ["v1_21"] }
kube-derive = "~0.73"
kube-runtime = "~0.73"
Thanks guys! This was a good lesson learner.
I'll tweak the error to mention the possibility of multiple versions, and to suggest the cargo tree
invocation.
New to Rust - Trying to build a k8s operator. When testing what I have so far, attempting to build causes the above-mentioned error. Thing is, my
Cargo.toml
does specify the feature. I'm building abin
. A bit of digging and I notice that the build is compiling two different versions ofk8s-openapi
(v0.14.0 and v0.11.0 - and I'm requesting to use 0.15.0 in my Cargo) so I'm assuming a dep is doing something wrong... I've been through https://docs.rs/k8s-openapi/latest/k8s_openapi/#crate-features and as far as I can tell, I'm doing this right, but I may be missing something.My
Cargo.toml
:The build error:
Neither version in this build is the one I'm specifying in
Cargo.toml
so I'm assuming something is pulling in deps from upstream, but if that's the case, I don't know how I would fix myCargo.toml
in a way that would affect the build for those deps.Reading around indicates that k8s-openapi is difficult at times. A backtrace shows: