Skip to content

Commit 5f77e0d

Browse files
sbernauerTechassi
andauthored
feat: Warn when stack/demo is larger than cluster (#94)
* feat: Warn when stack/demo is larget than cluster * reordered imports * space out error variants * Rework validate_cluster_size to return Vec<Err> instead of warn!ing * Add check_perquisites function * use operator-rs from main * Add improvements * fix: Checking of prerequesites * Avoid uneeded collect() * Use operator-rs 0.47.0 * Update OpenAPI spec * Fix typo --------- Co-authored-by: Techassi <sascha.lautenschlaeger@stackable.tech>
1 parent 80dce04 commit 5f77e0d

File tree

11 files changed

+305
-74
lines changed

11 files changed

+305
-74
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ utoipa-swagger-ui = { version = "3.1", features = ["axum"] }
5151
uuid = { version = "1.4.0", features = ["v4"] }
5252
which = "4.4"
5353

54-
[patch."https://github.com/stackabletech/operator-rs.git"]
54+
# [patch."https://github.com/stackabletech/operator-rs.git"]
5555
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
5656

5757
[profile.release.package.stackablectl]

rust/stackable-cockpit/src/platform/cluster.rs renamed to rust/stackable-cockpit/src/platform/cluster/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@ use kube::core::ObjectList;
33
use snafu::{ResultExt, Snafu};
44
use stackable_operator::{cpu::CpuQuantity, memory::MemoryQuantity};
55

6+
mod resource_request;
7+
8+
pub use resource_request::*;
9+
610
#[derive(Debug, Snafu)]
711
pub enum ClusterError {
812
#[snafu(display("failed to parse node cpu"))]
913
ParseNodeCpu {
1014
source: stackable_operator::error::Error,
1115
},
16+
1217
#[snafu(display("failed to parse node memory"))]
1318
ParseNodeMemory {
1419
source: stackable_operator::error::Error,
1520
},
1621
}
1722

18-
/// [`ClusterInfo`] contains information about the Kubernetes cluster, such as the number of nodes and
19-
/// allocatable resources.
23+
/// [`ClusterInfo`] contains information about the Kubernetes cluster, such as
24+
/// the number of nodes and allocatable resources.
2025
#[derive(Debug)]
2126
pub struct ClusterInfo {
2227
/// All nodes of the cluster regardless of their type
2328
pub node_count: usize,
29+
2430
/// Nodes that have no taints set, this e.g. excludes kind master nodes.
2531
/// The idea is, that our stacks/demos don't specify any tolerations, so these nodes are
2632
/// not available when installing a stack or demo.
2733
pub untainted_node_count: usize,
34+
2835
/// Sum of allocatable cpu resources on all untainted nodes. Please note that allocatable
2936
/// is comparable to the total capacity of the node, not the free capacity!
3037
pub untainted_allocatable_cpu: CpuQuantity,
38+
3139
/// Sum of allocatable memory resources on all untainted nodes. Please note that allocatable
3240
/// is comparable to the total capacity of the node, not the free capacity!
3341
pub untainted_allocatable_memory: MemoryQuantity,
@@ -48,11 +56,10 @@ impl ClusterInfo {
4856
});
4957
let untainted_node_count = untainted_nodes.clone().count();
5058

51-
let untainted_allocatable: Vec<_> = untainted_nodes
59+
let untainted_allocatable = untainted_nodes
5260
.into_iter()
5361
.filter_map(|node| node.status)
54-
.filter_map(|status| status.allocatable)
55-
.collect();
62+
.filter_map(|status| status.allocatable);
5663

5764
let mut untainted_allocatable_memory = MemoryQuantity::from_mebi(0.0);
5865
let mut untainted_allocatable_cpu = CpuQuantity::from_millis(0);

0 commit comments

Comments
 (0)