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
28 changes: 14 additions & 14 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 @@ -9,7 +9,7 @@ members = [
]

[workspace.package]
version = "2.3.0"
version = "2.3.1"
edition = "2024"
license = "GPL-3.0-or-later"
repository = "https://github.com/moghtech/komodo"
Expand Down
36 changes: 35 additions & 1 deletion bin/core/src/api/write/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use komodo_client::{
permission::PermissionLevel,
repo::Repo,
resource::ResourceQuery,
stack::{Stack, StackInfo, StackServiceWithUpdate, StackState},
stack::{
Stack, StackInfo, StackServiceNames, StackServiceWithUpdate,
StackState,
},
update::Update,
user::{auto_redeploy_user, stack_user, system_user},
},
Expand Down Expand Up @@ -822,6 +825,11 @@ pub async fn check_stack_for_update_inner(
services: extract_services_from_stack(&stack)
.into_iter()
.map(|service| StackServiceWithUpdate {
latest_image: find_latest_image(
&service.service_name,
&service.image,
&stack.info.latest_services,
),
service: service.service_name,
image: service.image,
update_available: false,
Expand All @@ -842,6 +850,11 @@ pub async fn check_stack_for_update_inner(
.services
.iter()
.map(|service| StackServiceWithUpdate {
latest_image: find_latest_image(
&service.service,
&service.image,
&stack.info.latest_services,
),
service: service.service.clone(),
image: service.image.clone(),
update_available: false,
Expand All @@ -857,6 +870,11 @@ pub async fn check_stack_for_update_inner(
service: service.service.clone(),
image: service.image.clone(),
update_available: false,
latest_image: find_latest_image(
&service.service,
&service.image,
&stack.info.latest_services,
),
};

let Some(current_digests) = &service.image_digests else {
Expand Down Expand Up @@ -1032,6 +1050,22 @@ pub async fn check_stack_for_update_inner(
})
}

fn find_latest_image(
service_name: &str,
current_image: &str,
latest_services: &[StackServiceNames],
) -> Option<String> {
latest_services.iter().find_map(|latest| {
if latest.service_name == service_name
&& latest.image != current_image
{
Some(latest.image.clone())
} else {
None
}
})
}

//

impl Resolve<WriteArgs> for BatchCheckStackForUpdate {
Expand Down
4 changes: 2 additions & 2 deletions bin/core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod monitor;
mod network;
mod periphery;
mod permission;
mod reporting;
mod report;
mod resource;
mod schedule;
mod stack;
Expand Down Expand Up @@ -72,7 +72,7 @@ async fn app() -> anyhow::Result<()> {
resource::spawn_action_state_refresh_loop();
schedule::spawn_schedule_executor();
helpers::prune::spawn_prune_loop();
reporting::spawn_reporting_loop();
report::spawn_reporting_loop();
}
.instrument(startup_span)
.await;
Expand Down
7 changes: 4 additions & 3 deletions bin/core/src/reporting.rs → bin/core/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::Context;
use async_timing_util::{Timelength, wait_until_timelength};
use komodo_client::entities::{
ResourceTargetVariant, core_report::CoreReport,
ResourceTargetVariant, report::KomodoReport,
};
use mogh_pki::{
PkiKind, RotatableKeyPair, SpkiPublicKey,
Expand Down Expand Up @@ -112,8 +112,9 @@ async fn report(
.into_iter()
.collect();

let report = CoreReport {
report_public_key: keys.public().to_string(),
let report = KomodoReport {
public_key: keys.public().to_string(),
version: String::from(env!("CARGO_PKG_VERSION")),
users,
count,
};
Expand Down
1 change: 1 addition & 0 deletions bin/core/src/resource/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl super::KomodoResource for Server {
state: status.as_ref().map(|s| s.state).unwrap_or_default(),
err: status.as_ref().and_then(|s| s.err.clone()),
stats: system_stats.map(Into::into),
alerting_thresholds: (&server.config).into(),
core_count: system_info.and_then(|i| i.core_count),
logical_core_count: system_info
.and_then(|i| i.logical_core_count),
Expand Down
46 changes: 27 additions & 19 deletions bin/core/src/resource/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,38 @@ impl super::KomodoResource for Stack {
.services
.iter()
.map(|current_service| {
let latest_service = stack
.info
.latest_services
.iter()
.find(|latest_service| {
current_service.service == latest_service.service_name
});
let latest_image = if let Some(latest_image) =
latest_service.as_ref().map(|s| &s.image)
&& latest_image != &current_service.image
{
Some(latest_image.to_string())
} else {
None
};
let update_available = current_service
.image_digests
.as_ref()
.map(|current_digests| {
stack
.info
.latest_services
.iter()
.find_map(|latest_service| {
if current_service.service
== latest_service.service_name
{
latest_service
.image_digest
.as_ref()?
.update_available(current_digests)
.into()
} else {
None
}
})
.unwrap_or_default()
.and_then(|current_digests| {
latest_service.as_ref().and_then(|latest_service| {
latest_service
.image_digest
.as_ref()?
.update_available(current_digests)
.into()
})
})
.unwrap_or_default();
StackServiceWithUpdate {
service: current_service.service.clone(),
image: current_service.image.clone(),
latest_image,
update_available,
}
})
Expand Down Expand Up @@ -239,6 +244,9 @@ impl super::KomodoResource for Stack {
branch,
latest_hash: stack.info.latest_hash,
deployed_hash: stack.info.deployed_hash,
auto_update_all_services: stack
.config
.auto_update_all_services,
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion bin/periphery/src/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl StatsClient {
let mut network_ingress_bytes: u64 = 0;
let mut network_egress_bytes: u64 = 0;

for (_, network) in self.networks.iter() {
for network in self.networks.values() {
network_ingress_bytes += network.received();
network_egress_bytes += network.transmitted();
}
Expand Down
4 changes: 2 additions & 2 deletions client/core/rs/src/entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub mod build;
pub mod builder;
/// [core config][config::core] and [periphery config][config::periphery]
pub mod config;
/// Subtypes of [CoreReport][core_report::CoreReport]
pub mod core_report;
/// Subtypes of [Deployment][deployment::Deployment].
pub mod deployment;
/// Networks, Images, Containers.
Expand All @@ -53,6 +51,8 @@ pub mod procedure;
pub mod provider;
/// Subtypes of [Repo][repo::Repo].
pub mod repo;
/// Subtypes of [CoreReport][core_report::CoreReport]
pub mod report;
/// Subtypes of [Resource][resource::Resource].
pub mod resource;
/// Subtypes of [Schedule][schedule::Schedule]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ use serde::{Deserialize, Serialize};

use crate::entities::ResourceTargetVariant;

/// Semi-anonymous core data reporting.
/// Reports only include the reporting-specific core public key
/// (not the keys used for server connection).
/// Semi-anonymous Komodo Core reporting.
/// Reports only include the reporting-specific public key
/// (not the key pair used for server connection).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct CoreReport {
pub struct KomodoReport {
/// Reporting specific public key.
/// Must match public key obtained through request signature.
pub report_public_key: String,
pub public_key: String,
/// The Komodo Core version string
pub version: String,
/// The total number of users
pub users: u64,
/// Resource counts by type
Expand Down
Loading
Loading