Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
]

[workspace.package]
version = "2.1.0"
version = "2.1.1"
edition = "2024"
authors = ["mbecker20 <becker.maxh@gmail.com>"]
license = "GPL-3.0-or-later"
Expand Down
44 changes: 40 additions & 4 deletions bin/core/src/monitor/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ pub async fn update_swarm_stack_cache(
Some(SwarmState::Unknown) | None => StackState::Unknown,
})
.unwrap_or(StackState::Down);

let services = extract_services_from_stack(&stack);
let service_prefix = format!("{project_name}_");

let mut services_with_swarm_services = services
.iter()
.map(
Expand All @@ -74,27 +76,50 @@ pub async fn update_swarm_stack_cache(
.unwrap_or_default()
})
.cloned();

let (image, image_digests) = swarm_service
.as_ref()
.and_then(|swarm_service| swarm_service.image.as_ref())
.map(|image| {
(
image.clone(),
ImageDigest::parse(image).map(|d| vec![d]),
)
})
.unwrap_or((
if image.contains(':') {
image.to_string()
} else {
format!("{image}:latest")
},
None,
));

StackService {
service: service_name.clone(),
image: image.clone(),
container: None,
swarm_service,
image_digests: Default::default(),
image,
image_digests,
}
},
)
.collect::<Vec<_>>();

services_with_swarm_services
.sort_by(|a, b| a.service.cmp(&b.service));

let prev_state = stack_status_cache
.get(&stack.id)
.await
.map(|s| s.curr.state);

let status = CachedStackStatus {
id: stack.id.clone(),
state: current_state,
services: services_with_swarm_services,
};

stack_status_cache
.insert(
stack.id,
Expand Down Expand Up @@ -207,10 +232,17 @@ pub async fn update_swarm_deployment_cache(
.unwrap_or_default()
})
.cloned();

let image_digests = service
.as_ref()
.and_then(|service| service.image.as_ref())
.and_then(|image| ImageDigest::parse(image).map(|d| vec![d]));

let prev_state = deployment_status_cache
.get(&deployment.id)
.await
.map(|s| s.curr.state);

let current_state = service
.as_ref()
.map(|service| match service.state {
Expand All @@ -220,16 +252,17 @@ pub async fn update_swarm_deployment_cache(
SwarmState::Unknown => DeploymentState::Unknown,
})
.unwrap_or(DeploymentState::NotDeployed);

deployment_status_cache
.insert(
deployment.id.clone(),
History {
curr: CachedDeploymentStatus {
id: deployment.id,
state: current_state,
service,
container: None,
image_digests: None,
service,
image_digests,
},
prev: prev_state,
}
Expand All @@ -251,6 +284,7 @@ pub async fn update_server_deployment_cache(
.iter()
.find(|container| container.name == deployment.name)
.cloned();

let image_digests = container
.as_ref()
.and_then(|container| container.image_id.as_ref())
Expand All @@ -263,10 +297,12 @@ pub async fn update_server_deployment_cache(
}
})
});

let prev_state = deployment_status_cache
.get(&deployment.id)
.await
.map(|s| s.curr.state);

let current_state = container
.as_ref()
.map(|c| c.state.into())
Expand Down
2 changes: 1 addition & 1 deletion client/core/ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "komodo_client",
"version": "2.1.0",
"version": "2.1.1",
"description": "Komodo client package",
"homepage": "https://komo.do",
"main": "dist/lib.js",
Expand Down
Loading