From 65642500be5c8d82d57c8e253777f519f9f2af50 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 8 Jun 2022 17:34:09 +0200 Subject: [PATCH 01/18] Trying to run proxy --- Cargo.lock | 133 ++++++++++++++++++----- Cargo.toml | 1 + crates/ya-http-proxy/Cargo.toml | 3 +- crates/ya-http-proxy/src/bin.rs | 3 - crates/ya-http-proxy/src/proxy/server.rs | 2 + src/config.rs | 8 +- src/main.rs | 25 +++++ 7 files changed, 141 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f6d8c5..2046a06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,6 +414,12 @@ version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" +[[package]] +name = "arc-swap" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" + [[package]] name = "async-trait" version = "0.1.53" @@ -768,6 +774,17 @@ dependencies = [ "syn", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -994,12 +1011,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "fs_extra" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -1404,27 +1415,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" -[[package]] -name = "jemalloc-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" -dependencies = [ - "cc", - "fs_extra", - "libc", -] - -[[package]] -name = "jemallocator" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" -dependencies = [ - "jemalloc-sys", - "libc", -] - [[package]] name = "jobserver" version = "0.1.24" @@ -1524,6 +1514,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ "cfg-if 1.0.0", + "serde", +] + +[[package]] +name = "log-mdc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" + +[[package]] +name = "log4rs" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "893eaf59f4bef8e2e94302adf56385db445a0306b9823582b0b8d5a06d8822f3" +dependencies = [ + "anyhow", + "arc-swap", + "chrono", + "derivative", + "fnv", + "humantime", + "libc", + "log", + "log-mdc", + "parking_lot 0.12.0", + "serde", + "serde-value", + "serde_json", + "serde_yaml", + "thiserror", + "thread-id", + "typemap", + "winapi 0.3.9", ] [[package]] @@ -1780,6 +1803,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" +dependencies = [ + "num-traits", +] + [[package]] name = "parking_lot" version = "0.11.2" @@ -2298,6 +2330,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_default" version = "0.1.0" @@ -2585,6 +2627,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thread-id" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fdfe0627923f7411a43ec9ec9c39c3a9b4151be313e0922042581fb6c9b717f" +dependencies = [ + "libc", + "redox_syscall", + "winapi 0.3.9", +] + [[package]] name = "threadpool" version = "1.8.1" @@ -2827,6 +2880,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "traitobject" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" + [[package]] name = "trust-dns-proto" version = "0.18.0-alpha.2" @@ -2872,6 +2931,15 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "typemap" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" +dependencies = [ + "unsafe-any", +] + [[package]] name = "typenum" version = "1.15.0" @@ -2911,6 +2979,15 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +[[package]] +name = "unsafe-any" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" +dependencies = [ + "traitobject", +] + [[package]] name = "untrusted" version = "0.7.1" @@ -3186,7 +3263,6 @@ dependencies = [ "futures", "hyper", "hyper-rustls", - "jemallocator", "log", "openssl", "routerify", @@ -3264,6 +3340,7 @@ dependencies = [ "http", "is_executable", "log", + "log4rs", "nix", "rand 0.8.5", "regex", diff --git a/Cargo.toml b/Cargo.toml index 5ff3781..7215ebb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ structopt = "0.3" strum = "0.23" thiserror = "1.0" tokio = { version = "0.2", features = ["io-std", "io-util", "fs", "rt-core", "rt-threaded", "process", "time"] } +log4rs = "1.1" [workspace] members = [ "crates/*" ] diff --git a/crates/ya-http-proxy/Cargo.toml b/crates/ya-http-proxy/Cargo.toml index b40bfb7..12e754d 100644 --- a/crates/ya-http-proxy/Cargo.toml +++ b/crates/ya-http-proxy/Cargo.toml @@ -13,7 +13,6 @@ bin = [ "anyhow", "dotenv", "flexi_logger", - "jemallocator", "structopt", ] tests-e2e = [] @@ -51,7 +50,7 @@ toml = { version = "0.5" } anyhow = { version = "1", optional = true } dotenv = { version = "0.15", optional = true } flexi_logger = { version = "0.22", optional = true } -jemallocator = { version = "0.3", optional = true } +#jemallocator = { version = "0.3", optional = true } structopt = { version = "0.3", optional = true } [dev-dependencies] diff --git a/crates/ya-http-proxy/src/bin.rs b/crates/ya-http-proxy/src/bin.rs index 61942f7..63bc196 100644 --- a/crates/ya-http-proxy/src/bin.rs +++ b/crates/ya-http-proxy/src/bin.rs @@ -1,6 +1,3 @@ -#[global_allocator] -static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; - use chrono::{DateTime, Local}; use std::net::SocketAddr; use std::path::{Path, PathBuf}; diff --git a/crates/ya-http-proxy/src/proxy/server.rs b/crates/ya-http-proxy/src/proxy/server.rs index 7cab0e6..6e8f547 100644 --- a/crates/ya-http-proxy/src/proxy/server.rs +++ b/crates/ya-http-proxy/src/proxy/server.rs @@ -17,6 +17,7 @@ use crate::proxy::stream::HttpStream; pub async fn listen_http( conf: &ServerConf, ) -> Result>>, Error> { + log::error!("SHOW MYSELF d"); let addrs = match conf.bind_http.as_ref() { Some(addrs) => addrs.to_vec(), None => return Ok(None), @@ -105,6 +106,7 @@ pub async fn listen_https( } fn read_tls_conf(conf: &ServerConf) -> Result, Error> { + log::error!("SHOW MYSELF"); let store = match conf.server_cert.server_cert_store_path.clone() { Some(path) => read_cert_store(path)?, None => return Err(TlsError::ServerCertStore("path not set".to_string()).into()), diff --git a/src/config.rs b/src/config.rs index 46bd1b4..bdf02a1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -95,7 +95,13 @@ pub fn lookup(ctx: &mut Context) -> Option { .join(SERVICES_SUBDIRECTORY) })); - find(paths, ctx) + log::error!("Find services: {:?} {:?}", paths, ctx.env.runtime_name().unwrap()); + let service_conf = find(paths, ctx); + if let Some(service_conf) = service_conf.as_ref() { + log::error!("Service found: {:?}", service_conf); + } + service_conf + } fn find(paths: Vec, ctx: &mut Context) -> Option { diff --git a/src/main.rs b/src/main.rs index 2467b56..d22696b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,11 @@ use crate::command::RuntimeCommand; type RuntimeCli = ::Cli; +use log::LevelFilter; +use log4rs::append::file::FileAppender; +use log4rs::config::{Appender, Config, Root}; +use log4rs::encode::pattern::PatternEncoder; + pub const PROPERTY_PREFIX: &str = "golem.runtime.http-auth"; const COUNTER_NAME: &str = "http-auth.requests"; const COUNTER_PUBLISH_INTERVAL: Duration = Duration::from_secs(2); @@ -153,6 +158,8 @@ impl Env for HttpAuthEnv { impl Runtime for HttpAuthRuntime { fn deploy<'a>(&mut self, ctx: &mut Context) -> OutputResponse<'a> { + println!("DUPADUPADUPADUADPUADPUADP"); + log::error!("sdfsdfsdfsdfsdfsdfsdfsdfsdfsdf"); if config::lookup(ctx).is_none() { return SdkError::response("Config file not found"); } @@ -177,6 +184,8 @@ impl Runtime for HttpAuthRuntime { None => return SdkError::response("Config file not found"), }; + log::info!("Service found {:?}", service); + let data_dir = ctx.conf.data_dir.clone(); let http_auth = self.http_auth.clone(); async move { @@ -320,6 +329,22 @@ impl Runtime for HttpAuthRuntime { } fn main() -> anyhow::Result<()> { + let logfile = FileAppender::builder() + .encoder(Box::new(PatternEncoder::new("{d} {l} {t} - {m}{n}"))) + .build(r#"logs/ya-runtime-http-proxy.log"#)?; + + let config = Config::builder() + .appender(Appender::builder().build("logfile", Box::new(logfile))) + .build( + Root::builder() + .appender("logfile") + .build(LevelFilter::Debug), + )?; + + log4rs::init_config(config)?; + log::debug!("Runtime HttpProxy starting - log level debug message ..."); + log::info!("Runtime HttpProxy starting - log level info message ..."); + let runtime = ya_runtime_sdk::build::(HttpAuthEnv::default(), move |ctx| { let api_url = ctx.conf.management_api_url.clone(); From 7c573fb6c2265d452e0106a2227ec77d5b61c740 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Thu, 9 Jun 2022 15:42:18 +0200 Subject: [PATCH 02/18] trying to work --- crates/ya-http-proxy-client/src/api.rs | 7 +++++++ src/main.rs | 4 ++-- src/proxy.rs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/ya-http-proxy-client/src/api.rs b/crates/ya-http-proxy-client/src/api.rs index f2ccd6f..dd0cd62 100644 --- a/crates/ya-http-proxy-client/src/api.rs +++ b/crates/ya-http-proxy-client/src/api.rs @@ -20,15 +20,18 @@ impl ManagementApi { } pub async fn create_service(&self, cs: &CreateService) -> Result { + log::info!("Create service"); self.client.post("services", cs).await } pub async fn get_service(&self, service_name: &str) -> Result { + log::info!("Get service"); let url = format!("services/{}", service_name); self.client.get(&url).await } pub async fn delete_service(&self, service_name: &str) -> Result<()> { + log::info!("Delete service"); let url = format!("services/{}", service_name); self.client.delete(&url).await } @@ -36,21 +39,25 @@ impl ManagementApi { // User management per service pub async fn get_users(&self, service_name: &str) -> Result> { + log::info!("Get users"); let url = format!("services/{}/users", service_name); self.client.get(&url).await } pub async fn create_user(&self, service_name: &str, cu: &CreateUser) -> Result { + log::info!("Create user"); let url = format!("services/{}/users", service_name); self.client.post(&url, cu).await } pub async fn get_user(&self, service_name: &str, username: &str) -> Result { + log::info!("Get user"); let url = format!("services/{}/users/{}", service_name, username); self.client.get(&url).await } pub async fn delete_user(&self, service_name: &str, username: &str) -> Result<()> { + log::info!("Delete user"); let url = format!("services/{}/users/{}", service_name, username); self.client.delete(&url).await } diff --git a/src/main.rs b/src/main.rs index d22696b..f9f66be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -158,8 +158,7 @@ impl Env for HttpAuthEnv { impl Runtime for HttpAuthRuntime { fn deploy<'a>(&mut self, ctx: &mut Context) -> OutputResponse<'a> { - println!("DUPADUPADUPADUADPUADPUADP"); - log::error!("sdfsdfsdfsdfsdfsdfsdfsdfsdfsdf"); + log::info!("SCX - started deploying service"); if config::lookup(ctx).is_none() { return SdkError::response("Config file not found"); } @@ -175,6 +174,7 @@ impl Runtime for HttpAuthRuntime { } fn start<'a>(&mut self, ctx: &mut Context) -> OutputResponse<'a> { + log::info!("SCX - started service"); let emitter = match ctx.emitter.clone() { Some(emitter) => emitter, None => return SdkError::response("Not running in server mode"), diff --git a/src/proxy.rs b/src/proxy.rs index 1f0e2e1..15de312 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -53,7 +53,7 @@ pub async fn spawn(api: ManagementApi, data_dir: PathBuf) -> anyhow::Result<()> .parent() .ok_or_else(|| anyhow::anyhow!("unable to retrieve executable directory"))?; - let path = exe_dir.join("ya-http-proxy"); + let path = exe_dir.join("ya-http-proxy.exe"); if !path.is_file() { anyhow::bail!("unable to find proxy binary"); } else if !path.is_executable() { From 33f758e3cff6d09019b4177623bb4a8b452d28b3 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Jun 2022 19:52:19 +0200 Subject: [PATCH 03/18] Added some logging --- crates/ya-http-proxy/src/proxy.rs | 1 + crates/ya-http-proxy/src/proxy/handler.rs | 13 +++++++++++-- crates/ya-http-proxy/src/proxy/server.rs | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/ya-http-proxy/src/proxy.rs b/crates/ya-http-proxy/src/proxy.rs index 9addc26..99396a9 100644 --- a/crates/ya-http-proxy/src/proxy.rs +++ b/crates/ya-http-proxy/src/proxy.rs @@ -52,6 +52,7 @@ impl ProxyManager { } async fn spawn(&self, create: &mut model::CreateService) -> Result { + log::info!("Proxy manager spawn"); let mut services = self.proxies.write().await; let addrs = create.addresses(); diff --git a/crates/ya-http-proxy/src/proxy/handler.rs b/crates/ya-http-proxy/src/proxy/handler.rs index debdcc7..558dee1 100644 --- a/crates/ya-http-proxy/src/proxy/handler.rs +++ b/crates/ya-http-proxy/src/proxy/handler.rs @@ -22,6 +22,7 @@ pub async fn forward_req( let headers = req.headers(); let state = proxy_state.read().await; + log::error!("forward error error1: {}", address); // Check whether the service is registered let service = match state .by_endpoint @@ -32,6 +33,7 @@ pub async fn forward_req( None => return response(StatusCode::NOT_FOUND), }; + log::error!("forward error auth: {}", address); // TODO: consider reading credentials from URL // Extract credentials from header let auth = match extract_basic_auth(headers) { @@ -46,6 +48,7 @@ pub async fn forward_req( let proxy_to = service.created_with.to.clone(); drop(state); + log::error!("forward error decode base64: {}", address); // Decode credentials let decoded_auth = match decode_base64(auth) { Ok(decoded_auth) => decoded_auth, @@ -59,13 +62,14 @@ pub async fn forward_req( // Domain name let host = extract_host(headers); + log::error!("forward error decode base64: {:?}", host); // Update request stats { let mut stats = proxy_stats.write().await; stats.inc(path, username); } - log::debug!("[{}] {} -> {}", username, path, proxy_to); + log::info!("[{}] {} -> {}", username, path, proxy_to); // Write proxy headers let headers = req.headers_mut(); @@ -78,12 +82,17 @@ pub async fn forward_req( if let Some(host) = host { headers.insert(HeaderName::from_static("x-forwarded-host"), host); } + log::error!("forward error decode headers: {:?}", headers); if let Err(e) = merge_path_and_query(req.uri_mut(), proxy_to) { log::warn!("Forwarded path error: {}", e); return response(StatusCode::INTERNAL_SERVER_ERROR); } - client.request(req).await + log::error!("Sending request: {:?}", req); + let resp = client.request(req).await; + log::error!("Got request: {:?}", resp); + resp + } #[inline] diff --git a/crates/ya-http-proxy/src/proxy/server.rs b/crates/ya-http-proxy/src/proxy/server.rs index 6e8f547..dd723f2 100644 --- a/crates/ya-http-proxy/src/proxy/server.rs +++ b/crates/ya-http-proxy/src/proxy/server.rs @@ -58,6 +58,8 @@ pub async fn listen_http( pub async fn listen_https( conf: &ServerConf, ) -> Result>>, Error> { + log::info!("listen_https"); + let addrs = match conf.bind_https.as_ref() { Some(addrs) => addrs.to_vec(), None => return Ok(None), From 2a444a1a4fe31949dd9e79d969d87b147403c0b8 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Jun 2022 19:55:33 +0200 Subject: [PATCH 04/18] fix --- src/proxy.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/proxy.rs b/src/proxy.rs index 15de312..3c9a608 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -53,7 +53,12 @@ pub async fn spawn(api: ManagementApi, data_dir: PathBuf) -> anyhow::Result<()> .parent() .ok_or_else(|| anyhow::anyhow!("unable to retrieve executable directory"))?; - let path = exe_dir.join("ya-http-proxy.exe"); + let path = if cfg!(windows) { + exe_dir.join("ya-http-proxy.exe") + } else { + exe_dir.join("ya-http-proxy") + }; + if !path.is_file() { anyhow::bail!("unable to find proxy binary"); } else if !path.is_executable() { From 87999075844c92bfe89c2a23faf973ccc98e4d30 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 13 Jun 2022 19:12:59 +0200 Subject: [PATCH 05/18] Hard-coded lock file --- crates/ya-http-proxy/src/proxy/handler.rs | 1 - src/config.rs | 7 +++++-- src/proxy.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/ya-http-proxy/src/proxy/handler.rs b/crates/ya-http-proxy/src/proxy/handler.rs index 558dee1..b01ba99 100644 --- a/crates/ya-http-proxy/src/proxy/handler.rs +++ b/crates/ya-http-proxy/src/proxy/handler.rs @@ -92,7 +92,6 @@ pub async fn forward_req( let resp = client.request(req).await; log::error!("Got request: {:?}", resp); resp - } #[inline] diff --git a/src/config.rs b/src/config.rs index bdf02a1..bbc0129 100644 --- a/src/config.rs +++ b/src/config.rs @@ -95,13 +95,16 @@ pub fn lookup(ctx: &mut Context) -> Option { .join(SERVICES_SUBDIRECTORY) })); - log::error!("Find services: {:?} {:?}", paths, ctx.env.runtime_name().unwrap()); + log::error!( + "Find services: {:?} {:?}", + paths, + ctx.env.runtime_name().unwrap() + ); let service_conf = find(paths, ctx); if let Some(service_conf) = service_conf.as_ref() { log::error!("Service found: {:?}", service_conf); } service_conf - } fn find(paths: Vec, ctx: &mut Context) -> Option { diff --git a/src/proxy.rs b/src/proxy.rs index 3c9a608..4b15360 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -14,7 +14,7 @@ const SLEEP: Duration = Duration::from_millis(500); pub async fn spawn(api: ManagementApi, data_dir: PathBuf) -> anyhow::Result<()> { let started = Instant::now(); - let lock_path = with_lock_ext(data_dir.join(env!("CARGO_PKG_NAME"))); + let lock_path = with_lock_ext("/tmp/proxy.lock"); let mut lock = LockFile::new(&lock_path); let mut state = ProxyState::Unknown; From 0becdfecfd65d1b0436a34af000de4e16189a95b Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 13 Jun 2022 19:45:39 +0200 Subject: [PATCH 06/18] fix --- src/proxy.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/proxy.rs b/src/proxy.rs index 4b15360..23d6d26 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -14,7 +14,9 @@ const SLEEP: Duration = Duration::from_millis(500); pub async fn spawn(api: ManagementApi, data_dir: PathBuf) -> anyhow::Result<()> { let started = Instant::now(); + let lock_path = with_lock_ext("/tmp/proxy.lock"); + log::error!("Lock path set: {}", lock_path.to_str().unwrap()); let mut lock = LockFile::new(&lock_path); let mut state = ProxyState::Unknown; From 450b14cc56683058ebb57fbae697c8c954272d29 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 13 Jun 2022 19:46:47 +0200 Subject: [PATCH 07/18] a --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3c0855f..bd7b06f 100644 --- a/README.md +++ b/README.md @@ -231,3 +231,4 @@ The client should ignore the missing Certificate Authority signature and the dom ```bash openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.cert -sha256 -days 3650 ``` + \ No newline at end of file From 0effa5aff7bad036e0046ae0f4121c2e302bde9a Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 15 Jun 2022 13:21:43 +0200 Subject: [PATCH 08/18] Incremental build changes --- Cargo.toml | 4 ++++ dummy.rs | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 dummy.rs diff --git a/Cargo.toml b/Cargo.toml index 7215ebb..ec96214 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,10 @@ assets = [ [target.'cfg(target_family = "unix")'.dependencies] nix = "0.23" +[[bin]] +name = "ya-runtime-http-auth" +path = "src/main.rs" + [dependencies] ya-runtime-sdk = { version = "0.2.1", features = ["macros"] } # ya-runtime-sdk = { git = "https://github.com/golemfactory/ya-runtime-sdk.git", rev = "77784b7c7af1246780e1439a2725147965fe2f85", features = ["macros"]} diff --git a/dummy.rs b/dummy.rs new file mode 100644 index 0000000..8377ff3 --- /dev/null +++ b/dummy.rs @@ -0,0 +1,9 @@ +/* +This file is used for optimizing incremental builds in dockerfile. It does not matter for whole build, +but if small changes are made then it's good to use snapshot of precompiled dependencies instead of rebuilding them every time + */ + +fn main() { + println!("Dummy file, if you see this output that means docker build went wrong"); + eprintln!("Dummy file, if you see this output that means docker build went wrong"); +} From 03df1cf7900237d9475f0ffb22953cf170f4403e Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 15 Jun 2022 19:21:51 +0200 Subject: [PATCH 09/18] Fixed issue with wrong orders of SocketAddr vectors (sometimes sorted sometimes not) which resulted in mismatched hash in services. --- crates/ya-http-proxy-model/src/addr.rs | 15 +++++++++++++++ crates/ya-http-proxy-model/src/model.rs | 9 ++++----- crates/ya-http-proxy/src/conf/server.rs | 9 ++++----- crates/ya-http-proxy/src/proxy.rs | 2 ++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/crates/ya-http-proxy-model/src/addr.rs b/crates/ya-http-proxy-model/src/addr.rs index 281ee22..8d11a7e 100644 --- a/crates/ya-http-proxy-model/src/addr.rs +++ b/crates/ya-http-proxy-model/src/addr.rs @@ -72,3 +72,18 @@ impl Display for Addresses { write!(f, "]") } } + +impl Addresses { + pub fn gather_and_sort_addresses( + addresses1: Option, + addresses2: Option, + ) -> Addresses { + let mut addrs = addresses1.unwrap_or_default(); + if let Some(addresses2) = addresses2 { + addrs.0.extend(addresses2.0); + } + addrs.0.sort(); + addrs.0.dedup(); + addrs + } +} diff --git a/crates/ya-http-proxy-model/src/model.rs b/crates/ya-http-proxy-model/src/model.rs index 9ef0cdd..b6bd314 100644 --- a/crates/ya-http-proxy-model/src/model.rs +++ b/crates/ya-http-proxy-model/src/model.rs @@ -120,11 +120,10 @@ pub struct CreateService { impl CreateService { pub fn addresses(&self) -> Addresses { - let addrs = self.bind_https.clone().unwrap_or_default(); - match self.bind_http.clone() { - Some(a) => addrs + a, - _ => addrs, - } + //make sure the function returns the same result as ServerConf::addresses + //otherwise services will be recreated resulting an error + + Addresses::gather_and_sort_addresses(self.bind_http.clone(), self.bind_https.clone()) } pub fn https_ports(&self) -> HashSet { diff --git a/crates/ya-http-proxy/src/conf/server.rs b/crates/ya-http-proxy/src/conf/server.rs index 23ea724..1437413 100644 --- a/crates/ya-http-proxy/src/conf/server.rs +++ b/crates/ya-http-proxy/src/conf/server.rs @@ -62,11 +62,10 @@ pub struct ServerConf { impl ServerConf { pub fn addresses(&self) -> Addresses { - let mut addrs = self.bind_https.clone().unwrap_or_default(); - if let Some(a) = self.bind_http.clone() { - addrs.0.extend(a.0); - } - addrs + //make sure the function returns the same result as CreateService::addresses + //otherwise services will be recreated resulting an error + + Addresses::gather_and_sort_addresses(self.bind_http.clone(), self.bind_https.clone()) } } diff --git a/crates/ya-http-proxy/src/proxy.rs b/crates/ya-http-proxy/src/proxy.rs index 99396a9..c6bac12 100644 --- a/crates/ya-http-proxy/src/proxy.rs +++ b/crates/ya-http-proxy/src/proxy.rs @@ -42,6 +42,8 @@ impl ProxyManager { let instances = self.proxies.write().await; let addrs = create.addresses(); + log::info!("Addresses get {:?}", addrs); + log::info!("Instances contains {:?}", instances.keys()); match instances.get(&addrs) { Some(proxy) => Ok(proxy.clone()), None => { From 489fcd0753b48de2a351bd1adaa49a6ce37b9c32 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 15 Jun 2022 19:23:20 +0200 Subject: [PATCH 10/18] Additional logging --- crates/ya-http-proxy/src/proxy.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/ya-http-proxy/src/proxy.rs b/crates/ya-http-proxy/src/proxy.rs index c6bac12..e231f50 100644 --- a/crates/ya-http-proxy/src/proxy.rs +++ b/crates/ya-http-proxy/src/proxy.rs @@ -41,6 +41,9 @@ impl ProxyManager { pub async fn get_or_spawn(&self, create: &mut model::CreateService) -> Result { let instances = self.proxies.write().await; let addrs = create.addresses(); + log::info!("Addresses get {:?}", addrs); + log::info!("Instances contains {:?}", instances.keys()); + log::info!("create: {:?}", create); log::info!("Addresses get {:?}", addrs); log::info!("Instances contains {:?}", instances.keys()); @@ -65,6 +68,7 @@ impl ProxyManager { let conf = self.conf_update(create)?; let name = create.name.clone(); let addrs = conf.server.addresses(); + log::info!("Conf.server: {:?}", conf.server); let proxy_addrs = addrs.clone(); let cpu_threads = create.cpu_threads; @@ -113,6 +117,7 @@ impl ProxyManager { match rx.await { Ok(result) => { if let Ok(ref proxy) = result { + log::info!("Addresses insert {:?}", proxy_addrs); services.insert(proxy_addrs, proxy.clone()); } result From a1bc2bbcb8d347e6f1a1e59b917fee0dd841d5e5 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Thu, 25 Aug 2022 12:08:23 +0200 Subject: [PATCH 11/18] added architecture --- .github/workflows/release.yml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4618858..2c33f1f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -122,6 +122,88 @@ jobs: asset_path: ./releases/${{ steps.pack.outputs.artifact }} asset_name: ${{ steps.pack.outputs.artifact }} asset_content_type: ${{ steps.pack.outputs.media }} + build-aarch64: + name: Build Release + needs: + - create-release + runs-on: ubuntu-latest + env: + OPENSSL_STATIC: 1 + steps: + - uses: actions/checkout@v1 + with: + lfs: true + + - name: Install Musl + run: | + sudo apt-get install -y musl-tools musl + + - name: Get upload url + id: release_upload_url + uses: actions/github-script@0.9.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + result-encoding: string + script: | + let tag = context.payload.ref.replace(/.*\//, ''); + let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { + owner: context.repo.owner, + repo: context.repo.repo, + tag: tag + }); + console.log(release.data.upload_url); + return release.data.upload_url + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: aarch64-unknown-linux-musl + override: true + + - name: Build proxy + run: | + cargo build -p ya-http-proxy --features bin --release --target x86_64-unknown-linux-musl + - name: Build runtime + run: | + cargo build --release --target x86_64-unknown-linux-musl + + - name: Pack + id: pack + shell: bash + env: + GITHUB_REF: ${{ github.ref }} + OS_NAME: linux + run: | + TAG_NAME="${GITHUB_REF##*/}" + TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} + + mkdir -p "$TARGET_DIR/ya-runtime-http-auth" + strip "target/x86_64-unknown-linux-musl/release/ya-runtime-http-auth" + strip "target/x86_64-unknown-linux-musl/release/ya-http-proxy" + + set -x + cp target/x86_64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" + cp target/x86_64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" + cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" + (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") + + echo "::set-output name=artifact::ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" + echo "::set-output name=media::application/tar+gzip" + + - name: Upload + run: echo todo upload ${{ steps.pack.outputs.artifact }} + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_upload_url.outputs.result }} + asset_path: ./releases/${{ steps.pack.outputs.artifact }} + asset_name: ${{ steps.pack.outputs.artifact }} + asset_content_type: ${{ steps.pack.outputs.media }} + build-deb: name: Build Deb needs: From 93cb7c205b7d1ea5707ab5b7815bdf805b4c242f Mon Sep 17 00:00:00 2001 From: scx1332 Date: Thu, 25 Aug 2022 12:11:39 +0200 Subject: [PATCH 12/18] Update aarch --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8b3dfe7..5b3c8f8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -28,6 +28,8 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable + target: aarch64-unknown-linux-musl + override: true - name: Cache cargo registry uses: actions/cache@v1 From 9ce7cb4daa53c2630c49855035c9e1b609a3b10b Mon Sep 17 00:00:00 2001 From: scx1332 Date: Tue, 30 Aug 2022 18:23:57 +0200 Subject: [PATCH 13/18] Revert "Update aarch" This reverts commit 93cb7c205b7d1ea5707ab5b7815bdf805b4c242f. --- .github/workflows/release.yml | 82 ----------------------------------- .github/workflows/rust.yml | 2 - 2 files changed, 84 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c33f1f..4618858 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -122,88 +122,6 @@ jobs: asset_path: ./releases/${{ steps.pack.outputs.artifact }} asset_name: ${{ steps.pack.outputs.artifact }} asset_content_type: ${{ steps.pack.outputs.media }} - build-aarch64: - name: Build Release - needs: - - create-release - runs-on: ubuntu-latest - env: - OPENSSL_STATIC: 1 - steps: - - uses: actions/checkout@v1 - with: - lfs: true - - - name: Install Musl - run: | - sudo apt-get install -y musl-tools musl - - - name: Get upload url - id: release_upload_url - uses: actions/github-script@0.9.0 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - result-encoding: string - script: | - let tag = context.payload.ref.replace(/.*\//, ''); - let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { - owner: context.repo.owner, - repo: context.repo.repo, - tag: tag - }); - console.log(release.data.upload_url); - return release.data.upload_url - - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: aarch64-unknown-linux-musl - override: true - - - name: Build proxy - run: | - cargo build -p ya-http-proxy --features bin --release --target x86_64-unknown-linux-musl - - name: Build runtime - run: | - cargo build --release --target x86_64-unknown-linux-musl - - - name: Pack - id: pack - shell: bash - env: - GITHUB_REF: ${{ github.ref }} - OS_NAME: linux - run: | - TAG_NAME="${GITHUB_REF##*/}" - TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} - - mkdir -p "$TARGET_DIR/ya-runtime-http-auth" - strip "target/x86_64-unknown-linux-musl/release/ya-runtime-http-auth" - strip "target/x86_64-unknown-linux-musl/release/ya-http-proxy" - - set -x - cp target/x86_64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" - cp target/x86_64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" - cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" - (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") - - echo "::set-output name=artifact::ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" - echo "::set-output name=media::application/tar+gzip" - - - name: Upload - run: echo todo upload ${{ steps.pack.outputs.artifact }} - - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.release_upload_url.outputs.result }} - asset_path: ./releases/${{ steps.pack.outputs.artifact }} - asset_name: ${{ steps.pack.outputs.artifact }} - asset_content_type: ${{ steps.pack.outputs.media }} - build-deb: name: Build Deb needs: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5b3c8f8..8b3dfe7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -28,8 +28,6 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable - target: aarch64-unknown-linux-musl - override: true - name: Cache cargo registry uses: actions/cache@v1 From d9f859e61a011c96ae188fa081e8ca93f6aa6426 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Tue, 30 Aug 2022 18:25:19 +0200 Subject: [PATCH 14/18] Added workflows --- .github/workflows/release_arm.yml | 131 ++++++++++++++++++++++++++++++ .github/workflows/rust_arm.yml | 79 ++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 .github/workflows/release_arm.yml create mode 100644 .github/workflows/rust_arm.yml diff --git a/.github/workflows/release_arm.yml b/.github/workflows/release_arm.yml new file mode 100644 index 0000000..1c08ade --- /dev/null +++ b/.github/workflows/release_arm.yml @@ -0,0 +1,131 @@ +name: Release ARM +on: + push: + tags: + - v* + - pre-rel-* + +jobs: + create-release: + name: "Create Release" + runs-on: ubuntu-latest + steps: + - name: Create Release + uses: actions/github-script@v3.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + let tag = context.payload.ref.replace(/.*\//, ''); + let buildNo = context.runNumber; + let versionName = tag.replace(/^pre-rel-/,''); + try { + let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { + owner: context.repo.owner, + repo: context.repo.repo, + tag: tag + }); + } + catch(e) { + let body = ["TODO"].join("\n"); + + let release = await github.request("POST /repos/:owner/:repo/releases", { + owner: context.repo.owner, + repo: context.repo.repo, + data: { + tag_name: tag, + prerelease: true, + body: body, + name: `${versionName} #${buildNo}` + } + }); + console.log(release.data.upload_url); + } + + build: + name: Build Release + needs: + - create-release + runs-on: ubuntu-latest + env: + OPENSSL_STATIC: 1 + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + lfs: true + + - name: Get upload url + id: release_upload_url + uses: actions/github-script@0.9.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + result-encoding: string + script: | + let tag = context.payload.ref.replace(/.*\//, ''); + let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { + owner: context.repo.owner, + repo: context.repo.repo, + tag: tag + }); + console.log(release.data.upload_url); + return release.data.upload_url + + - name: Install last stable Rust cross compiler + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: aarch64-unknown-linux-musl + override: true + + - name: Build proxy + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: -p ya-http-proxy --bin ya-http-proxy --features bin --release --target aarch64-unknown-linux-musl + + - name: Build runtime + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --target aarch64-unknown-linux-musl + + - name: Pack + id: pack + shell: bash + env: + GITHUB_REF: ${{ github.ref }} + OS_NAME: linux + run: | + TAG_NAME="${GITHUB_REF##*/}" + TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} + + ls -la target + mkdir -p "$TARGET_DIR/ya-runtime-http-auth" + #strip "target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth" + #strip "target/aarch64-unknown-linux-musl/release/ya-http-proxy" + + set -x + cp target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" + cp target/aarch64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" + cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" + (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") + + echo "::set-output name=artifact::ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" + echo "::set-output name=media::application/tar+gzip" + + - name: Upload + run: echo todo upload ${{ steps.pack.outputs.artifact }} + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_upload_url.outputs.result }} + asset_path: ./releases/${{ steps.pack.outputs.artifact }} + asset_name: ${{ steps.pack.outputs.artifact }} + asset_content_type: ${{ steps.pack.outputs.media }} + diff --git a/.github/workflows/rust_arm.yml b/.github/workflows/rust_arm.yml new file mode 100644 index 0000000..569d5d0 --- /dev/null +++ b/.github/workflows/rust_arm.yml @@ -0,0 +1,79 @@ +name: Build for ARM + +on: + push: + branches: + - main + - release/* + - scx1332/* + pull_request: + branches: + - main + - release/* + + +jobs: + build_arm: + name: Build Arm + env: + RUSTFLAGS: "-D warnings -C opt-level=z -C debuginfo=1" + X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR: c:/vcpkg/installed/x64-windows + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Install last stable Rust cross compiler + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: aarch64-unknown-linux-musl + override: true + + - name: Build proxy + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: -p ya-http-proxy --bin ya-http-proxy --features bin --release --target aarch64-unknown-linux-musl + + - name: Build runtime + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --target aarch64-unknown-linux-musl + + - name: Pack + id: pack + shell: bash + env: + GITHUB_REF: ${{ github.ref }} + OS_NAME: linux + run: | + TAG_NAME="${GITHUB_REF##*/}" + TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} + + ls -la target + mkdir -p "$TARGET_DIR/ya-runtime-http-auth" + #strip "target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth" + #strip "target/aarch64-unknown-linux-musl/release/ya-http-proxy" + + set -x + cp target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" + cp target/aarch64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" + cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" + (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") + + echo "::set-output name=artifact::ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" + echo "::set-output name=media::application/tar+gzip" + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: ya-runtime-http-auth + path: ./releases/${{ steps.pack.outputs.artifact }} From da0827aeb22da807ece878c0b3d9a325cb4ec2e0 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Tue, 30 Aug 2022 19:21:28 +0200 Subject: [PATCH 15/18] Updated release build --- .github/workflows/release_arm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_arm.yml b/.github/workflows/release_arm.yml index 1c08ade..d39226c 100644 --- a/.github/workflows/release_arm.yml +++ b/.github/workflows/release_arm.yml @@ -112,7 +112,7 @@ jobs: cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") - echo "::set-output name=artifact::ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" + echo "::set-output name=artifact::ya-runtime-http-auth-arm-${TAG_NAME}.tar.gz" echo "::set-output name=media::application/tar+gzip" - name: Upload From 5e18a8bf9a8b4073ae97b1b54586fcb6f05c6eda Mon Sep 17 00:00:00 2001 From: scx1332 Date: Tue, 30 Aug 2022 19:24:31 +0200 Subject: [PATCH 16/18] Merged steps into release.yml --- .github/workflows/release.yml | 87 ++++++++++++++++++++ .github/workflows/release_arm.yml | 131 ------------------------------ 2 files changed, 87 insertions(+), 131 deletions(-) delete mode 100644 .github/workflows/release_arm.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4618858..fad21ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -206,3 +206,90 @@ jobs: asset_path: ${{ steps.deb.outputs.path }} asset_name: ${{ steps.deb.outputs.name }} asset_content_type: application/vnd.debian.binary-package + build: + name: Build ARM Release + needs: + - create-release + runs-on: ubuntu-latest + env: + OPENSSL_STATIC: 1 + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + lfs: true + + - name: Get upload url + id: release_upload_url + uses: actions/github-script@0.9.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + result-encoding: string + script: | + let tag = context.payload.ref.replace(/.*\//, ''); + let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { + owner: context.repo.owner, + repo: context.repo.repo, + tag: tag + }); + console.log(release.data.upload_url); + return release.data.upload_url + + - name: Install last stable Rust cross compiler + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: aarch64-unknown-linux-musl + override: true + + - name: Build proxy + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: -p ya-http-proxy --bin ya-http-proxy --features bin --release --target aarch64-unknown-linux-musl + + - name: Build runtime + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --target aarch64-unknown-linux-musl + + - name: Pack + id: pack + shell: bash + env: + GITHUB_REF: ${{ github.ref }} + OS_NAME: linux + run: | + TAG_NAME="${GITHUB_REF##*/}" + TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} + + ls -la target + mkdir -p "$TARGET_DIR/ya-runtime-http-auth" + #strip "target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth" + #strip "target/aarch64-unknown-linux-musl/release/ya-http-proxy" + + set -x + cp target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" + cp target/aarch64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" + cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" + (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") + + echo "::set-output name=artifact::ya-runtime-http-auth-arm-${TAG_NAME}.tar.gz" + echo "::set-output name=media::application/tar+gzip" + + - name: Upload + run: echo todo upload ${{ steps.pack.outputs.artifact }} + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_upload_url.outputs.result }} + asset_path: ./releases/${{ steps.pack.outputs.artifact }} + asset_name: ${{ steps.pack.outputs.artifact }} + asset_content_type: ${{ steps.pack.outputs.media }} \ No newline at end of file diff --git a/.github/workflows/release_arm.yml b/.github/workflows/release_arm.yml deleted file mode 100644 index d39226c..0000000 --- a/.github/workflows/release_arm.yml +++ /dev/null @@ -1,131 +0,0 @@ -name: Release ARM -on: - push: - tags: - - v* - - pre-rel-* - -jobs: - create-release: - name: "Create Release" - runs-on: ubuntu-latest - steps: - - name: Create Release - uses: actions/github-script@v3.0 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - let tag = context.payload.ref.replace(/.*\//, ''); - let buildNo = context.runNumber; - let versionName = tag.replace(/^pre-rel-/,''); - try { - let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { - owner: context.repo.owner, - repo: context.repo.repo, - tag: tag - }); - } - catch(e) { - let body = ["TODO"].join("\n"); - - let release = await github.request("POST /repos/:owner/:repo/releases", { - owner: context.repo.owner, - repo: context.repo.repo, - data: { - tag_name: tag, - prerelease: true, - body: body, - name: `${versionName} #${buildNo}` - } - }); - console.log(release.data.upload_url); - } - - build: - name: Build Release - needs: - - create-release - runs-on: ubuntu-latest - env: - OPENSSL_STATIC: 1 - steps: - - name: Checkout - uses: actions/checkout@v1 - with: - lfs: true - - - name: Get upload url - id: release_upload_url - uses: actions/github-script@0.9.0 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - result-encoding: string - script: | - let tag = context.payload.ref.replace(/.*\//, ''); - let release = await github.request("GET /repos/:owner/:repo/releases/tags/:tag", { - owner: context.repo.owner, - repo: context.repo.repo, - tag: tag - }); - console.log(release.data.upload_url); - return release.data.upload_url - - - name: Install last stable Rust cross compiler - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: aarch64-unknown-linux-musl - override: true - - - name: Build proxy - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: -p ya-http-proxy --bin ya-http-proxy --features bin --release --target aarch64-unknown-linux-musl - - - name: Build runtime - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --release --target aarch64-unknown-linux-musl - - - name: Pack - id: pack - shell: bash - env: - GITHUB_REF: ${{ github.ref }} - OS_NAME: linux - run: | - TAG_NAME="${GITHUB_REF##*/}" - TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} - - ls -la target - mkdir -p "$TARGET_DIR/ya-runtime-http-auth" - #strip "target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth" - #strip "target/aarch64-unknown-linux-musl/release/ya-http-proxy" - - set -x - cp target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" - cp target/aarch64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" - cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" - (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") - - echo "::set-output name=artifact::ya-runtime-http-auth-arm-${TAG_NAME}.tar.gz" - echo "::set-output name=media::application/tar+gzip" - - - name: Upload - run: echo todo upload ${{ steps.pack.outputs.artifact }} - - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.release_upload_url.outputs.result }} - asset_path: ./releases/${{ steps.pack.outputs.artifact }} - asset_name: ${{ steps.pack.outputs.artifact }} - asset_content_type: ${{ steps.pack.outputs.media }} - From 5041de8a1ec8412680665741f72704aae7a44112 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Tue, 30 Aug 2022 19:25:59 +0200 Subject: [PATCH 17/18] fix --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fad21ce..3688f54 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -206,7 +206,7 @@ jobs: asset_path: ${{ steps.deb.outputs.path }} asset_name: ${{ steps.deb.outputs.name }} asset_content_type: application/vnd.debian.binary-package - build: + build-arm: name: Build ARM Release needs: - create-release From 8925f42b934d39b7e4d4230215ceab9e88cdb281 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 2 Sep 2022 18:39:55 +0200 Subject: [PATCH 18/18] fix upload dir --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3688f54..40a6c40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -264,7 +264,7 @@ jobs: OS_NAME: linux run: | TAG_NAME="${GITHUB_REF##*/}" - TARGET_DIR=releases/ya-runtime-http-auth-linux-${TAG_NAME} + TARGET_DIR=releases/ya-runtime-http-auth-arm-${TAG_NAME} ls -la target mkdir -p "$TARGET_DIR/ya-runtime-http-auth" @@ -275,7 +275,7 @@ jobs: cp target/aarch64-unknown-linux-musl/release/ya-runtime-http-auth "$TARGET_DIR/ya-runtime-http-auth/" cp target/aarch64-unknown-linux-musl/release/ya-http-proxy "$TARGET_DIR/ya-runtime-http-auth/" cp conf/ya-runtime-http-auth.json "$TARGET_DIR/" - (cd releases && tar czvf "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-${OS_NAME}-${TAG_NAME}") + (cd releases && tar czvf "ya-runtime-http-auth-arm-${TAG_NAME}.tar.gz" "ya-runtime-http-auth-arm-${TAG_NAME}") echo "::set-output name=artifact::ya-runtime-http-auth-arm-${TAG_NAME}.tar.gz" echo "::set-output name=media::application/tar+gzip"