diff --git a/README.md b/README.md index 8045f26776..effb08a49f 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ https://github.com/windmill-labs/windmill/assets/122811744/0b132cd1-ee67-4505-82 - [Postgres without superuser](#postgres-without-superuser) - [Commercial license](#commercial-license) - [OAuth for self-hosting](#oauth-for-self-hosting) - - [smtp for self-hostring](#smtp-for-self-hostring) + - [smtp for self-hosting](#smtp-for-self-hosting) - [Resource types](#resource-types) - [Environment Variables](#environment-variables) - [Run a local dev setup](#run-a-local-dev-setup) @@ -297,7 +297,7 @@ You may also add your own custom OAuth2 IdP and OAuth2 Resource provider: } ``` -### smtp for self-hostring +### smtp for self-hosting For users to receive emails when you invite them to workspaces or add them to the instances using their emails, configure the SMTP env variables in the diff --git a/backend/windmill-api/src/workspaces.rs b/backend/windmill-api/src/workspaces.rs index cc94ea30c8..cb94d0e356 100644 --- a/backend/windmill-api/src/workspaces.rs +++ b/backend/windmill-api/src/workspaces.rs @@ -133,6 +133,8 @@ struct EditCommandScript { slack_command_script: Option, } + +#[cfg(feature = "enterprise")] #[derive(Deserialize)] struct EditDeployTo { deploy_to: Option, @@ -477,6 +479,8 @@ async fn edit_slack_command( Ok(format!("Edit command script {}", &w_id)) } + +#[cfg(feature = "enterprise")] async fn edit_deploy_to( authed: Authed, Extension(db): Extension, @@ -485,12 +489,6 @@ async fn edit_deploy_to( Json(es): Json, ) -> Result { require_admin(is_admin, &username)?; - #[cfg(not(feature = "enterprise"))] - { - return Err(Error::BadRequest( - "Deploy to is only available on enterprise".to_string(), - )); - } let mut tx = db.begin().await?; sqlx::query!( @@ -522,6 +520,13 @@ async fn edit_deploy_to( Ok(format!("Edit deploy to for {}", &w_id)) } +#[cfg(not(feature = "enterprise"))] +async fn edit_deploy_to() -> Result { + return Err(Error::BadRequest( + "Deploy to is only available on enterprise".to_string(), + )); +} + const BANNED_DOMAINS: &str = include_str!("../banned_domains.txt"); async fn is_allowed_auto_domain(Authed { email, .. }: Authed) -> JsonResult { diff --git a/backend/windmill-audit/src/lib.rs b/backend/windmill-audit/src/lib.rs index 34308d3ccb..fce15ae72b 100644 --- a/backend/windmill-audit/src/lib.rs +++ b/backend/windmill-audit/src/lib.rs @@ -47,22 +47,22 @@ pub async fn audit_log<'c, E: sqlx::Executor<'c, Database = Postgres>>( operation: &str, action_kind: ActionKind, w_id: &str, - resource: Option<&str>, - parameters: Option>, + _resource: Option<&str>, + _parameters: Option>, ) -> Result<()> { #[cfg(feature = "enterprise")] - let p_json: serde_json::Value = serde_json::to_value(¶meters).unwrap(); + let p_json: serde_json::Value = serde_json::to_value(&_parameters).unwrap(); #[cfg(not(feature = "enterprise"))] let p_json: serde_json::Value = serde_json::json!({"redacted": "-"}); #[cfg(not(feature = "enterprise"))] - let resource: Option<&str> = Some("EE only"); + let _resource: Option<&str> = Some("EE only"); tracing::info!( operation = operation, action_kind = ?action_kind, - resource = resource, + resource = _resource, parameters = %p_json, workspace_id = w_id, username = username, @@ -77,7 +77,7 @@ pub async fn audit_log<'c, E: sqlx::Executor<'c, Database = Postgres>>( .bind(username) .bind(operation) .bind(action_kind) - .bind(resource) + .bind(_resource) .bind(p_json) .execute(db) .await?; diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 99e96a7f37..a4de30469e 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -6,11 +6,7 @@ * LICENSE-AGPL for a copy of the license. */ -use std::{ - collections::HashMap, - time::{Instant, SystemTime}, - vec, -}; +use std::{collections::HashMap, vec}; use async_recursion::async_recursion; use itertools::Itertools; @@ -32,7 +28,6 @@ use windmill_common::{ schedule::{schedule_to_user, Schedule}, scripts::{ScriptHash, ScriptLang}, users::username_to_permissioned_as, - utils::rd_string, METRICS_ENABLED, }; @@ -82,8 +77,11 @@ lazy_static::lazy_static! { ACCEPTED_TAGS.clone().into_iter().map(|x| format!("(tag = '{x}')")).join(" OR ")); } +#[cfg(feature = "enterprise")] const MAX_FREE_EXECS: i32 = 1000; +#[cfg(feature = "enterprise")] const MAX_FREE_CONCURRENT_RUNS: i32 = 15; + const RSMQ_MAIN_QUEUE: &'static str = "main_queue"; #[async_recursion] @@ -246,7 +244,7 @@ pub async fn add_completed_job( .flatten(); let mut tx: QueueTransaction<'_, R> = (rsmq, db.begin().await?).into(); let job_id = queued_job.id.clone(); - let duration = sqlx::query_scalar!( + let _duration = sqlx::query_scalar!( "INSERT INTO completed_job AS cj ( workspace_id , id @@ -338,8 +336,8 @@ pub async fn add_completed_job( tx.commit().await?; #[cfg(feature = "enterprise")] - if !is_flow && duration > 1000 { - let additional_usage = duration / 1000; + if !is_flow && _duration > 1000 { + let additional_usage = _duration / 1000; let w_id = &queued_job.workspace_id; let premium_workspace = *CLOUD_HOSTED && sqlx::query_scalar!("SELECT premium FROM workspace WHERE id = $1", w_id) diff --git a/backend/windmill-worker/src/python_executor.rs b/backend/windmill-worker/src/python_executor.rs index 7fb82f2566..1f0937f951 100644 --- a/backend/windmill-worker/src/python_executor.rs +++ b/backend/windmill-worker/src/python_executor.rs @@ -49,11 +49,14 @@ const RELATIVE_PYTHON_LOADER: &str = include_str!("../loader.py"); #[cfg(feature = "enterprise")] use crate::global_cache::{build_tar_and_push, pull_from_tar}; +#[cfg(feature = "enterprise")] +use crate::S3_CACHE_BUCKET; + use crate::{ common::{read_result, set_logs}, create_args_and_out_file, get_reserved_variables, handle_child, write_file, AuthedClientBackgroundTask, DISABLE_NSJAIL, DISABLE_NUSER, HTTPS_PROXY, HTTP_PROXY, NO_PROXY, - NSJAIL_PATH, PATH_ENV, PIP_CACHE_DIR, S3_CACHE_BUCKET, + NSJAIL_PATH, PATH_ENV, PIP_CACHE_DIR, }; pub async fn create_dependencies_dir(job_dir: &str) { diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 36df748f31..3a37469a2f 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -13,11 +13,11 @@ use once_cell::sync::OnceCell; use serde::Deserialize; use sqlx::{Pool, Postgres}; use tokio_postgres::NoTls; -use windmill_api_client::{Client, types::CompletedJob}; +use windmill_api_client::{Client}; use windmill_parser::Typ; use std::{ borrow::Borrow, collections::HashMap, io, os::unix::process::ExitStatusExt, panic, - process::Stdio, time::{Duration, SystemTime}, + process::Stdio, time::{Duration}, sync::{Arc, atomic::Ordering}, collections::hash_map::DefaultHasher, hash::{Hasher, Hash}, @@ -43,9 +43,12 @@ use tokio::{ sync::{ mpsc::{self, Sender}, watch, broadcast, RwLock, Barrier }, - time::{interval, sleep, Instant, MissedTickBehavior}, join + time::{interval, sleep, Instant, MissedTickBehavior} }; +#[cfg(feature = "enterprise")] +use tokio::join; + use futures::{ future::{self, ready, FutureExt}, stream, StreamExt, @@ -419,8 +422,9 @@ pub async fn run_worker(2); + let (_copy_to_bucket_tx, mut copy_to_bucket_rx) = mpsc::channel::<()>(2); + #[cfg(feature = "enterprise")] let mut copy_cache_from_bucket_handle: Option> = None; tracing::info!(worker = %worker_name, "starting worker"); @@ -436,7 +440,7 @@ pub async fn run_worker NUM_SECS_PING { diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index 957c2d987b..2faf80ea5b 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -10,7 +10,7 @@ use std::collections::HashMap; use std::time::Duration; use crate::js_eval::{eval_timeout, IdContext}; -use crate::{worker, AuthedClient, KEEP_JOB_DIR}; +use crate::{AuthedClient, KEEP_JOB_DIR}; use anyhow::Context; use async_recursion::async_recursion; use serde_json::{json, Map, Value};