deploy 2.0.0-dev-80

This commit is contained in:
mbecker20
2025-10-27 01:21:44 -07:00
parent e0b31cfe51
commit 35bf224080
8 changed files with 108 additions and 89 deletions

89
Cargo.lock generated
View File

@@ -440,7 +440,7 @@ dependencies = [
"hyper-util",
"pin-project-lite",
"rustls 0.21.12",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-native-certs 0.8.1",
"rustls-pki-types",
"tokio",
@@ -671,7 +671,7 @@ dependencies = [
"hyper 1.7.0",
"hyper-util",
"pin-project-lite",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-pemfile 2.2.0",
"rustls-pki-types",
"tokio",
@@ -902,7 +902,7 @@ dependencies = [
[[package]]
name = "cache"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"tokio",
@@ -1094,9 +1094,10 @@ dependencies = [
[[package]]
name = "command"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"komodo_client",
"nix 0.30.1",
"shlex",
"svi",
"tokio",
@@ -1121,7 +1122,7 @@ checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb"
[[package]]
name = "config"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"colored",
"indexmap 2.12.0",
@@ -1443,7 +1444,7 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "database"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"async-compression",
@@ -1742,7 +1743,7 @@ dependencies = [
[[package]]
name = "encoding"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"bytes",
@@ -1784,7 +1785,7 @@ dependencies = [
[[package]]
name = "environment"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"formatting",
@@ -1794,7 +1795,7 @@ dependencies = [
[[package]]
name = "environment_file"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"thiserror 2.0.17",
]
@@ -1890,7 +1891,7 @@ dependencies = [
[[package]]
name = "formatting"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"serror",
]
@@ -2056,7 +2057,7 @@ dependencies = [
[[package]]
name = "git"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"cache",
@@ -2454,7 +2455,7 @@ dependencies = [
"http 1.3.1",
"hyper 1.7.0",
"hyper-util",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-native-certs 0.8.1",
"rustls-pki-types",
"tokio",
@@ -2688,7 +2689,7 @@ dependencies = [
[[package]]
name = "interpolate"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"komodo_client",
@@ -2793,9 +2794,9 @@ dependencies = [
[[package]]
name = "jsonwebtoken"
version = "10.0.0"
version = "10.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1417155a38e99d7704ddb3ea7445fe57fdbd5d756d727740a9ed8b9ebaed6e1"
checksum = "3d119c6924272d16f0ab9ce41f7aa0bfef9340c00b0bb7ca3dd3b263d4a9150b"
dependencies = [
"aws-lc-rs",
"base64 0.22.1",
@@ -2810,7 +2811,7 @@ dependencies = [
[[package]]
name = "komodo_cli"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"bytes",
@@ -2840,7 +2841,7 @@ dependencies = [
[[package]]
name = "komodo_client"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"async_timing_util",
@@ -2875,7 +2876,7 @@ dependencies = [
[[package]]
name = "komodo_core"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"arc-swap",
@@ -2922,7 +2923,7 @@ dependencies = [
"reqwest",
"resolver_api",
"response",
"rustls 0.23.33",
"rustls 0.23.34",
"secret_file",
"serde",
"serde_json",
@@ -2949,7 +2950,7 @@ dependencies = [
[[package]]
name = "komodo_periphery"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"arc-swap",
@@ -2980,7 +2981,7 @@ dependencies = [
"periphery_client",
"portable-pty",
"resolver_api",
"rustls 0.23.33",
"rustls 0.23.34",
"secret_file",
"serde",
"serde_json",
@@ -3069,7 +3070,7 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "logger"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"komodo_client",
@@ -3300,7 +3301,7 @@ dependencies = [
"percent-encoding",
"rand 0.8.5",
"rustc_version_runtime",
"rustls 0.23.33",
"rustls 0.23.34",
"rustversion",
"serde",
"serde_bytes",
@@ -3359,9 +3360,21 @@ dependencies = [
"libc",
]
[[package]]
name = "nix"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags 2.9.4",
"cfg-if",
"cfg_aliases 0.2.1",
"libc",
]
[[package]]
name = "noise"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"arc-swap",
@@ -3776,7 +3789,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "periphery_client"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"derive_variants",
@@ -3901,7 +3914,7 @@ dependencies = [
"lazy_static",
"libc",
"log",
"nix",
"nix 0.28.0",
"serial2",
"shared_library",
"shell-words",
@@ -3996,7 +4009,7 @@ dependencies = [
"quinn-proto",
"quinn-udp",
"rustc-hash",
"rustls 0.23.33",
"rustls 0.23.34",
"socket2 0.6.1",
"thiserror 2.0.17",
"tokio",
@@ -4016,7 +4029,7 @@ dependencies = [
"rand 0.9.2",
"ring",
"rustc-hash",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-pki-types",
"slab",
"thiserror 2.0.17",
@@ -4208,7 +4221,7 @@ dependencies = [
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-native-certs 0.8.1",
"rustls-pki-types",
"serde",
@@ -4257,7 +4270,7 @@ dependencies = [
[[package]]
name = "response"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"axum",
@@ -4362,9 +4375,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.23.33"
version = "0.23.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c"
checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7"
dependencies = [
"aws-lc-rs",
"log",
@@ -4527,7 +4540,7 @@ dependencies = [
[[package]]
name = "secret_file"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"tokio",
]
@@ -5273,7 +5286,7 @@ version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61"
dependencies = [
"rustls 0.23.33",
"rustls 0.23.34",
"tokio",
]
@@ -5297,7 +5310,7 @@ checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857"
dependencies = [
"futures-util",
"log",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-native-certs 0.8.1",
"rustls-pki-types",
"tokio",
@@ -5560,7 +5573,7 @@ dependencies = [
[[package]]
name = "transport"
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
dependencies = [
"anyhow",
"axum",
@@ -5572,7 +5585,7 @@ dependencies = [
"periphery_client",
"pin-project-lite",
"rand 0.9.2",
"rustls 0.23.33",
"rustls 0.23.34",
"serde",
"serror",
"sha1",
@@ -5603,7 +5616,7 @@ dependencies = [
"httparse",
"log",
"rand 0.9.2",
"rustls 0.23.33",
"rustls 0.23.34",
"rustls-pki-types",
"sha1",
"thiserror 2.0.17",

View File

@@ -8,7 +8,7 @@ members = [
]
[workspace.package]
version = "2.0.0-dev-79"
version = "2.0.0-dev-80"
edition = "2024"
authors = ["mbecker20 <becker.maxh@gmail.com>"]
license = "GPL-3.0-or-later"
@@ -100,8 +100,8 @@ envy = "0.4.2"
# CRYPTO / AUTH
uuid = { version = "1.18.1", features = ["v4", "fast-rng", "serde"] }
jsonwebtoken = { version = "10.0.0", features = ["aws_lc_rs"] } # locked back with octorust
rustls = { version = "0.23.33", features = ["aws-lc-rs"] }
jsonwebtoken = { version = "10.1.0", features = ["aws_lc_rs"] } # locked back with octorust
rustls = { version = "0.23.34", features = ["aws-lc-rs"] }
pem-rfc7468 = { version = "0.7.0", features = ["alloc"] }
openidconnect = "4.0.1"
urlencoding = "2.1.3"
@@ -118,12 +118,14 @@ spki = "0.7.3"
der = "0.7.10"
# SYSTEM
nix = { version = "0.30.1", features = ["process", "signal"] }
hickory-resolver = "0.25.2"
portable-pty = "0.9.0"
shell-escape = "0.1.5"
crossterm = "0.29.0"
bollard = "0.19.3"
sysinfo = "0.37.1"
shlex = "1.3.0"
# CLOUD
aws-config = "1.8.8"
@@ -146,4 +148,3 @@ wildcard = "0.3.0"
colored = "3.0.0"
bytes = "1.10.1"
regex = "1.12.2"
shlex = "1.3.0"

View File

@@ -1,7 +1,7 @@
use std::sync::OnceLock;
use anyhow::{Context, anyhow};
use jsonwebtoken::{DecodingKey, Validation, decode};
use jsonwebtoken::dangerous::insecure_decode;
use komodo_client::entities::{
config::core::{CoreConfig, OauthCredentials},
random_string,
@@ -138,15 +138,8 @@ impl GoogleOauthClient {
&self,
id_token: &str,
) -> anyhow::Result<GoogleUser> {
let mut v = Validation::new(Default::default());
v.insecure_disable_signature_validation();
v.validate_aud = false;
let res = decode::<GoogleUser>(
id_token,
&DecodingKey::from_secret(b""),
&v,
)
.context("failed to decode google id token")?;
let res = insecure_decode::<GoogleUser>(id_token)
.context("failed to decode google id token")?;
Ok(res.claims)
}

View File

@@ -43,6 +43,7 @@ async fn app() -> anyhow::Result<()> {
logger::init(&config.logging)?;
let startup_span = info_span!("CoreStartup");
async {
info!("Komodo Core version: v{}", env!("CARGO_PKG_VERSION"));
@@ -159,9 +160,13 @@ async fn app() -> anyhow::Result<()> {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
command::spawn_process_reaper_if_pid1()
.context("Failed to spawn process reaper inside container. This may lead to unreaped processes on host.")?;
let mut term_signal = tokio::signal::unix::signal(
tokio::signal::unix::SignalKind::terminate(),
)?;
tokio::select! {
res = tokio::spawn(app()) => res?,
_ = term_signal.recv() => Ok(()),

View File

@@ -1,3 +1,4 @@
use anyhow::Context;
use futures_util::{StreamExt, stream::FuturesUnordered};
use komodo_client::entities::config::periphery::Command;
use tracing::Instrument;
@@ -20,6 +21,7 @@ mod stats;
mod terminal;
async fn app() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let config = config::periphery_config();
logger::init(&config.logging)?;
@@ -102,21 +104,19 @@ async fn main() -> anyhow::Result<()> {
return noise::key::command::handle(command).await;
}
dotenvy::dotenv().ok();
command::spawn_process_reaper_if_pid1()
.context("Failed to spawn process reaper inside container. This may lead to unreaped processes on host.")?;
let mut term_signal = tokio::signal::unix::signal(
tokio::signal::unix::SignalKind::terminate(),
)?;
let app = tokio::spawn(app());
tokio::select! {
res = app => return res?,
res = tokio::spawn(app()) => return res?,
_ = term_signal.recv() => {
info!("Exiting all active Terminals for shutdown");
terminal::delete_all_terminals().await;
Ok(())
},
}
Ok(())
}

View File

@@ -13,4 +13,5 @@ komodo_client.workspace = true
svi.workspace = true
#
tokio.workspace = true
shlex.workspace = true
shlex.workspace = true
nix.workspace = true

View File

@@ -8,6 +8,11 @@ use komodo_client::{
entities::{komodo_timestamp, update::Log},
parsers::parse_multiline_command,
};
use nix::{
sys::wait::{WaitPidFlag, WaitStatus, waitpid},
unistd::Pid,
};
use tokio::signal::unix::{SignalKind, signal};
mod output;
@@ -134,10 +139,9 @@ pub async fn run_standard_command(
{
lexed
} else {
return CommandOutput::from_err(
std::io::Error::other("Command lexed into empty args"),
None,
);
return CommandOutput::from_err(std::io::Error::other(
"Command lexed into empty args",
));
};
let mut cmd = Command::new(&lexed[0]);
@@ -154,20 +158,11 @@ pub async fn run_standard_command(
Ok(path) => {
cmd.current_dir(path);
}
Err(e) => return CommandOutput::from(Err(e), None),
Err(e) => return CommandOutput::from_err(e),
}
}
let child = match cmd.spawn() {
Ok(child) => child,
Err(e) => return CommandOutput::from_err(e, None),
};
let pid = child.id();
println!("[{}] {command}", pid.clone().unwrap_or_default());
CommandOutput::from(child.wait_with_output().await, pid)
CommandOutput::from(cmd.output().await)
}
fn shell() -> &'static str {
@@ -200,16 +195,30 @@ pub async fn run_shell_command(
Ok(path) => {
cmd.current_dir(path);
}
Err(e) => return CommandOutput::from(Err(e), None),
Err(e) => return CommandOutput::from_err(e),
}
}
let child = match cmd.spawn() {
Ok(child) => child,
Err(e) => return CommandOutput::from_err(e, None),
};
let pid = child.id();
CommandOutput::from(child.wait_with_output().await, pid)
CommandOutput::from(cmd.output().await)
}
pub fn spawn_process_reaper_if_pid1() -> std::io::Result<()> {
if std::process::id() != 1 {
return Ok(());
}
let mut sig = signal(SignalKind::child())?;
tokio::spawn(async move {
loop {
let _ = sig.recv().await;
loop {
match waitpid(Pid::from_raw(-1), Some(WaitPidFlag::WNOHANG)) {
Ok(WaitStatus::StillAlive) => break,
Ok(_status) => continue, // Exited/Signaled/… — all reaped
Err(nix::errno::Errno::ECHILD) => break, // none left
Err(_) => break,
}
}
}
});
Ok(())
}

View File

@@ -6,30 +6,27 @@ use std::{
#[derive(Debug, Clone)]
pub struct CommandOutput {
pub pid: Option<u32>,
pub status: ExitStatus,
pub stdout: String,
pub stderr: String,
}
impl CommandOutput {
pub fn from(output: io::Result<Output>, pid: Option<u32>) -> Self {
pub fn from(output: io::Result<Output>) -> Self {
match output {
Ok(output) => Self {
pid,
status: output.status,
stdout: String::from_utf8(output.stdout)
.unwrap_or("failed to generate stdout".to_string()),
stderr: String::from_utf8(output.stderr)
.unwrap_or("failed to generate stderr".to_string()),
},
Err(e) => CommandOutput::from_err(e, pid),
Err(e) => CommandOutput::from_err(e),
}
}
pub fn from_err(e: io::Error, pid: Option<u32>) -> Self {
pub fn from_err(e: io::Error) -> Self {
Self {
pid,
status: ExitStatus::from_raw(1),
stdout: "".to_string(),
stderr: format!("{e:#?}"),