Skip to content

Commit 04df951

Browse files
Prepare release 0.7.1 (#224)
* chore(deps): Bump opentelemetry_sdk from 0.28.0 to 0.29.0 (#223) Bumps [opentelemetry_sdk](https://github.com/open-telemetry/opentelemetry-rust) from 0.28.0 to 0.29.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases) - [Commits](open-telemetry/opentelemetry-rust@opentelemetry_sdk-0.28.0...opentelemetry_sdk-0.29.0) --- updated-dependencies: - dependency-name: opentelemetry_sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Danil-Grigorev <[email protected]> * chore(deps): Bump opentelemetry-otlp from 0.28.0 to 0.29.0 (#222) Bumps [opentelemetry-otlp](https://github.com/open-telemetry/opentelemetry-rust) from 0.28.0 to 0.29.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases) - [Commits](open-telemetry/opentelemetry-rust@opentelemetry-otlp-0.28.0...opentelemetry-otlp-0.29.0) --- updated-dependencies: - dependency-name: opentelemetry-otlp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Danil-Grigorev <[email protected]> * Simplify dynamic watch setup version separation (#219) * Drop finalizer on ClusterGroup - Move BundleNamespaceMapping cleanup into Class reconciler - Remove finalizer from ClusterGroup, causing issues - Refactor controllers to use stable API (duplicate cache for ClusterGroup) - Fix hot loop on Helm install due to chart version compare issue Signed-off-by: Danil-Grigorev <[email protected]> * Simplify dynamic watch setup version separation Current setup allows to use functionality available for k/k 1.32+ already with streaming_list() option by piggybacking type_meta population on serialization as a typed object first with k/k below 1.32. `TypeMeta` for core types in this scenario is always populated by `k8s_openapi` implementation, even though list response does omit type_meta for the inner set of objects. Main differentiator here, is that streaming_list uses only `watch`, which never omits type_meta of the resource, while regular watch setup issues `list` request to collect initial events. For the `Cluster` object defined as a `CRD`, `to_dynamic_event` performs necessary conversion with type_meta population in-place. Signed-off-by: Danil-Grigorev <[email protected]> * Implement default handling as trait extension Signed-off-by: Danil-Grigorev <[email protected]> --------- Signed-off-by: Danil-Grigorev <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Danil-Grigorev <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 17ea634 commit 04df951

File tree

12 files changed

+375
-438
lines changed

12 files changed

+375
-438
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ telemetry = ["tonic", "opentelemetry-otlp"]
3232
rand = { version = "0.9", features = ["small_rng"] }
3333
actix-web = "4.10.2"
3434
futures = "0.3.28"
35-
tokio = { version = "1.44.1", features = ["macros", "rt-multi-thread"] }
35+
tokio = { version = "1.44.1", features = ["macros", "rt-multi-thread", "process"] }
3636
k8s-openapi = { version = "0.24", features = ["latest", "schemars"] }
3737
kube = { version = "0.99.0", features = [
3838
"runtime",
@@ -52,8 +52,8 @@ tracing = "0.1.37"
5252
tracing-subscriber = { version = "0.3.19", features = ["json", "env-filter"] }
5353
tracing-opentelemetry = "0.28.0"
5454
opentelemetry = { version = "0.27.1", features = ["trace"] }
55-
opentelemetry-otlp = { version = "0.28.0", optional = true }
56-
opentelemetry_sdk = { version = "0.28.0", features = ["rt-tokio"] }
55+
opentelemetry-otlp = { version = "0.29.0", optional = true }
56+
opentelemetry_sdk = { version = "0.29.0", features = ["rt-tokio"] }
5757
tonic = { version = "0.12.3", optional = true }
5858
thiserror = "2.0.11"
5959
anyhow = "1.0.96"

src/api/capi_cluster.rs

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::BTreeMap;
22

3-
use cluster_api_rs::capi_cluster::{ClusterSpec, ClusterStatus, ClusterTopology};
3+
use cluster_api_rs::capi_cluster::{ClusterSpec, ClusterStatus};
44
use fleet_api_rs::fleet_clustergroup::{ClusterGroupSelector, ClusterGroupSpec};
55
use kube::{
66
api::{ObjectMeta, TypeMeta},
@@ -44,51 +44,37 @@ impl Cluster {
4444
pub(crate) fn to_group(self: &Cluster, config: Option<&ClusterConfig>) -> Option<ClusterGroup> {
4545
config?.apply_class_group().then_some(true)?;
4646

47-
if let cluster_api_rs::capi_cluster::ClusterSpec {
48-
topology:
49-
Some(ClusterTopology {
50-
class_namespace: Some(class_namespace),
51-
class,
52-
..
53-
}),
54-
..
55-
} = &self.spec
56-
{
57-
// Cluster groups creation for cluster class namespace are handled by ClusterClass controller
58-
if Some(class_namespace) == self.namespace().as_ref() {
59-
return None;
60-
}
47+
let class = self.cluster_class_name()?;
48+
// Cluster groups creation for cluster class namespace are handled by ClusterClass controller
49+
let class_namespace = self.cluster_class_namespace()?;
6150

62-
let labels = {
63-
let mut labels = BTreeMap::default();
64-
labels.insert(CLUSTER_CLASS_LABEL.to_string(), class.clone());
65-
labels.insert(
66-
CLUSTER_CLASS_NAMESPACE_LABEL.to_string(),
67-
class_namespace.clone(),
68-
);
69-
Some(labels)
70-
};
71-
72-
return Some(ClusterGroup {
73-
types: Some(TypeMeta::resource::<ClusterGroup>()),
74-
metadata: ObjectMeta {
75-
name: Some(format!("{class}.{class_namespace}")),
76-
namespace: self.namespace(),
77-
labels: labels.clone(),
78-
owner_references: self.owner_ref(&()).into_iter().map(Into::into).collect(),
79-
..Default::default()
80-
},
81-
spec: ClusterGroupSpec {
82-
selector: Some(ClusterGroupSelector {
83-
match_labels: labels,
84-
..Default::default()
85-
}),
86-
},
87-
..Default::default()
88-
});
89-
}
51+
let labels = {
52+
let mut labels = BTreeMap::default();
53+
labels.insert(CLUSTER_CLASS_LABEL.to_string(), class.to_string());
54+
labels.insert(
55+
CLUSTER_CLASS_NAMESPACE_LABEL.to_string(),
56+
class_namespace.to_string(),
57+
);
58+
Some(labels)
59+
};
9060

91-
None
61+
Some(ClusterGroup {
62+
types: Some(TypeMeta::resource::<ClusterGroup>()),
63+
metadata: ObjectMeta {
64+
name: Some(format!("{class}.{class_namespace}")),
65+
namespace: self.namespace(),
66+
labels: labels.clone(),
67+
owner_references: self.owner_ref(&()).into_iter().map(Into::into).collect(),
68+
..Default::default()
69+
},
70+
spec: ClusterGroupSpec {
71+
selector: Some(ClusterGroupSelector {
72+
match_labels: labels,
73+
..Default::default()
74+
}),
75+
},
76+
..Default::default()
77+
})
9278
}
9379

9480
pub(crate) fn to_cluster(
@@ -97,23 +83,19 @@ impl Cluster {
9783
) -> fleet_cluster::Cluster {
9884
let empty = ClusterConfig::default();
9985
let config = config.unwrap_or(&empty);
100-
let labels = match &self.spec.topology {
101-
Some(ClusterTopology {
102-
class,
103-
class_namespace,
104-
..
105-
}) if !class.is_empty() => {
106-
let mut labels = self.labels().clone();
107-
labels.insert(CLUSTER_CLASS_LABEL.to_string(), class.clone());
86+
let class = self.cluster_class_name();
87+
let ns = self.namespace().unwrap_or_default();
88+
let class_namespace = self.cluster_class_namespace().unwrap_or(&ns);
89+
let labels = {
90+
let mut labels = self.labels().clone();
91+
if let Some(class) = class {
92+
labels.insert(CLUSTER_CLASS_LABEL.to_string(), class.to_string());
10893
labels.insert(
10994
CLUSTER_CLASS_NAMESPACE_LABEL.to_string(),
110-
class_namespace
111-
.clone()
112-
.unwrap_or(self.namespace().unwrap_or_default()),
95+
class_namespace.to_string(),
11396
);
114-
labels
11597
}
116-
None | Some(ClusterTopology { .. }) => self.labels().clone(),
98+
labels
11799
};
118100

119101
fleet_cluster::Cluster {
@@ -210,4 +192,12 @@ impl Cluster {
210192
}
211193
.into()
212194
}
195+
196+
pub(crate) fn cluster_class_namespace(&self) -> Option<&str> {
197+
self.spec.topology.as_ref()?.class_namespace.as_deref()
198+
}
199+
200+
pub(crate) fn cluster_class_name(&self) -> Option<&str> {
201+
Some(&self.spec.topology.as_ref()?.class)
202+
}
213203
}

src/api/fleet_addon_config.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ pub enum Install {
269269
Version(String),
270270
}
271271

272+
impl Install {
273+
/// Perform version normalization for comparison with `helm search` app_version output
274+
pub(crate) fn normalized(self) -> Self {
275+
match self {
276+
Install::FollowLatest(_) => self,
277+
Install::Version(version) => {
278+
Install::Version(version.strip_prefix("v").unwrap_or(&version).into())
279+
}
280+
}
281+
}
282+
}
283+
272284
impl Default for Install {
273285
fn default() -> Self {
274286
Self::FollowLatest(true)
@@ -314,16 +326,6 @@ pub struct Selectors {
314326
}
315327

316328
impl FleetAddonConfig {
317-
// Provide a static label selector for cluster objects, which can be always be set
318-
// and will not cause cache events from resources in the labeled Namespace to be missed
319-
pub(crate) fn cluster_watch(&self) -> Result<Selector, ParseExpressionError> {
320-
Ok(self
321-
.namespace_selector()?
322-
.selects_all()
323-
.then_some(self.cluster_selector()?)
324-
.unwrap_or_default())
325-
}
326-
327329
// Raw cluster selector
328330
pub(crate) fn cluster_selector(&self) -> Result<Selector, ParseExpressionError> {
329331
self.spec

src/api/fleet_clustergroup.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use fleet_api_rs::fleet_clustergroup::{
66
use k8s_openapi::api::core::v1::ObjectReference;
77
use kube::{
88
api::{ObjectMeta, TypeMeta},
9+
core::{Expression, Selector},
910
runtime::reflector::ObjectRef,
1011
Resource, ResourceExt as _,
1112
};
@@ -51,6 +52,13 @@ impl ClusterGroup {
5152
.into(),
5253
)
5354
}
55+
56+
pub(crate) fn group_selector() -> Selector {
57+
Selector::from_iter([
58+
Expression::Exists(CLUSTER_CLASS_LABEL.to_string()),
59+
Expression::Exists(CLUSTER_CLASS_NAMESPACE_LABEL.to_string()),
60+
])
61+
}
5462
}
5563

5664
impl From<&ClusterClass> for ClusterGroup {

0 commit comments

Comments
 (0)