Skip to content

Commit e5d78ea

Browse files
Update dependencies
* Bump clap to 4.0.10 * Bump clevercloud-sdk to 0.10.9 * Bump kube to 0.75.0 * Bump kube-derieve to 0.75.0 * Bump kube-runtime to 0.75.0 * Bump k8s-openapi to 0.16.0 * Bump opentelemetry to 0.18.0 * Bump opentelemetry-jaeger to 0.17.0 * Bump schemars to 0.8.11 * Bump serde to 1.0.145 * Bump serde_yaml to 0.9.13 * Bump thiserror to 1.0.37 * Bump tokio to 1.21.2 * Bump tracing to 0.1.37 * Bump tracing-subscriber to 0.3.16 * Bump tracing-opentelemetry to 0.18.0 Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
1 parent a971da5 commit e5d78ea

File tree

11 files changed

+374
-267
lines changed

11 files changed

+374
-267
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,56 @@ keywords = ["kubernetes", "operator", "clevercloud", "openshift"]
1616
async-trait = "^0.1.57"
1717
base64 = "^0.13.0"
1818
chrono = { version = "^0.4.22", default-features = false }
19-
clap = { version = "^3.2.20", features = ["derive"] }
20-
clevercloud-sdk = { version = "^0.10.8", features = ["jsonschemas"] }
19+
clap = { version = "^4.0.10", features = ["derive"] }
20+
clevercloud-sdk = { version = "^0.10.9", features = ["jsonschemas"] }
2121
config = "^0.13.2"
2222
futures = "^0.3.24"
2323
hostname = "^0.3.1"
2424
hyper = { version = "^0.14.20", features = ["server", "tcp", "http1"] }
2525
json-patch = "^0.2.6"
26-
kube = { version = "^0.74.0", default-features = false, features = [
26+
kube = { version = "^0.75.0", default-features = false, features = [
2727
"client",
2828
"rustls-tls",
2929
"ws",
3030
"gzip",
3131
"derive",
3232
"jsonpatch",
3333
] }
34-
kube-derive = "^0.74.0"
35-
kube-runtime = "^0.74.0"
36-
k8s-openapi = { version = "^0.15.0", default-features = false, features = [
34+
kube-derive = "^0.75.0"
35+
kube-runtime = "^0.75.0"
36+
k8s-openapi = { version = "^0.16.0", default-features = false, features = [
3737
"v1_21",
3838
] }
3939
lazy_static = { version = "^1.4.0", optional = true }
40-
opentelemetry = { version = "^0.17.0", features = [
40+
opentelemetry = { version = "^0.18.0", features = [
4141
"rt-tokio",
4242
], optional = true }
43-
opentelemetry-jaeger = { version = "^0.16.0", features = [
43+
opentelemetry-jaeger = { version = "^0.17.0", features = [
4444
"rt-tokio",
4545
"collector_client",
4646
], optional = true }
4747
paw = "^1.0.0"
4848
prometheus = { version = "^0.13.2", optional = true }
49-
schemars = { version = "^0.8.10", features = [
49+
schemars = { version = "^0.8.11", features = [
5050
"chrono",
5151
"indexmap1",
5252
"uuid1",
5353
"bytes",
5454
"url",
5555
] }
5656
sentry = { version = "^0.27.0", optional = true }
57-
serde = { version = "1.0.144", features = ["derive"] }
57+
serde = { version = "1.0.145", features = ["derive"] }
5858
serde_json = { version = "^1.0.85", features = [
5959
"preserve_order",
6060
"float_roundtrip",
6161
] }
62-
serde_yaml = "^0.9.11"
62+
serde_yaml = "^0.9.13"
6363
tempfile = "^3.3.0"
64-
thiserror = "^1.0.34"
65-
tokio = { version = "^1.21.0", features = ["full"] }
66-
tracing = "^0.1.36"
67-
tracing-subscriber = { version = "^0.3.15", default-features = false, features = ["std", "ansi", "tracing-log"] }
68-
tracing-opentelemetry = { version = "^0.17.4", optional = true }
64+
thiserror = "^1.0.37"
65+
tokio = { version = "^1.21.2", features = ["full"] }
66+
tracing = "^0.1.37"
67+
tracing-subscriber = { version = "^0.3.16", default-features = false, features = ["std", "ansi", "tracing-log"] }
68+
tracing-opentelemetry = { version = "^0.18.0", optional = true }
6969

7070
[features]
7171
default = [

src/cmd/crd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ pub enum CustomResourceDefinitionError {
6666

6767
#[derive(Subcommand, Clone, Debug)]
6868
pub enum CustomResourceDefinition {
69-
/// View custom resource definition
70-
#[clap(name = "view", aliases = &["v"])]
69+
#[clap(name = "view", aliases = &["v"], about = "View custom resource definition")]
7170
View {
7271
#[clap(name = "custom-resource")]
7372
custom_resource: Option<CustomResource>,

src/cmd/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ pub enum Error {
7272

7373
#[derive(Subcommand, Clone, Debug)]
7474
pub enum Command {
75-
/// Interact with custom resource definition
76-
#[clap(name = "custom-resource-definition", aliases= &["crd"], subcommand)]
75+
#[clap(name = "custom-resource-definition", aliases= &["crd"], subcommand, about = "Interact with custom resource definition")]
7776
CustomResourceDefinition(crd::CustomResourceDefinition),
7877
}
7978

src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,20 @@ pub(crate) async fn main(args: Args) -> Result<(), Error> {
109109
);
110110
global::set_text_map_propagator(Propagator::new());
111111

112-
let mut builder = opentelemetry_jaeger::new_pipeline()
113-
.with_collector_endpoint(config.jaeger.endpoint.to_owned())
112+
let mut builder = opentelemetry_jaeger::new_collector_pipeline()
113+
.with_endpoint(config.jaeger.endpoint.to_owned())
114114
.with_service_name(env!("CARGO_PKG_NAME"));
115115

116116
if let Some(user) = &config.jaeger.user {
117-
builder = builder.with_collector_username(user);
117+
builder = builder.with_username(user);
118118
}
119119

120120
if let Some(password) = &config.jaeger.password {
121-
builder = builder.with_collector_password(password);
121+
builder = builder.with_password(password);
122122
}
123123

124-
let layer = tracing_opentelemetry::layer().with_tracer(builder.install_simple()?);
124+
let layer = tracing_opentelemetry::layer()
125+
.with_tracer(builder.install_batch(opentelemetry::runtime::Tokio)?);
125126

126127
tracing::subscriber::set_global_default(Registry::default().with(layer))?;
127128
}

src/svc/k8s/finalizer.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
66
use std::fmt::Debug;
77

8+
use k8s_openapi::NamespaceResourceScope;
89
use kube::Resource;
910

1011
#[cfg_attr(feature = "trace", tracing::instrument)]
1112
/// returns if there is the given finalizer on the resource
1213
pub fn contains<T>(obj: &T, finalizer: &str) -> bool
1314
where
14-
T: Resource + Debug,
15+
T: Resource<Scope = NamespaceResourceScope> + Debug,
1516
{
1617
if let Some(finalizers) = &obj.meta().finalizers {
1718
finalizers.iter().any(|f| finalizer == f)
@@ -24,9 +25,9 @@ where
2425
/// add finalizer to the resource
2526
pub fn add<T>(mut obj: T, finalizer: &str) -> T
2627
where
27-
T: Resource + Debug,
28+
T: Resource<Scope = NamespaceResourceScope> + Debug,
2829
{
29-
if (&obj.meta().finalizers).is_some() {
30+
if obj.meta().finalizers.is_some() {
3031
if !contains(&obj, finalizer) {
3132
obj.meta_mut().finalizers.as_mut().map(|finalizers| {
3233
finalizers.push(finalizer.into());
@@ -44,7 +45,7 @@ where
4445
/// remove finalizer from the resource
4546
pub fn remove<T>(mut obj: T, finalizer: &str) -> T
4647
where
47-
T: Resource + Debug,
48+
T: Resource<Scope = NamespaceResourceScope> + Debug,
4849
{
4950
if let Some(finalizers) = &obj.meta().finalizers {
5051
obj.meta_mut().finalizers = Some(

src/svc/k8s/mod.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{error::Error, fmt::Debug, hash::Hash, sync::Arc, time::Duration};
88
use async_trait::async_trait;
99

1010
use futures::{StreamExt, TryStreamExt};
11+
use k8s_openapi::NamespaceResourceScope;
1112
use kube::{CustomResourceExt, Resource, ResourceExt};
1213
use kube_runtime::{
1314
controller::{self, Action},
@@ -118,7 +119,7 @@ impl Context {
118119
/// controller [`Controller<T>`]
119120
pub trait ControllerBuilder<T>
120121
where
121-
T: Resource + Clone + Debug,
122+
T: Resource<Scope = NamespaceResourceScope> + Clone + Debug,
122123
<T as Resource>::DynamicType: Eq + Hash,
123124
{
124125
/// returns a new created kubernetes controller
@@ -133,7 +134,14 @@ where
133134
#[async_trait]
134135
pub trait Reconciler<T>
135136
where
136-
T: ResourceExt + CustomResourceExt + Debug + Clone + Send + Sync + 'static,
137+
T: Resource<Scope = NamespaceResourceScope>
138+
+ ResourceExt
139+
+ CustomResourceExt
140+
+ Debug
141+
+ Clone
142+
+ Send
143+
+ Sync
144+
+ 'static,
137145
{
138146
type Error: Error + Send + Sync;
139147

@@ -144,7 +152,7 @@ where
144152
async fn delete(ctx: Arc<Context>, obj: Arc<T>) -> Result<(), Self::Error>;
145153

146154
/// returns a [`Action`] to perform following the given error
147-
fn retry(err: &Self::Error, _ctx: Arc<Context>) -> Action {
155+
fn retry(_obj: Arc<T>, err: &Self::Error, _ctx: Arc<Context>) -> Action {
148156
// Implements a basic reconciliation which always re-schedule the event
149157
// 500 ms later
150158
trace!("Requeue failed reconciliation for 500ms, {}", err);
@@ -240,7 +248,15 @@ where
240248
#[async_trait]
241249
pub trait Watcher<T>: ControllerBuilder<T> + Reconciler<T>
242250
where
243-
T: DeserializeOwned + ResourceExt + CustomResourceExt + Clone + Debug + Send + Sync + 'static,
251+
T: Resource<Scope = NamespaceResourceScope>
252+
+ ResourceExt
253+
+ CustomResourceExt
254+
+ DeserializeOwned
255+
+ Clone
256+
+ Debug
257+
+ Send
258+
+ Sync
259+
+ 'static,
244260
<T as Resource>::DynamicType: Unpin + Eq + Hash + Clone + Debug + Send + Sync,
245261
Self: Send + Sync + 'static,
246262
<Self as Reconciler<T>>::Error: WatcherError + Send + Sync,
@@ -320,7 +336,15 @@ where
320336
/// Blanklet implementation for [`Watcher<T>`]
321337
impl<T, U> Watcher<T> for U
322338
where
323-
T: DeserializeOwned + ResourceExt + CustomResourceExt + Clone + Debug + Send + Sync + 'static,
339+
T: Resource<Scope = NamespaceResourceScope>
340+
+ ResourceExt
341+
+ CustomResourceExt
342+
+ DeserializeOwned
343+
+ Clone
344+
+ Debug
345+
+ Send
346+
+ Sync
347+
+ 'static,
324348
<T as Resource>::DynamicType: Unpin + Eq + Hash + Clone + Debug + Send + Sync,
325349
U: Reconciler<T> + ControllerBuilder<T>,
326350
U::Error: WatcherError + Send + Sync,

src/svc/k8s/recorder/event.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use chrono::Utc;
99
use k8s_openapi::{
1010
api::core::v1::{Event, EventSource},
1111
apimachinery::pkg::apis::meta::v1::{MicroTime, Time},
12+
NamespaceResourceScope,
1213
};
13-
use kube::{api::ObjectMeta, CustomResourceExt, ResourceExt};
14+
use kube::{api::ObjectMeta, CustomResourceExt, Resource, ResourceExt};
1415

1516
use crate::svc::k8s::{recorder::Level, resource};
1617

@@ -26,7 +27,7 @@ pub const EVENT_FOR: &str = "for";
2627
/// create a new event from the given parameters
2728
pub fn new<T, U>(obj: &T, kind: &Level, action: &U, message: &str) -> Event
2829
where
29-
T: ResourceExt + CustomResourceExt + Debug,
30+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
3031
U: ToString + Debug,
3132
{
3233
let now = Utc::now();

src/svc/k8s/recorder/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use std::{
1313
str::FromStr,
1414
};
1515

16-
use k8s_openapi::api::core::v1::Event;
17-
use kube::{Client, CustomResourceExt, ResourceExt};
16+
use k8s_openapi::{api::core::v1::Event, NamespaceResourceScope};
17+
use kube::{Client, CustomResourceExt, Resource, ResourceExt};
1818
use tracing::debug;
1919
#[cfg(feature = "trace")]
2020
use tracing::Instrument;
@@ -35,8 +35,9 @@ pub enum Error {
3535
// -----------------------------------------------------------------------------
3636
// Level enumeration
3737

38-
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
38+
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug, Default)]
3939
pub enum Level {
40+
#[default]
4041
Warning,
4142
Normal,
4243
}
@@ -95,7 +96,7 @@ pub async fn record<T, U>(
9596
message: &str,
9697
) -> Result<Event, kube::Error>
9798
where
98-
T: ResourceExt + CustomResourceExt + Debug,
99+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
99100
U: ToString + Debug,
100101
{
101102
irecord(client, obj, kind, action, message).await
@@ -111,7 +112,7 @@ pub async fn record<T, U>(
111112
message: &str,
112113
) -> Result<Event, kube::Error>
113114
where
114-
T: ResourceExt + CustomResourceExt + Debug,
115+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
115116
U: ToString + Debug,
116117
{
117118
irecord(client, obj, kind, action, message)
@@ -128,7 +129,7 @@ async fn irecord<T, U>(
128129
message: &str,
129130
) -> Result<Event, kube::Error>
130131
where
131-
T: ResourceExt + CustomResourceExt + Debug,
132+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
132133
U: ToString + Debug,
133134
{
134135
debug!(
@@ -150,7 +151,7 @@ pub async fn normal<T, U>(
150151
message: &str,
151152
) -> Result<Event, kube::Error>
152153
where
153-
T: ResourceExt + CustomResourceExt + Debug,
154+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
154155
U: ToString + Debug,
155156
{
156157
inormal(client, obj, action, message).await
@@ -165,7 +166,7 @@ pub async fn normal<T, U>(
165166
message: &str,
166167
) -> Result<Event, kube::Error>
167168
where
168-
T: ResourceExt + CustomResourceExt + Debug,
169+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
169170
U: ToString + Debug,
170171
{
171172
inormal(client, obj, action, message)
@@ -181,7 +182,7 @@ async fn inormal<T, U>(
181182
message: &str,
182183
) -> Result<Event, kube::Error>
183184
where
184-
T: ResourceExt + CustomResourceExt + Debug,
185+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
185186
U: ToString + Debug,
186187
{
187188
record(client, obj, &Level::Normal, action, message).await
@@ -196,7 +197,7 @@ pub async fn warning<T, U>(
196197
message: &str,
197198
) -> Result<Event, kube::Error>
198199
where
199-
T: ResourceExt + CustomResourceExt + Debug,
200+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
200201
U: ToString + Debug,
201202
{
202203
iwarning(client, obj, action, message).await
@@ -211,7 +212,7 @@ pub async fn warning<T, U>(
211212
message: &str,
212213
) -> Result<Event, kube::Error>
213214
where
214-
T: ResourceExt + CustomResourceExt + Debug,
215+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
215216
U: ToString + Debug,
216217
{
217218
iwarning(client, obj, action, message)
@@ -227,7 +228,7 @@ async fn iwarning<T, U>(
227228
message: &str,
228229
) -> Result<Event, kube::Error>
229230
where
230-
T: ResourceExt + CustomResourceExt + Debug,
231+
T: Resource<Scope = NamespaceResourceScope> + ResourceExt + CustomResourceExt + Debug,
231232
U: ToString + Debug,
232233
{
233234
record(client, obj, &Level::Warning, action, message).await

0 commit comments

Comments
 (0)