From 6e565b0dcb0fb56b69131c262d482c82bb6c527b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 16 Oct 2026 18:47:41 +0200 Subject: [PATCH 01/46] feat: route dev workspace and fork jobs to their own worker groups (#11811) * feat: route dev workspace and fork jobs to their own worker groups * fix: harden dev workspace isolation against review findings * fix: verify hashed dedicated tags and keep dev lineage across renames * fix: let tag-scoped tokens reach jobs queued on dev workspace tags * fix: expand tag scopes only in dev workspaces and forks * fix: expand tag scopes only while dev workspace isolation is on Co-Authored-By: Claude Opus 5.5 * feat: collapse the dev workspace isolation section by default Co-Authored-By: Claude Opus 5.5 * feat: count dev workspace isolation toggles and dev-serving group flags Co-Authored-By: Claude Opus 5.5 * fix: validate the dev workspace tag suffix on every instance config writer Co-Authored-By: Claude Opus 5.5 * chore: update ee-repo-ref to 71e9c0de8317e839f955ebef6a819062f20ac418 This commit updates the EE repository reference after PR #892 was merged in windmill-ee-private. Previous ee-repo-ref: b5ab84e1705f939c399f6315a03f88b55bce1804 New ee-repo-ref: 71e9c0de8317e839f955ebef6a819062f20ac418 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: windmill-internal-app[bot] --- ...cd674de140b7f93897286447279e74777e99e.json | 28 + ...e169f51dbbdc3584d3522f25e97e180e307fd.json | 20 + ...3be2e6e6e3b03e61ce8f2879627115224c8cf.json | 22 + backend/Cargo.lock | 1 + backend/ee-repo-ref.txt | 2 +- backend/src/main.rs | 24 +- backend/src/monitor.rs | 55 +- backend/tests/dev_workspace_tag_suffix.rs | 177 +++++++ backend/tests/instance_config.rs | 26 + backend/windmill-api-auth/src/auth.rs | 69 +++ backend/windmill-api-configs/src/lib.rs | 22 +- backend/windmill-api-jobs/src/jobs_export.rs | 5 +- backend/windmill-api-settings/src/lib.rs | 17 + backend/windmill-api-workers/Cargo.toml | 1 + backend/windmill-api-workers/src/lib.rs | 32 +- .../src/workspaces_extra.rs | 16 +- backend/windmill-api/openapi.yaml | 24 + backend/windmill-api/src/jobs.rs | 23 +- .../windmill-common/src/global_settings.rs | 17 + .../windmill-common/src/instance_config.rs | 15 + backend/windmill-common/src/worker.rs | 73 ++- backend/windmill-queue/src/jobs.rs | 11 +- backend/windmill-queue/src/tags.rs | 206 +++++++- backend/windmill-worker/src/ai/tools.rs | 3 + backend/windmill-worker/src/worker_flow.rs | 83 ++- .../lib/components/DefaultTagsInner.svelte | 22 + .../components/DevWorkspaceIsolation.svelte | 495 ++++++++++++++++++ .../lib/components/DevWorkspaceSetting.svelte | 33 +- .../src/lib/components/WorkerGroup.svelte | 94 +++- .../src/lib/components/WorkerTagSelect.svelte | 45 +- .../jobs/MissingWorkerTagAlert.svelte | 32 +- .../src/lib/components/jobs/missingWorker.ts | 18 +- .../runs/NoWorkerWithTagWarning.svelte | 17 +- .../src/lib/components/runs/RunBadges.svelte | 27 +- .../CreateWorkspaceInner.svelte | 42 +- frontend/src/lib/consts.ts | 2 + frontend/src/lib/devWorkspaceTags.ts | 79 +++ .../(root)/(logged)/workers/+page.svelte | 27 +- 38 files changed, 1802 insertions(+), 103 deletions(-) create mode 100644 backend/.sqlx/query-043cd99b3da09bca6cd2cf1e0adcd674de140b7f93897286447279e74777e99e.json create mode 100644 backend/.sqlx/query-0fb0fea54a1580d4b7ffd37ca43e169f51dbbdc3584d3522f25e97e180e307fd.json create mode 100644 backend/.sqlx/query-2d22fe27288580cb727e43b2abe3be2e6e6e3b03e61ce8f2879627115224c8cf.json create mode 100644 backend/tests/dev_workspace_tag_suffix.rs create mode 100644 frontend/src/lib/components/DevWorkspaceIsolation.svelte create mode 100644 frontend/src/lib/devWorkspaceTags.ts diff --git a/backend/.sqlx/query-043cd99b3da09bca6cd2cf1e0adcd674de140b7f93897286447279e74777e99e.json b/backend/.sqlx/query-043cd99b3da09bca6cd2cf1e0adcd674de140b7f93897286447279e74777e99e.json new file mode 100644 index 0000000000..7f14dee4e2 --- /dev/null +++ b/backend/.sqlx/query-043cd99b3da09bca6cd2cf1e0adcd674de140b7f93897286447279e74777e99e.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH RECURSIVE chain AS (\n SELECT id, parent_workspace_id, is_dev_workspace, 0 AS depth\n FROM workspace WHERE id = $1\n UNION ALL\n SELECT w.id, w.parent_workspace_id, w.is_dev_workspace, chain.depth + 1\n FROM workspace w\n JOIN chain ON w.id = chain.parent_workspace_id\n WHERE chain.depth < 20\n )\n SELECT\n (SELECT id FROM chain\n WHERE parent_workspace_id IS NULL\n OR (is_dev_workspace AND id NOT LIKE 'wm-fork-%')\n ORDER BY depth LIMIT 1) AS id,\n (SELECT parent_workspace_id IS NOT NULL FROM chain WHERE depth = 0) AS has_parent\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "has_parent", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "043cd99b3da09bca6cd2cf1e0adcd674de140b7f93897286447279e74777e99e" +} diff --git a/backend/.sqlx/query-0fb0fea54a1580d4b7ffd37ca43e169f51dbbdc3584d3522f25e97e180e307fd.json b/backend/.sqlx/query-0fb0fea54a1580d4b7ffd37ca43e169f51dbbdc3584d3522f25e97e180e307fd.json new file mode 100644 index 0000000000..2afefc7ab8 --- /dev/null +++ b/backend/.sqlx/query-0fb0fea54a1580d4b7ffd37ca43e169f51dbbdc3584d3522f25e97e180e307fd.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT config FROM config WHERE name LIKE 'worker\\_\\_%'", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + true + ] + }, + "hash": "0fb0fea54a1580d4b7ffd37ca43e169f51dbbdc3584d3522f25e97e180e307fd" +} diff --git a/backend/.sqlx/query-2d22fe27288580cb727e43b2abe3be2e6e6e3b03e61ce8f2879627115224c8cf.json b/backend/.sqlx/query-2d22fe27288580cb727e43b2abe3be2e6e6e3b03e61ce8f2879627115224c8cf.json new file mode 100644 index 0000000000..95fd9a3a2f --- /dev/null +++ b/backend/.sqlx/query-2d22fe27288580cb727e43b2abe3be2e6e6e3b03e61ce8f2879627115224c8cf.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT config FROM config WHERE name = $1 FOR UPDATE", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "2d22fe27288580cb727e43b2abe3be2e6e6e3b03e61ce8f2879627115224c8cf" +} diff --git a/backend/Cargo.lock b/backend/Cargo.lock index f2571ecd5c..15b4e190fe 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -16229,6 +16229,7 @@ dependencies = [ "uuid", "windmill-api-auth", "windmill-common", + "windmill-queue", ] [[package]] diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index b40437560a..b68bd04e25 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -664708fff04d4f9e0660bcae3edb307fb2c9481b +71e9c0de8317e839f955ebef6a819062f20ac418 diff --git a/backend/src/main.rs b/backend/src/main.rs index fd953213a4..d5c51de819 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -44,7 +44,8 @@ use windmill_common::{ CRITICAL_ALERTS_ON_TOKEN_EXPIRY_SETTING, CRITICAL_ALERT_MUTE_UI_SETTING, CRITICAL_ALERT_MUTE_ZOMBIE_JOB_RESTART_SETTING, CRITICAL_ERROR_CHANNELS_SETTING, CUSTOM_TAGS_SETTING, DEFAULT_TAGS_PER_WORKSPACE_SETTING, DEFAULT_TAGS_WORKSPACES_SETTING, - DEPENDENCY_JOB_TAG_SETTING, DISABLE_PASSWORD_LOGIN_SETTING, EMAIL_DOMAIN_SETTING, + DEPENDENCY_JOB_TAG_SETTING, DEV_WORKSPACE_ISOLATION_SETTING, + DEV_WORKSPACE_TAG_SUFFIX_SETTING, DISABLE_PASSWORD_LOGIN_SETTING, EMAIL_DOMAIN_SETTING, ENV_SETTINGS, EXPOSE_DEBUG_METRICS_SETTING, EXPOSE_METRICS_SETTING, EXTRA_PIP_INDEX_URL_SETTING, FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX_SETTING, HTTP_ROUTE_DEFAULT_ALLOWED_ORIGINS_SETTING, HTTP_ROUTE_WORKSPACED_ROUTE_SETTING, @@ -129,7 +130,8 @@ use windmill_worker::{ use crate::monitor::{ initial_load, load_concurrency_key_max_queued, load_dependency_job_tag, - load_disable_password_login, load_fork_workspace_tag_append_fork_suffix, load_keep_job_dir, + load_dev_workspace_isolation, load_dev_workspace_tag_suffix, load_disable_password_login, + load_fork_workspace_tag_append_fork_suffix, load_keep_job_dir, load_mcp_disable_token_query_param, load_metrics_debug_enabled, load_preview_tags_override, load_require_preexisting_user, load_retention_period_overrides, load_tag_per_workspace_enabled, load_tag_per_workspace_workspaces, load_workspace_fairness_duration_secs, @@ -1052,12 +1054,8 @@ Windmill Community Edition {GIT_VERSION} // Before the first load: it can sign a token for instance object storage. #[cfg(all(feature = "enterprise", feature = "openidconnect", feature = "private"))] - windmill_common::oidc_ee::init_oidc_signing( - &conn, - server_mode, - killpill_rx.resubscribe(), - ) - .await?; + windmill_common::oidc_ee::init_oidc_signing(&conn, server_mode, killpill_rx.resubscribe()) + .await?; initial_load( &conn, @@ -1881,6 +1879,16 @@ async fn process_notify_event( tracing::error!("Error loading dependency job tag: {e:#}"); } } + DEV_WORKSPACE_ISOLATION_SETTING => { + if let Err(e) = load_dev_workspace_isolation(db).await { + tracing::error!("Error loading dev workspace isolation: {e:#}"); + } + } + DEV_WORKSPACE_TAG_SUFFIX_SETTING => match load_dev_workspace_tag_suffix(db).await { + Ok(true) if worker_mode => reload_worker_config(db, tx.clone(), true).await, + Ok(_) => (), + Err(e) => tracing::error!("Error loading dev workspace tag suffix: {e:#}"), + }, WORKSPACE_FAIRNESS_ENABLED_SETTING => { if let Err(e) = load_workspace_fairness_enabled(db).await { tracing::error!("Error loading workspace fairness enabled: {e:#}"); diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index 4fae6f34ab..03728c1d7b 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -60,7 +60,8 @@ use windmill_common::{ CRITICAL_ALERTS_ON_DB_OVERSIZE_SETTING, CRITICAL_ALERTS_ON_TOKEN_EXPIRY_SETTING, CRITICAL_ALERT_MUTE_UI_SETTING, CRITICAL_ALERT_MUTE_ZOMBIE_JOB_RESTART_SETTING, CRITICAL_ERROR_CHANNELS_SETTING, CUSTOM_TAGS_SETTING, DEFAULT_TAGS_PER_WORKSPACE_SETTING, - DEFAULT_TAGS_WORKSPACES_SETTING, DEPENDENCY_JOB_TAG_SETTING, DISABLE_PASSWORD_LOGIN, + DEFAULT_TAGS_WORKSPACES_SETTING, DEPENDENCY_JOB_TAG_SETTING, + DEV_WORKSPACE_ISOLATION_SETTING, DEV_WORKSPACE_TAG_SUFFIX_SETTING, DISABLE_PASSWORD_LOGIN, DISABLE_PASSWORD_LOGIN_SETTING, EXPOSE_DEBUG_METRICS_SETTING, EXPOSE_METRICS_SETTING, EXTRA_PIP_INDEX_URL_SETTING, FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX_SETTING, HUB_API_SECRET_SETTING, HUB_BASE_URL_SETTING, INSTANCE_PYTHON_VERSION_SETTING, @@ -89,11 +90,13 @@ use windmill_common::{ users::truncate_token, utils::{empty_as_none, now_from_db, report_critical_error, Mode, HUB_API_SECRET}, worker::{ - load_env_vars, load_init_bash_from_env, load_periodic_bash_script_from_env, - load_periodic_bash_script_interval_from_env, load_whitelist_env_vars_from_env, - load_worker_config, store_pull_query, store_suspended_pull_query, Connection, WorkerConfig, - CLOUD_HOSTED, CONCURRENCY_KEY_MAX_QUEUED, CONCURRENCY_KEY_MAX_QUEUED_DEFAULT, - DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, DEPENDENCY_JOB_TAG, + is_valid_dev_workspace_tag_suffix, load_env_vars, load_init_bash_from_env, + load_periodic_bash_script_from_env, load_periodic_bash_script_interval_from_env, + load_whitelist_env_vars_from_env, load_worker_config, store_pull_query, + store_suspended_pull_query, Connection, WorkerConfig, CLOUD_HOSTED, + CONCURRENCY_KEY_MAX_QUEUED, CONCURRENCY_KEY_MAX_QUEUED_DEFAULT, + DEFAULT_DEV_WORKSPACE_TAG_SUFFIX, DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, + DEPENDENCY_JOB_TAG, DEV_WORKSPACE_ISOLATION, DEV_WORKSPACE_TAG_SUFFIX, FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX, INDEXER_CONFIG, PREVIEW_TAGS_OVERRIDE, SMTP_CONFIG, WINDMILL_DIR, WORKER_CONFIG, WORKER_GROUP, WORKSPACE_FAIRNESS_DURATION_SECS, WORKSPACE_FAIRNESS_ENABLED, WORKSPACE_FAIRNESS_MAX_PERCENT, WORKSPACE_FAIRNESS_MIN_TOTAL, @@ -321,6 +324,13 @@ pub async fn initial_load( pass.setting(DEPENDENCY_JOB_TAG_SETTING, false, |v| async move { apply_dependency_job_tag(v) }); + // Ahead of the worker config reload below, which expands the tags with it. + pass.setting(DEV_WORKSPACE_TAG_SUFFIX_SETTING, false, |v| async move { + apply_dev_workspace_tag_suffix(v); + }); + pass.setting(DEV_WORKSPACE_ISOLATION_SETTING, false, |v| async move { + apply_dev_workspace_isolation(v) + }); // Load per-workspace retention overrides before the first cleanup tick so a fresh server // never sweeps globally without honoring configured longer-retention workspaces. @@ -1127,6 +1137,39 @@ pub fn apply_fork_workspace_tag_append_fork_suffix(value: Option error::Result { + let v = load_value_from_global_settings(db, DEV_WORKSPACE_TAG_SUFFIX_SETTING).await?; + Ok(apply_dev_workspace_tag_suffix(v)) +} + +pub fn apply_dev_workspace_tag_suffix(value: Option) -> bool { + let suffix = match value { + Some(serde_json::Value::String(t)) if !t.trim().is_empty() => t.trim().to_string(), + _ => DEFAULT_DEV_WORKSPACE_TAG_SUFFIX.to_string(), + }; + if !is_valid_dev_workspace_tag_suffix(&suffix) { + tracing::error!("Ignoring invalid dev workspace tag suffix {suffix:?}"); + return false; + } + let prev = DEV_WORKSPACE_TAG_SUFFIX.swap(std::sync::Arc::new(suffix.clone())); + *prev != suffix +} + +pub async fn load_dev_workspace_isolation(db: &DB) -> error::Result<()> { + let v = load_value_from_global_settings(db, DEV_WORKSPACE_ISOLATION_SETTING).await?; + apply_dev_workspace_isolation(v); + Ok(()) +} + +pub fn apply_dev_workspace_isolation(value: Option) { + DEV_WORKSPACE_ISOLATION.store( + matches!(value, Some(serde_json::Value::Bool(true))), + Ordering::Relaxed, + ); +} + pub async fn reload_critical_alert_mute_ui_setting(conn: &Connection) -> error::Result<()> { let v = load_value_from_global_settings_with_conn(conn, CRITICAL_ALERT_MUTE_UI_SETTING, true) .await?; diff --git a/backend/tests/dev_workspace_tag_suffix.rs b/backend/tests/dev_workspace_tag_suffix.rs new file mode 100644 index 0000000000..0969a0e45b --- /dev/null +++ b/backend/tests/dev_workspace_tag_suffix.rs @@ -0,0 +1,177 @@ +//! Sets the process-wide `DEV_WORKSPACE_ISOLATION`, so it lives in its own test binary: any other +//! test pushing a job in the same process would land on a suffixed tag. + +use std::collections::HashMap; + +use sqlx::{Pool, Postgres}; +use windmill_common::{ + jobs::{JobPayload, RawCode}, + runnable_settings::{ConcurrencySettings, DebouncingSettings}, + scripts::{ScriptHash, ScriptLang}, + worker::DEV_WORKSPACE_ISOLATION, +}; +use windmill_queue::{PushArgs, PushIsolationLevel}; + +async fn pushed_tag( + db: &Pool, + workspace_id: &str, + payload: JobPayload, + tag: Option<&str>, +) -> String { + try_pushed_tag(db, workspace_id, payload, tag) + .await + .expect("push must succeed") +} + +async fn try_pushed_tag( + db: &Pool, + workspace_id: &str, + payload: JobPayload, + tag: Option<&str>, +) -> Result { + let args = HashMap::new(); + let (id, tx) = windmill_queue::push( + db, + PushIsolationLevel::IsolatedRoot(db.clone()), + workspace_id, + payload, + PushArgs::from(&args), + "test-user", + "test@windmill.dev", + "u/test-user".to_string(), + None, + None, + None, + None, + None, + None, + None, + None, + false, + false, + None, + true, + tag.map(str::to_string), + None, + None, + None, + None, + false, + None, + None, + None, + None, + ) + .await?; + tx.commit().await.unwrap(); + Ok(sqlx::query_scalar("SELECT tag FROM v2_job WHERE id = $1") + .bind(id) + .fetch_one(db) + .await + .unwrap()) +} + +fn preview() -> JobPayload { + JobPayload::Code(RawCode { + hash: None, + content: "echo hi".to_string(), + path: None, + language: ScriptLang::Bash, + lock: None, + concurrency_settings: ConcurrencySettings::default().into(), + debouncing_settings: DebouncingSettings::default(), + cache_ttl: None, + cache_ignore_s3_path: None, + dedicated_worker: None, + modules: None, + tag: None, + }) +} + +#[sqlx::test(fixtures("base"))] +async fn dev_workspace_and_fork_jobs_run_on_suffixed_tags(db: Pool) { + DEV_WORKSPACE_ISOLATION.store(true, std::sync::atomic::Ordering::Relaxed); + + // A dev workspace, a fork of it, and a fork whose parent was deleted (`ON DELETE SET NULL`). + sqlx::query( + "INSERT INTO workspace (id, name, owner, parent_workspace_id, is_dev_workspace) VALUES + ('staging', 'staging', 'test-user', 'test-workspace', true), + ('wm-fork-a', 'fork', 'test-user', 'staging', false), + ('wm-fork-orphan', 'orphan', 'test-user', NULL, false)", + ) + .execute(&db) + .await + .unwrap(); + sqlx::query( + "INSERT INTO workspace_settings (workspace_id) + VALUES ('staging'), ('wm-fork-a'), ('wm-fork-orphan')", + ) + .execute(&db) + .await + .unwrap(); + + for (workspace, tag, expected) in [ + ("test-workspace", None, "bash"), + ("test-workspace", Some("gpu"), "gpu"), + ("staging", None, "bash-dev"), + ("staging", Some("gpu"), "gpu-dev"), + // A tag inherited from a dev job (a flow step, an agent's tool) is not suffixed twice. + ("staging", Some("gpu-dev"), "gpu-dev"), + ("wm-fork-a", None, "bash-dev"), + ("wm-fork-orphan", None, "bash-dev"), + ] { + assert_eq!( + pushed_tag(&db, workspace, preview(), tag).await, + expected, + "{workspace} with tag {tag:?}" + ); + } + + // A dedicated worker tag already names the workspace, and its worker is placed by hand. + let dedicated = JobPayload::ScriptHash { + hash: ScriptHash(123412), + path: "f/system/hello".to_string(), + cache_ttl: None, + cache_ignore_s3_path: None, + dedicated_worker: Some(true), + language: ScriptLang::Bun, + priority: None, + apply_preprocessor: false, + concurrency_settings: ConcurrencySettings::default(), + debouncing_settings: DebouncingSettings::default(), + labels: None, + job_token_scopes: None, + }; + assert_eq!( + pushed_tag(&db, "staging", dedicated, None).await, + "staging:f/system/hello" + ); + + // A hashed dedicated tag keeps only a prefix of its workspace id: a dev workspace sharing that + // prefix does not get to use another workspace's dedicated worker. + let root = "a".repeat(40); + let dev = format!("{root}-dev"); + sqlx::query( + "INSERT INTO workspace (id, name, owner, parent_workspace_id, is_dev_workspace) + VALUES ($1, 'root', 'test-user', NULL, false), ($2, 'dev', 'test-user', $1, true)", + ) + .bind(&root) + .bind(&dev) + .execute(&db) + .await + .unwrap(); + sqlx::query("INSERT INTO workspace_settings (workspace_id) VALUES ($1), ($2)") + .bind(&root) + .bind(&dev) + .execute(&db) + .await + .unwrap(); + let root_dedicated = + windmill_common::worker::dedicated_worker_tag(&root, "f/some/long/script/path"); + assert!( + try_pushed_tag(&db, &dev, preview(), Some(&root_dedicated)) + .await + .is_err(), + "{root_dedicated} must not stay unsuffixed, and suffixed it no longer fits a job tag" + ); +} diff --git a/backend/tests/instance_config.rs b/backend/tests/instance_config.rs index 24937a3ce5..18a7466637 100644 --- a/backend/tests/instance_config.rs +++ b/backend/tests/instance_config.rs @@ -1533,6 +1533,32 @@ async fn declarative_sync_rejects_an_unusable_instance_banner(db: Pool ); } +#[sqlx::test(fixtures("base"))] +async fn declarative_sync_rejects_an_unusable_dev_workspace_tag_suffix(db: Pool) { + clear_settings_and_configs(&db).await; + let before = count_global_settings(&db).await; + + let mut desired = BTreeMap::new(); + desired.insert( + "dev_workspace_tag_suffix".to_string(), + serde_json::json!("-dev' OR '1'='1"), + ); + + let err = windmill_common::instance_config::sync_global_settings_declarative( + &db, + &BTreeMap::new(), + &desired, + &(), + ) + .await + .expect_err("a suffix the workers would ignore must fail the sync"); + assert!( + err.to_string().contains("dev_workspace_tag_suffix"), + "the error should name the offending setting, got: {err}" + ); + assert_eq!(count_global_settings(&db).await, before); +} + #[sqlx::test(fixtures("base"))] async fn declarative_sync_rejects_a_malformed_max_token_expiration(db: Pool) { clear_settings_and_configs(&db).await; diff --git a/backend/windmill-api-auth/src/auth.rs b/backend/windmill-api-auth/src/auth.rs index 720111e89d..cb799bec25 100644 --- a/backend/windmill-api-auth/src/auth.rs +++ b/backend/windmill-api-auth/src/auth.rs @@ -6,6 +6,7 @@ use axum::{ }; use chrono::TimeZone; use http::{request::Parts, StatusCode}; +use itertools::Itertools; use quick_cache::sync::Cache; use serde::{Deserialize, Serialize}; use sqlx::FromRow; @@ -1022,6 +1023,53 @@ where } } +/// Adds the suffixed form of each tag of an `if_jobs:filter_tags:` scope: in a dev workspace a +/// job allowed on `gpu` is queued on `gpu-dev`, and the token must still reach the jobs it starts. +fn expand_filter_tags_with_dev_suffix(scopes: &mut [String], suffix: &str) { + for scope in scopes.iter_mut() { + if let Some(tags) = scope.strip_prefix("if_jobs:filter_tags:") { + let expanded = tags + .split(',') + .flat_map(|t| { + let suffixed = windmill_common::worker::with_dev_workspace_suffix(t, suffix); + [t.to_string(), suffixed] + }) + .unique() + .join(","); + *scope = format!("if_jobs:filter_tags:{expanded}"); + } + } +} + +/// Only while isolation is on and for a dev workspace or a fork, whose jobs get the suffix then: +/// otherwise the suffixed tags are other tags the token was not given. +async fn expand_filter_tags_for_dev_workspace( + db: &DB, + workspace_id: &str, + scopes: Option<&mut Vec>, +) { + let Some(scopes) = scopes else { return }; + if !windmill_common::worker::DEV_WORKSPACE_ISOLATION.load(std::sync::atomic::Ordering::Relaxed) + || !scopes.iter().any(|s| s.starts_with("if_jobs:filter_tags:")) + { + return; + } + let is_dev = workspace_id.starts_with(windmill_common::workspaces::WM_FORK_PREFIX) + || sqlx::query_scalar::<_, bool>( + "SELECT parent_workspace_id IS NOT NULL FROM workspace WHERE id = $1", + ) + .bind(workspace_id) + .fetch_optional(db) + .await + .ok() + .flatten() + .unwrap_or(false); + if is_dev { + let suffix = windmill_common::worker::DEV_WORKSPACE_TAG_SUFFIX.load(); + expand_filter_tags_with_dev_suffix(scopes, &suffix); + } +} + pub fn transform_old_scope_to_new_scope(scopes: Option<&mut Vec>) { if let Some(scopes) = scopes { for scope in scopes.iter_mut() { @@ -1172,6 +1220,14 @@ pub async fn resolve_opt_job_authed( let authed = &mut opt_job_authed.authed; if authed.scopes.is_some() && !own_job_runtime_route { transform_old_scope_to_new_scope(authed.scopes.as_mut()); + if let Some(w_id) = workspace_id.as_deref() { + expand_filter_tags_for_dev_workspace( + &cache.db, + w_id, + authed.scopes.as_mut(), + ) + .await; + } if let Err(err) = crate::scopes::check_scopes_for_route( authed.scopes.as_deref(), @@ -1359,6 +1415,19 @@ pub async fn list_tokens_internal( mod tests { use super::*; + #[test] + fn filter_tags_reach_their_dev_workspace_form() { + let mut scopes = vec![ + "jobs:read".to_string(), + "if_jobs:filter_tags:gpu,bash-dev".to_string(), + ]; + expand_filter_tags_with_dev_suffix(&mut scopes, "-dev"); + assert_eq!( + scopes, + vec!["jobs:read", "if_jobs:filter_tags:gpu,gpu-dev,bash-dev"] + ); + } + /// Dropping the `AUTH_CACHE` entry between the two resolutions is what makes a memo /// hit observable: only a working memo can answer the second one. #[tokio::test] diff --git a/backend/windmill-api-configs/src/lib.rs b/backend/windmill-api-configs/src/lib.rs index f1f4792e71..890a561679 100644 --- a/backend/windmill-api-configs/src/lib.rs +++ b/backend/windmill-api-configs/src/lib.rs @@ -273,18 +273,22 @@ async fn update_config( } let mut tx = db.begin().await?; - let was_paused = if name.starts_with("worker__") { + let previous = if name.starts_with("worker__") { sqlx::query_scalar!( - "SELECT COALESCE(config->'paused' = 'true'::jsonb, false) FROM config WHERE name = $1 FOR UPDATE", + "SELECT config FROM config WHERE name = $1 FOR UPDATE", &name ) .fetch_optional(&mut *tx) .await? .flatten() - .unwrap_or(false) } else { - false + None }; + let is_set = |c: Option<&serde_json::Value>, k: &str| { + c.and_then(|c| c.get(k)).and_then(|v| v.as_bool()) == Some(true) + }; + let was_paused = is_set(previous.as_ref(), "paused"); + let was_serving_dev = is_set(previous.as_ref(), "serves_dev_workspaces"); sqlx::query!( "INSERT INTO config (name, config) VALUES ($1, $2) ON CONFLICT (name) DO UPDATE SET config = EXCLUDED.config", &name, @@ -306,7 +310,7 @@ async fn update_config( tx.commit().await?; if name.starts_with("worker__") { - let paused = config.get("paused").and_then(|v| v.as_bool()) == Some(true); + let paused = is_set(Some(&config), "paused"); if paused != was_paused { windmill_common::feature_usage::log_feature_usage( "worker_group", @@ -314,6 +318,14 @@ async fn update_config( if paused { "pause" } else { "resume" }, ); } + let serving_dev = is_set(Some(&config), "serves_dev_workspaces"); + if serving_dev != was_serving_dev { + windmill_common::feature_usage::log_feature_usage( + "worker_group", + "dev_workspaces_toggle", + if serving_dev { "serve" } else { "stop" }, + ); + } } Ok(format!("Updated config {name}")) } diff --git a/backend/windmill-api-jobs/src/jobs_export.rs b/backend/windmill-api-jobs/src/jobs_export.rs index b2b69367bc..576d33bad5 100644 --- a/backend/windmill-api-jobs/src/jobs_export.rs +++ b/backend/windmill-api-jobs/src/jobs_export.rs @@ -434,6 +434,7 @@ pub async fn import_completed_jobs( pub async fn import_queued_jobs( authed: ApiAuthed, + Extension(db): Extension, Extension(user_db): Extension, Path(w_id): Path, Json(jobs): Json>, @@ -468,7 +469,9 @@ pub async fn import_queued_jobs( let mut tx = user_db.begin(&authed).await?; - for job in jobs { + for mut job in jobs { + // A fork's admin is whoever created it, so an imported tag is as untrusted as a pushed one. + job.tag = windmill_queue::tags::apply_dev_workspace_suffix(job.tag, &w_id, &db).await?; sqlx::query!( r#" INSERT INTO v2_job ( diff --git a/backend/windmill-api-settings/src/lib.rs b/backend/windmill-api-settings/src/lib.rs index f9ba1ff86f..d6803dc432 100644 --- a/backend/windmill-api-settings/src/lib.rs +++ b/backend/windmill-api-settings/src/lib.rs @@ -916,6 +916,7 @@ pub async fn set_global_setting_internal( run_setting_pre_write_hook(db, &key, &value).await?; + let turns_on = value.as_bool() == Some(true); match value { serde_json::Value::Null => { if instance_config::PROTECTED_SETTINGS.contains(&key.as_str()) { @@ -949,6 +950,14 @@ pub async fn set_global_setting_internal( } }; + if key == windmill_common::global_settings::DEV_WORKSPACE_ISOLATION_SETTING { + windmill_common::feature_usage::log_feature_usage( + "dev_workspace_isolation", + "toggle", + if turns_on { "on" } else { "off" }, + ); + } + if should_bump_instance_ai_revision { bump_instance_ai_config_revision(); } @@ -975,6 +984,14 @@ async fn run_setting_pre_write_hook( value: &serde_json::Value, ) -> error::Result<()> { match key { + windmill_common::global_settings::DEV_WORKSPACE_TAG_SUFFIX_SETTING => match value { + serde_json::Value::Null => {} + serde_json::Value::String(s) if s.trim().is_empty() => {} + suffix => windmill_common::global_settings::validate_dev_workspace_tag_suffix(suffix) + .map_err(|e| { + error::Error::BadRequest(format!("The dev workspace tag suffix {e}")) + })?, + }, // The instance AI config is written as an untyped blob through this generic // endpoint, so it never passes the typed check the workspace handler applies. // Rates that reach a cost total unbounded would make it negative or infinite. diff --git a/backend/windmill-api-workers/Cargo.toml b/backend/windmill-api-workers/Cargo.toml index 8e54d84e77..24f2bc5649 100644 --- a/backend/windmill-api-workers/Cargo.toml +++ b/backend/windmill-api-workers/Cargo.toml @@ -11,6 +11,7 @@ path = "src/lib.rs" [dependencies] windmill-api-auth.workspace = true windmill-common = { workspace = true, default-features = false } +windmill-queue.workspace = true axum.workspace = true chrono.workspace = true serde.workspace = true diff --git a/backend/windmill-api-workers/src/lib.rs b/backend/windmill-api-workers/src/lib.rs index 8ebee2a967..a7f488a7dd 100644 --- a/backend/windmill-api-workers/src/lib.rs +++ b/backend/windmill-api-workers/src/lib.rs @@ -21,7 +21,10 @@ use windmill_common::{ jobs::{HIDE_WORKERS_FOR_NON_ADMINS, TAGS_ARE_SENSITIVE}, queue_metrics::{read_queue_metrics_series, QueueMetricsSeries}, utils::{paginate, Pagination}, - worker::{ALL_TAGS, CUSTOM_TAGS_PER_WORKSPACE, DEFAULT_TAGS, DEFAULT_TAGS_PER_WORKSPACE}, + worker::{ + ALL_TAGS, CUSTOM_TAGS_PER_WORKSPACE, DEFAULT_TAGS, DEFAULT_TAGS_PER_WORKSPACE, + DEV_WORKSPACE_ISOLATION, DEV_WORKSPACE_TAG_SUFFIX, + }, workspaces::workspace_with_fork_ancestors, DB, }; @@ -37,6 +40,7 @@ pub fn global_service() -> Router { "/is_default_tags_per_workspace", get(get_default_tags_per_workspace), ) + .route("/dev_workspace_isolation", get(get_dev_workspace_isolation)) .route("/get_default_tags", get(get_default_tags)) .route("/queue_metrics", get(get_queue_metrics)) .route("/queue_metrics_series", get(get_queue_metrics_series)) @@ -186,7 +190,18 @@ async fn exists_workers_with_tags( let chain = workspace_with_fork_ancestors(&db, workspace).await?; let custom_tags = CUSTOM_TAGS_PER_WORKSPACE.load(); let allowed_tags = custom_tags.to_string_vec(Some(&chain)); - tags.retain(|t| allowed_tags.contains(t)); + // A dev workspace's jobs run on the suffixed form of the tags it may use. + let dev_suffix = windmill_queue::tags::dev_workspace_suffix_for(workspace, &db) + .await + .ok() + .flatten(); + tags.retain(|t| { + allowed_tags.contains(t) + || dev_suffix.as_deref().is_some_and(|s| { + t.strip_suffix(s) + .is_some_and(|b| allowed_tags.iter().any(|a| a == b)) + }) + }); } else { // No workspace provided and not superadmin - return empty return Ok(Json(std::collections::HashMap::new())); @@ -259,6 +274,19 @@ async fn get_default_tags_per_workspace() -> JsonResult { )) } +#[derive(Serialize)] +struct DevWorkspaceIsolation { + enabled: bool, + suffix: String, +} + +async fn get_dev_workspace_isolation() -> JsonResult { + Ok(Json(DevWorkspaceIsolation { + enabled: DEV_WORKSPACE_ISOLATION.load(std::sync::atomic::Ordering::Relaxed), + suffix: DEV_WORKSPACE_TAG_SUFFIX.load().to_string(), + })) +} + async fn get_default_tags() -> JsonResult> { Ok(Json(DEFAULT_TAGS.clone())) } diff --git a/backend/windmill-api-workspaces/src/workspaces_extra.rs b/backend/windmill-api-workspaces/src/workspaces_extra.rs index 67d31f8a77..dc40c72d13 100644 --- a/backend/windmill-api-workspaces/src/workspaces_extra.rs +++ b/backend/windmill-api-workspaces/src/workspaces_extra.rs @@ -868,11 +868,21 @@ pub(crate) async fn change_workspace_id( "Re-pushing jobs for {} enabled schedules", enabled_schedule_paths.len() ); - for schedule_path in &enabled_schedule_paths { - if let Some(schedule) = get_schedule_opt(&mut *tx, &rw.new_id, schedule_path).await? { - tx = push_scheduled_job(&db, tx, &schedule, None, None).await?; + windmill_queue::tags::carry_lineage_over_rename(&old_id, &rw.new_id, &db).await?; + let new_id = &rw.new_id; + let repushed = async { + for schedule_path in &enabled_schedule_paths { + if let Some(schedule) = get_schedule_opt(&mut *tx, new_id, schedule_path).await? { + tx = push_scheduled_job(&db, tx, &schedule, None, None).await?; + } } + Ok::<_, Error>(tx) } + .await; + if repushed.is_err() { + windmill_queue::tags::invalidate_fork_parent_cache(new_id); + } + let mut tx = repushed?; // After every workspace_settings write above: fork cleanup locks a settings row before the // registry, so taking the registry first here would deadlock with it. diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 943d05dc11..1c7619e1f8 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -11413,6 +11413,30 @@ paths: schema: type: boolean + /workers/dev_workspace_isolation: + get: + summary: get whether the jobs of dev workspaces and forks run on their own worker groups + operationId: getDevWorkspaceIsolation + tags: + - worker + responses: + "200": + description: dev workspace isolation + content: + application/json: + schema: + type: object + properties: + enabled: + type: boolean + description: whether new jobs of dev workspaces and forks are queued on suffixed tags + suffix: + type: string + description: the suffix of those tags, which worker groups serving dev workspaces listen with + required: + - enabled + - suffix + /w/{workspace}/workspace_dependencies/create: post: summary: create workspace dependencies diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index c567a593d9..a7e2915571 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -9264,6 +9264,7 @@ async fn run_inline_preview_script( return Err(operator_preview_refusal(job_id)); } check_scopes(&authed, || format!("jobs:run"))?; + windmill_queue::tags::check_inline_run_allowed(&w_id, &db).await?; if let Some(job_id) = job_id { register_potential_assets_on_inline_execution(job_id, &w_id, &preview); } @@ -9383,6 +9384,7 @@ async fn run_inline_script_inner( args: Option>>, user_db: Option, ) -> error::Result { + windmill_queue::tags::check_inline_run_allowed(&w_id, &db).await?; // An inline run executes with the caller's own token, so it cannot honour a script's // `job_token_scopes`: such a script only runs as a job. A path is resolved here, once, and // the version checked is the version run. @@ -10183,17 +10185,22 @@ async fn add_batch_jobs( let language = language.unwrap_or(ScriptLang::Deno); - let tag = if let Some(dedicated_worker) = dedicated_worker { + let tag = match (dedicated_worker, batch_info.tag) { // Same rule as `push`: a dedicated worker would run it with its own unscoped token. - if dedicated_worker && path.is_some() && job_token_scopes.is_none() { + (Some(true), _) if path.is_some() && job_token_scopes.is_none() => { windmill_common::worker::dedicated_worker_tag(&w_id, &path.clone().unwrap()) - } else { - format!("{}", language.as_str()) } - } else if let Some(tag) = batch_info.tag { - tag - } else { - format!("{}", language.as_str()) + (None, Some(tag)) => { + windmill_queue::tags::apply_dev_workspace_suffix(tag, &w_id, &db).await? + } + _ => { + windmill_queue::tags::apply_dev_workspace_suffix( + language.as_str().to_string(), + &w_id, + &db, + ) + .await? + } }; let mut tx = user_db.begin(&authed).await?; diff --git a/backend/windmill-common/src/global_settings.rs b/backend/windmill-common/src/global_settings.rs index 2bc303f5c2..9472655ce5 100644 --- a/backend/windmill-common/src/global_settings.rs +++ b/backend/windmill-common/src/global_settings.rs @@ -10,6 +10,8 @@ pub const FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX_SETTING: &str = "fork_workspace_tag_append_fork_suffix"; pub const PREVIEW_TAGS_OVERRIDE_SETTING: &str = "preview_tags_override"; pub const DEPENDENCY_JOB_TAG_SETTING: &str = "dependency_job_tag"; +pub const DEV_WORKSPACE_ISOLATION_SETTING: &str = "dev_workspace_isolation"; +pub const DEV_WORKSPACE_TAG_SUFFIX_SETTING: &str = "dev_workspace_tag_suffix"; pub const BASE_URL_SETTING: &str = "base_url"; pub const WS_BASE_URL_SETTING: &str = "ws_base_url"; pub const OAUTH_SETTING: &str = "oauths"; @@ -315,6 +317,21 @@ pub fn validate_accent_color(value: &serde_json::Value) -> Result<(), String> { Ok(()) } +/// Validate a non-empty [`DEV_WORKSPACE_TAG_SUFFIX_SETTING`] value. Every writer must call +/// it: a suffix that fails it is ignored at load, so the workers would listen on a suffix +/// the setting does not show. +pub fn validate_dev_workspace_tag_suffix(value: &serde_json::Value) -> Result<(), String> { + let s = value + .as_str() + .ok_or_else(|| "must be a string".to_string())?; + if !crate::worker::is_valid_dev_workspace_tag_suffix(s.trim()) { + return Err( + "may only contain letters, digits, '-', '_' and '.', up to 32 characters".to_string(), + ); + } + Ok(()) +} + /// The settings every signed-in browser reads on each full page load. #[derive(serde::Serialize, Clone, Debug, Default, PartialEq)] pub struct InstanceUi { diff --git a/backend/windmill-common/src/instance_config.rs b/backend/windmill-common/src/instance_config.rs index d19de41dcc..110384a0d6 100644 --- a/backend/windmill-common/src/instance_config.rs +++ b/backend/windmill-common/src/instance_config.rs @@ -263,6 +263,8 @@ pub struct GlobalSettings { #[serde(skip_serializing_if = "Option::is_none")] pub default_tags_per_workspace: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub dev_workspace_isolation: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub preview_tags_override: Option, #[serde(skip_serializing_if = "Option::is_none")] pub disable_hub: Option, @@ -279,6 +281,8 @@ pub struct GlobalSettings { #[serde(skip_serializing_if = "Option::is_none")] pub dependency_job_tag: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub dev_workspace_tag_suffix: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub ws_base_url: Option, #[serde(skip_serializing_if = "Option::is_none")] pub github_app_webhook_base_url: Option, @@ -970,6 +974,9 @@ pub struct WorkerGroupConfig { /// Workers of the group pull no new job while this is set; queued jobs wait. #[serde(skip_serializing_if = "Option::is_none")] pub paused: Option, + /// The group listens to its tags suffixed with the dev workspace tag suffix, and only to them. + #[serde(skip_serializing_if = "Option::is_none")] + pub serves_dev_workspaces: Option, /// Object store this group's dependency cache uses instead of the instance one. Same shape /// as the instance `object_store_cache_config`. #[serde(skip_serializing_if = "Option::is_none")] @@ -1499,6 +1506,14 @@ pub async fn sync_global_settings_declarative( .map_err(|e| anyhow::anyhow!("{accent_key}: {e}"))?, } + let suffix_key = crate::global_settings::DEV_WORKSPACE_TAG_SUFFIX_SETTING; + match desired.get(suffix_key) { + None | Some(serde_json::Value::Null) => {} + Some(serde_json::Value::String(s)) if s.trim().is_empty() => {} + Some(suffix) => crate::global_settings::validate_dev_workspace_tag_suffix(suffix) + .map_err(|e| anyhow::anyhow!("{suffix_key}: {e}"))?, + } + // An origin list that cannot be parsed is dropped at boot, leaving the // empty default — which is no restriction at all. Rejecting it here is what // keeps a typo in a ConfigMap from silently widening CORS instance-wide. diff --git a/backend/windmill-common/src/worker.rs b/backend/windmill-common/src/worker.rs index f5743782e3..2257327867 100644 --- a/backend/windmill-common/src/worker.rs +++ b/backend/windmill-common/src/worker.rs @@ -451,6 +451,13 @@ lazy_static::lazy_static! { pub static ref FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX: AtomicBool = AtomicBool::new(false); pub static ref PREVIEW_TAGS_OVERRIDE: AtomicBool = AtomicBool::new(false); pub static ref DEPENDENCY_JOB_TAG: arc_swap::ArcSwap> = arc_swap::ArcSwap::from_pointee(None); + /// Whether the jobs of dev workspaces and forks are queued on suffixed tags. + pub static ref DEV_WORKSPACE_ISOLATION: AtomicBool = AtomicBool::new(false); + /// The suffix of those tags. Groups serving dev workspaces listen with it whether isolation is + /// on or not, so turning it off leaves no job already queued on a suffixed tag unserved. + pub static ref DEV_WORKSPACE_TAG_SUFFIX: arc_swap::ArcSwap = arc_swap::ArcSwap::from_pointee(DEFAULT_DEV_WORKSPACE_TAG_SUFFIX.to_string()); + /// Whether this process's worker group serves dev workspaces, set when its config is loaded. + pub static ref WORKER_SERVES_DEV_WORKSPACES: AtomicBool = AtomicBool::new(false); pub static ref MAX_TIMEOUT: u64 = std::env::var("TIMEOUT") .ok() @@ -2418,9 +2425,45 @@ pub async fn update_worker_ping_main_loop_query( // occupancy_rate = $3, memory_usage = $4, wm_memory_usage = $5, vcpus = COALESCE($7, vcpus), // memory = COALESCE($8, memory), occupancy_rate_15s = $9, occupancy_rate_5m = $10, occupancy_rate_30m = $11 WHERE worker = $6", -const MAX_TAG_LEN: usize = 50; +/// The length of `v2_job.tag`. +pub const MAX_TAG_LEN: usize = 50; const HASH_SUFFIX_LEN: usize = 16; +pub const DEFAULT_DEV_WORKSPACE_TAG_SUFFIX: &str = "-dev"; + +/// The suffix new jobs of dev workspaces and forks get, `None` while isolation is off. +pub fn dev_workspace_tag_suffix() -> Option { + DEV_WORKSPACE_ISOLATION + .load(std::sync::atomic::Ordering::Relaxed) + .then(|| DEV_WORKSPACE_TAG_SUFFIX.load().to_string()) +} + +/// Worker tags are pasted into the pull queries as SQL literals and listed comma-separated, so +/// the suffix must not carry a quote, a comma or whitespace. +pub fn is_valid_dev_workspace_tag_suffix(suffix: &str) -> bool { + !suffix.is_empty() + && suffix.len() <= 32 + && suffix + .chars() + .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.')) +} + +/// `tag` as the workers serving dev workspaces listen to it. Idempotent, because a tag inherited +/// from a dev job (a flow step, an agent's tool) already carries the suffix. +pub fn with_dev_workspace_suffix(tag: &str, suffix: &str) -> String { + if tag.ends_with(suffix) { + tag.to_string() + } else { + format!("{tag}{suffix}") + } +} + +/// Whether `tag` has the shape of a [`dedicated_worker_tag`] too long to keep whole. Its prefix +/// alone does not tell whose it is: two workspaces may share it. +pub fn is_hashed_dedicated_worker_tag(tag: &str) -> bool { + tag.len() == MAX_TAG_LEN && tag.as_bytes().get(MAX_TAG_LEN - 1 - HASH_SUFFIX_LEN) == Some(&b'#') +} + pub fn dedicated_worker_tag(workspace_id: &str, path: &str) -> String { let full_tag = format!("{}:{}", workspace_id, path); if full_tag.len() <= MAX_TAG_LEN { @@ -2581,8 +2624,32 @@ pub async fn load_worker_config( }) .unwrap_or_else(|| DEFAULT_TAGS.clone()); + // A group serving dev workspaces listens to the suffixed form of its tags only, so it never + // takes a root workspace's job. Dedicated workers are placed by hand and keep their tags. + let dev_suffix = (config.serves_dev_workspaces == Some(true) + && dedicated_worker.is_none() + && dedicated_workers.is_none()) + .then(|| DEV_WORKSPACE_TAG_SUFFIX.load().to_string()); + WORKER_SERVES_DEV_WORKSPACES.store(dev_suffix.is_some(), std::sync::atomic::Ordering::Relaxed); + let worker_tags = match &dev_suffix { + Some(suffix) => worker_tags + .iter() + .map(|t| with_dev_workspace_suffix(t, suffix)) + .unique() + .collect_vec(), + None => worker_tags, + }; + let mut priority_tags_sorted: Vec = Vec::new(); - let priority_tags_map = config.priority_tags.unwrap_or_else(HashMap::new); + let priority_tags_map: HashMap = match &dev_suffix { + Some(suffix) => config + .priority_tags + .unwrap_or_default() + .into_iter() + .map(|(t, p)| (with_dev_workspace_suffix(&t, suffix), p)) + .collect(), + None => config.priority_tags.unwrap_or_else(HashMap::new), + }; if priority_tags_map.len() > 0 { let mut all_tags_set: HashSet = HashSet::from_iter(worker_tags.clone()); @@ -2778,6 +2845,7 @@ pub struct WorkerConfigOpt { pub native_mode: Option, pub object_store_cache_config: Option, pub paused: Option, + pub serves_dev_workspaces: Option, } impl Default for WorkerConfigOpt { @@ -2798,6 +2866,7 @@ impl Default for WorkerConfigOpt { native_mode: Default::default(), object_store_cache_config: Default::default(), paused: Default::default(), + serves_dev_workspaces: Default::default(), } } } diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 2ed6d034b2..eafb344870 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -4778,6 +4778,9 @@ pub async fn pull( } } }; + let tag = + crate::tags::apply_dev_workspace_suffix(tag, &job.workspace_id, db) + .await?; sqlx::query!( "UPDATE v2_job_queue SET tag = $1, running = false WHERE id = $2", tag, @@ -7372,7 +7375,8 @@ async fn push_inner<'c, 'd>( // A dedicated worker runs every job it serves with its own unscoped worker token, so a // job with a restricted token runs on the regular workers of its language instead. - let tag = if dedicated_worker.is_some_and(|x| x) && job_token_scopes.is_none() { + let on_dedicated_worker = dedicated_worker.is_some_and(|x| x) && job_token_scopes.is_none(); + let tag = if on_dedicated_worker { let flow_prefix = if job_kind == JobKind::Flow || job_kind == JobKind::FlowDependencies { "flow/" } else { @@ -7453,6 +7457,11 @@ async fn push_inner<'c, 'd>( } }) }; + let tag = if on_dedicated_worker { + tag + } else { + crate::tags::apply_dev_workspace_suffix(tag, workspace_id, db).await? + }; let mut tx = tx.into_tx().await?; diff --git a/backend/windmill-queue/src/tags.rs b/backend/windmill-queue/src/tags.rs index 5f076bd3b2..59af8f9e8d 100644 --- a/backend/windmill-queue/src/tags.rs +++ b/backend/windmill-queue/src/tags.rs @@ -1,6 +1,10 @@ use sqlx::{Pool, Postgres}; +use windmill_common::error::Error; use windmill_common::worker::{ - DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX, + dedicated_worker_tag, dev_workspace_tag_suffix, is_hashed_dedicated_worker_tag, + with_dev_workspace_suffix, DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, + DEV_WORKSPACE_TAG_SUFFIX, FORK_WORKSPACE_TAG_APPEND_FORK_SUFFIX, MAX_TAG_LEN, + WORKER_SERVES_DEV_WORKSPACES, }; use windmill_common::workspaces::WM_FORK_PREFIX; @@ -13,6 +17,10 @@ struct TagWorkspace { /// Whether the `-fork` suffix may apply: the workspace shares an ancestor's id, or carries the /// generated prefix itself. is_fork: bool, + /// Whether the workspace's jobs run on the workers serving dev workspaces: it has a parent, + /// or carries the generated prefix (a fork orphaned by its parent's deletion stays a fork). + /// `None` when the lookup failed. + is_dev: Option, } lazy_static::lazy_static! { @@ -140,9 +148,153 @@ pub async fn per_workspace_tag(workspace_id: &str, db: &Pool) -> Optio }) } +/// `tag`, fully resolved, as a job of `workspace_id` is queued on it: suffixed with the dev +/// workspace tag suffix when isolation is on and the workspace is a dev workspace or a fork, so +/// only the worker groups serving dev workspaces pick it up. A tag no group serves leaves the job +/// queued; it never falls back to the unsuffixed tag. Dedicated worker tags are exempt: they +/// already name the workspace and an admin places each dedicated worker by hand. +pub async fn apply_dev_workspace_suffix( + tag: String, + workspace_id: &str, + db: &Pool, +) -> Result { + let Some(suffix) = dev_workspace_suffix_for(workspace_id, db).await? else { + return Ok(tag); + }; + if is_dedicated_worker_tag_of(workspace_id, &tag, db).await? { + return Ok(tag); + } + let suffixed = with_dev_workspace_suffix(&tag, &suffix); + if suffixed.len() > MAX_TAG_LEN { + return Err(Error::BadRequest(format!( + "tag {tag} of a dev workspace job would be {suffixed} once suffixed with {suffix}, \ + longer than the {MAX_TAG_LEN} characters a job tag holds" + ))); + } + Ok(suffixed) +} + +/// Whether `tag` is a dedicated worker tag of `workspace_id`. A hashed one keeps only a prefix of +/// the workspace id, which another workspace may share, so it counts only when a worker group's +/// dedicated config for this workspace produces it. +async fn is_dedicated_worker_tag_of( + workspace_id: &str, + tag: &str, + db: &Pool, +) -> Result { + if tag.starts_with(&format!("{workspace_id}:")) { + return Ok(true); + } + if !is_hashed_dedicated_worker_tag(tag) { + return Ok(false); + } + let configs = sqlx::query_scalar!("SELECT config FROM config WHERE name LIKE 'worker\\_\\_%'") + .fetch_all(db) + .await?; + Ok(configs.into_iter().flatten().any(|config| { + let single = config.get("dedicated_worker").cloned().into_iter(); + let many = config + .get("dedicated_workers") + .and_then(|v| v.as_array().cloned()) + .unwrap_or_default(); + single.chain(many).any(|entry| { + entry + .as_str() + .and_then(|e| e.split_once(':')) + .is_some_and(|(ws, path)| { + ws == workspace_id && dedicated_worker_tag(ws, path) == tag + }) + }) + })) +} + +/// Gives `new_id` the lineage of `old_id` before a rename commits: the rename re-pushes the +/// workspace's schedules in its own transaction, where the new row is not yet visible to the +/// lookup, and a job queued then would keep a tag resolved without its parent for good. +pub async fn carry_lineage_over_rename( + old_id: &str, + new_id: &str, + db: &Pool, +) -> Result<(), Error> { + let old = lookup_tag_workspace(old_id, db).await; + if old.is_dev.is_none() { + return Err(Error::internal_err(format!( + "could not resolve the lineage of {old_id}" + ))); + } + let new = TagWorkspace { + id: if old.id == old_id { + new_id.to_string() + } else { + old.id + }, + ..old + }; + FORK_PARENT_CACHE.insert(new_id.to_string(), (new, std::time::Instant::now())); + Ok(()) +} + +/// The suffix to strip from a flow job's tag to compare it with the generic flow tags: that of a +/// dev workspace's flow, isolation on or off, so a flow started before isolation was turned off +/// still routes its steps by their own tags. +pub async fn dev_flow_tag_suffix( + workspace_id: &str, + flow_tag: &str, + db: &Pool, +) -> Result, Error> { + let suffix = DEV_WORKSPACE_TAG_SUFFIX.load().to_string(); + if !flow_tag.ends_with(&suffix) { + return Ok(None); + } + match lookup_tag_workspace(workspace_id, db).await.is_dev { + Some(true) => Ok(Some(suffix)), + Some(false) => Ok(None), + None => Err(Error::internal_err(format!( + "could not resolve whether {workspace_id} is a dev workspace" + ))), + } +} + +/// The suffix the jobs of `workspace_id` are queued with: `Some` while isolation is on and the +/// workspace is a dev workspace or a fork. A lineage that cannot be read is an error rather than +/// a guess, as either guess queues a job on the wrong pool for good. +pub async fn dev_workspace_suffix_for( + workspace_id: &str, + db: &Pool, +) -> Result, Error> { + let Some(suffix) = dev_workspace_tag_suffix() else { + return Ok(None); + }; + match lookup_tag_workspace(workspace_id, db).await.is_dev { + Some(true) => Ok(Some(suffix)), + Some(false) => Ok(None), + None => Err(Error::internal_err(format!( + "could not resolve whether {workspace_id} is a dev workspace, which decides the \ + workers its jobs run on" + ))), + } +} + +/// Refuses running code of `workspace_id` in this process, as the inline routes do, when its +/// jobs are isolated on dev workers and this process's group does not serve dev workspaces. +pub async fn check_inline_run_allowed( + workspace_id: &str, + db: &Pool, +) -> Result<(), Error> { + if dev_workspace_suffix_for(workspace_id, db).await?.is_some() + && !WORKER_SERVES_DEV_WORKSPACES.load(std::sync::atomic::Ordering::Relaxed) + { + return Err(Error::BadRequest(format!( + "{workspace_id} is a dev workspace or a fork, whose code runs only on worker groups \ + serving dev workspaces, and this worker's group does not: run it as a job instead" + ))); + } + Ok(()) +} + /// Backed by a short-TTL cache to avoid a DB round-trip per job push. A transient DB error resolves /// to the workspace's own id for this call but is NOT cached, so the next push retries instead of -/// misrouting for the whole TTL. +/// misrouting for the whole TTL. Whether the workspace is dev is then unknown. async fn lookup_tag_workspace(workspace_id: &str, db: &Pool) -> TagWorkspace { if let Some((resolved, cached_at)) = FORK_PARENT_CACHE.get(workspace_id) { if cached_at.elapsed().as_secs() < FORK_PARENT_CACHE_TTL_SECS { @@ -154,7 +306,7 @@ async fn lookup_tag_workspace(workspace_id: &str, db: &Pool) -> TagWor // itself under a generated fork id. The depth bound mirrors the other chain walkers as a // cycle-safety backstop. A `wm-fork-` workspace orphaned by `ON DELETE SET NULL` has no parent // left to borrow from, so it ends the walk on itself. - let resolved = match sqlx::query_scalar!( + let resolved = match sqlx::query!( r#" WITH RECURSIVE chain AS ( SELECT id, parent_workspace_id, is_dev_workspace, 0 AS depth @@ -165,35 +317,47 @@ async fn lookup_tag_workspace(workspace_id: &str, db: &Pool) -> TagWor JOIN chain ON w.id = chain.parent_workspace_id WHERE chain.depth < 20 ) - SELECT id AS "id!" FROM chain - WHERE parent_workspace_id IS NULL - OR (is_dev_workspace AND id NOT LIKE 'wm-fork-%') - ORDER BY depth LIMIT 1 + SELECT + (SELECT id FROM chain + WHERE parent_workspace_id IS NULL + OR (is_dev_workspace AND id NOT LIKE 'wm-fork-%') + ORDER BY depth LIMIT 1) AS id, + (SELECT parent_workspace_id IS NOT NULL FROM chain WHERE depth = 0) AS has_parent "#, workspace_id ) - .fetch_optional(db) + .fetch_one(db) .await { - // No row means the workspace does not exist yet, or its chain is broken: both are "we - // cannot resolve this", so fall back to its own id for this call WITHOUT caching. Caching - // it would pin a fork to its own unserved id for the whole TTL — a rename resolves the new - // id before the row lands, and every job pushed until the TTL expires would queue. - Ok(None) => { - return TagWorkspace { - id: workspace_id.to_string(), - is_fork: workspace_id.starts_with(WM_FORK_PREFIX), + Ok(row) => match row.id { + Some(id) => TagWorkspace { + is_fork: id != workspace_id || workspace_id.starts_with(WM_FORK_PREFIX), + is_dev: Some( + row.has_parent == Some(true) || workspace_id.starts_with(WM_FORK_PREFIX), + ), + id, + }, + // No id means the workspace does not exist yet, or its chain is broken: both are "we + // cannot resolve this", so fall back to its own id for this call WITHOUT caching. + // Caching it would pin a fork to its own unserved id for the whole TTL — a rename + // resolves the new id before the row lands, and every job pushed until the TTL + // expires would queue. + None => { + return TagWorkspace { + id: workspace_id.to_string(), + is_fork: workspace_id.starts_with(WM_FORK_PREFIX), + is_dev: Some( + row.has_parent == Some(true) || workspace_id.starts_with(WM_FORK_PREFIX), + ), + } } - } - Ok(Some(id)) => { - let is_fork = id != workspace_id || workspace_id.starts_with(WM_FORK_PREFIX); - TagWorkspace { id, is_fork } - } + }, Err(e) => { tracing::warn!("failed to resolve tag workspace for {workspace_id}: {e:#}"); return TagWorkspace { id: workspace_id.to_string(), is_fork: workspace_id.starts_with(WM_FORK_PREFIX), + is_dev: None, }; } }; diff --git a/backend/windmill-worker/src/ai/tools.rs b/backend/windmill-worker/src/ai/tools.rs index 1a478292cb..0bc7bf6777 100644 --- a/backend/windmill-worker/src/ai/tools.rs +++ b/backend/windmill-worker/src/ai/tools.rs @@ -577,6 +577,9 @@ async fn enqueue_windmill_tool( &ctx.job.workspace_id, ctx.preserve_step_tags, job_payload.tag.as_deref(), + windmill_queue::tags::dev_flow_tag_suffix(&ctx.job.workspace_id, &ctx.job.tag, ctx.db) + .await? + .as_deref(), ); if tool_tag.as_deref().is_some_and(tag_reads_flow_expr) { append_logs( diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index a257ca51fa..c188f8de58 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -1631,7 +1631,17 @@ pub async fn update_flow_status_after_job_completion_internal( Some(t) => { let no_args = HashMap::new(); let args = PushArgs::from(fetched_args.as_ref().unwrap_or(&no_args)); - resolve_push_tag(t, &args, &flow_job.workspace_id, db).await + match resolve_push_tag(t, &args, &flow_job.workspace_id, db).await { + Some(t) => Some( + windmill_queue::tags::apply_dev_workspace_suffix( + t, + &flow_job.workspace_id, + db, + ) + .await?, + ), + None => None, + } } None => None, }; @@ -2210,7 +2220,8 @@ pub async fn update_flow_status_after_job_completion_internal( None }, has_triggered_error_handler: has_triggered_error_handler || is_failure_step, - recovered_by_child: failure_step_recovers || (recovered_by_child && !success), + recovered_by_child: failure_step_recovers + || (recovered_by_child && !success), }, )); } @@ -3284,8 +3295,17 @@ pub(crate) fn resolve_flow_step_tag( workspace_id: &str, preserve_step_tags: bool, step_tag: Option<&str>, + // The suffix of a dev workspace's flow tag, if any: its flows run on the generic tag suffixed, + // and their steps are suffixed when pushed. + dev_suffix: Option<&str>, ) -> Option { - if is_preprocessor_step || flow_tag == "flow" || flow_tag == format!("flow-{}", workspace_id) { + let generic_flow_tag = dev_suffix + .and_then(|s| flow_tag.strip_suffix(s)) + .unwrap_or(flow_tag); + if is_preprocessor_step + || generic_flow_tag == "flow" + || generic_flow_tag == format!("flow-{}", workspace_id) + { step_tag.map(str::to_string) } else if preserve_step_tags && step_tag.is_some_and(|t| !t.is_empty()) { step_tag.map(str::to_string) @@ -3363,7 +3383,14 @@ mod tag_resolution_tests { // Parent flow on a custom tag, step declares its own tag, preserve disabled: // the step inherits the flow tag (historical behavior). assert_eq!( - resolve_flow_step_tag(false, "worker-group-A", "w1", false, Some("worker-group-B")), + resolve_flow_step_tag( + false, + "worker-group-A", + "w1", + false, + Some("worker-group-B"), + None + ), Some("worker-group-A".to_string()) ); } @@ -3373,7 +3400,14 @@ mod tag_resolution_tests { // The exact customer scenario: a sub-flow tagged worker-group-B run as a step of a // flow tagged worker-group-A now runs on worker-group-B when preserve_step_tags is on. assert_eq!( - resolve_flow_step_tag(false, "worker-group-A", "w1", true, Some("worker-group-B")), + resolve_flow_step_tag( + false, + "worker-group-A", + "w1", + true, + Some("worker-group-B"), + None + ), Some("worker-group-B".to_string()) ); } @@ -3381,12 +3415,12 @@ mod tag_resolution_tests { #[test] fn untagged_step_inherits_flow_tag_even_when_preserve_enabled() { assert_eq!( - resolve_flow_step_tag(false, "worker-group-A", "w1", true, None), + resolve_flow_step_tag(false, "worker-group-A", "w1", true, None, None), Some("worker-group-A".to_string()) ); // An empty tag counts as "no tag" and still inherits. assert_eq!( - resolve_flow_step_tag(false, "worker-group-A", "w1", true, Some("")), + resolve_flow_step_tag(false, "worker-group-A", "w1", true, Some(""), None), Some("worker-group-A".to_string()) ); } @@ -3395,16 +3429,38 @@ mod tag_resolution_tests { fn generic_flow_tag_always_uses_step_tag() { for flow_tag in ["flow", "flow-w1"] { assert_eq!( - resolve_flow_step_tag(false, flow_tag, "w1", false, Some("worker-group-B")), + resolve_flow_step_tag(false, flow_tag, "w1", false, Some("worker-group-B"), None), Some("worker-group-B".to_string()) ); } } + #[test] + fn dev_workspace_flow_on_suffixed_generic_tag_uses_step_tag() { + for flow_tag in ["flow-dev", "flow-w1-dev"] { + assert_eq!( + resolve_flow_step_tag(false, flow_tag, "w1", false, Some("gpu"), Some("-dev")), + Some("gpu".to_string()) + ); + } + // In a root workspace `flow-dev` is a custom tag the steps inherit. + assert_eq!( + resolve_flow_step_tag(false, "flow-dev", "w1", false, Some("gpu"), None), + Some("flow-dev".to_string()) + ); + } + #[test] fn preprocessor_step_uses_step_tag() { assert_eq!( - resolve_flow_step_tag(true, "worker-group-A", "w1", false, Some("worker-group-B")), + resolve_flow_step_tag( + true, + "worker-group-A", + "w1", + false, + Some("worker-group-B"), + None + ), Some("worker-group-B".to_string()) ); } @@ -4654,6 +4710,9 @@ async fn push_next_flow_job( &flow_job.workspace_id, flow.preserve_step_tags, payload_tag.tag.as_deref(), + windmill_queue::tags::dev_flow_tag_suffix(&flow_job.workspace_id, &flow_job.tag, db) + .await? + .as_deref(), ); // A step whose inputs failed to evaluate, or whose `$flow_expr[...]` tag failed to resolve, @@ -4794,10 +4853,8 @@ async fn push_next_flow_job( // narrows that further. windmill_common::scopes::intersect_job_token_scopes( flow_job.job_token_scopes.as_deref(), - windmill_common::scopes::step_job_token_scopes( - module.job_token_scopes.as_deref(), - ) - .as_deref(), + windmill_common::scopes::step_job_token_scopes(module.job_token_scopes.as_deref()) + .as_deref(), ) .as_deref(), ) diff --git a/frontend/src/lib/components/DefaultTagsInner.svelte b/frontend/src/lib/components/DefaultTagsInner.svelte index 87cfa0f89b..229c0d5e62 100644 --- a/frontend/src/lib/components/DefaultTagsInner.svelte +++ b/frontend/src/lib/components/DefaultTagsInner.svelte @@ -19,6 +19,11 @@ import Section from './Section.svelte' import ToggleButtonGroup from './common/toggleButton-v2/ToggleButtonGroup.svelte' import ToggleButton from './common/toggleButton-v2/ToggleButton.svelte' + import { + devWorkspaceTagSuffix, + loadDevWorkspaceTagSuffix, + withDevSuffix + } from '$lib/devWorkspaceTags' interface Props { defaultTagPerWorkspace?: boolean | undefined defaultTagWorkspaces?: string[] @@ -134,6 +139,7 @@ loadDefaultTags() loadWorkspaces() + loadDevWorkspaceTagSuffix()
@@ -208,6 +214,22 @@ /> {/snippet} + {#if $devWorkspaceTagSuffix} + + Dev workspace isolation (Workers page) is on and applies after this: a fork's + {forkAppendForkSuffix ? 'python3-{parent_id}-fork' : 'python3-{parent_id}'} + runs as + {withDevSuffix( + forkAppendForkSuffix ? 'python3-{parent_id}-fork' : 'python3-{parent_id}', + $devWorkspaceTagSuffix + )}, on the worker groups serving dev workspaces. To split root and dev jobs across + worker pools, isolation alone is enough. + + {/if} + import { Alert, Button, Section } from './common' + import ConfirmationModal from './common/confirmationModal/ConfirmationModal.svelte' + import Toggle from './Toggle.svelte' + import TextInput from './text_input/TextInput.svelte' + import Select from './select/Select.svelte' + import Tooltip from './meltComponents/Tooltip.svelte' + import { ArrowRight, ChevronDown, ChevronRight, Save, Settings } from 'lucide-svelte' + import { + SettingService, + WorkerService, + WorkspaceService, + type GetQueueStatusResponse, + type Workspace + } from '$lib/gen' + import { DEV_WORKSPACE_ISOLATION_SETTING, DEV_WORKSPACE_TAG_SUFFIX_SETTING } from '$lib/consts' + import { + DEFAULT_DEV_WORKSPACE_TAG_SUFFIX, + DEV_WORKSPACE_TAG_SUFFIX_PATTERN, + devWorkspaceIsolation, + devWorkspaceListenSuffix, + devWorkspaceTagSuffix, + isDevOrForkWorkspace, + loadDevWorkspaceTagSuffix, + withDevSuffix + } from '$lib/devWorkspaceTags' + import { enterpriseLicense } from '$lib/stores' + import { sendUserToast } from '$lib/toast' + import { pluralize } from '$lib/utils' + import { onMount } from 'svelte' + + interface Props { + /** Worker group configs, by group name. */ + workerGroups: Record | undefined + /** Workers of each group that pinged in the last 15 seconds. */ + liveWorkers: Record + canEdit: boolean + onConfigureGroup: (name: string) => void + } + + let { workerGroups, liveWorkers, canEdit, onConfigureGroup }: Props = $props() + + let suffix = $derived($devWorkspaceTagSuffix) + let enabled = $derived(suffix != null) + let effectiveSuffix = $derived($devWorkspaceListenSuffix) + + // Overridden while a confirmation is pending, reset to the saved state otherwise. + let toggleChecked = $derived(enabled) + let suffixDraft = $derived(effectiveSuffix) + let suffixError = $derived( + DEV_WORKSPACE_TAG_SUFFIX_PATTERN.test(suffixDraft.trim()) + ? undefined + : "Use 1 to 32 letters, digits, '-', '_' or '.'" + ) + + let workspaces = $state(undefined) + let devWorkspaces = $derived( + (workspaces ?? []).filter((w) => !w.deleted && isDevOrForkWorkspace(w)) + ) + let workspaceNames = $derived(Object.fromEntries((workspaces ?? []).map((w) => [w.id, w.name]))) + + async function loadWorkspaces() { + const all: Workspace[] = [] + for (let page = 1; ; page++) { + const batch = await WorkspaceService.listWorkspacesAsSuperAdmin({ page, perPage: 100 }) + all.push(...batch) + if (batch.length < 100) break + } + workspaces = all + } + + let queueStatus = $state(undefined) + async function loadQueueStatus() { + try { + queueStatus = await WorkerService.getQueueStatus() + } catch { + queueStatus = undefined + } + } + + onMount(() => { + loadDevWorkspaceTagSuffix(true) + loadWorkspaces().catch((e) => console.error('Could not list workspaces', e)) + loadQueueStatus() + const interval = setInterval(loadQueueStatus, 15_000) + return () => clearInterval(interval) + }) + + type GroupEntry = { name: string; live: number; tags: string[] } + + function isDedicated(config: any): boolean { + return config?.dedicated_worker != undefined || (config?.dedicated_workers?.length ?? 0) > 0 + } + + let flaggedGroups: GroupEntry[] = $derived( + Object.entries(workerGroups ?? {}) + .filter(([_, c]) => c?.serves_dev_workspaces === true && !isDedicated(c)) + .map(([name, c]) => ({ name, live: liveWorkers[name] ?? 0, tags: c?.worker_tags ?? [] })) + ) + let liveFlaggedWorkers = $derived(flaggedGroups.reduce((acc, g) => acc + g.live, 0)) + let unflaggedGroupNames = $derived( + Object.entries(workerGroups ?? {}) + .filter(([_, c]) => c?.serves_dev_workspaces !== true && !isDedicated(c)) + .map(([name]) => name) + ) + // The only way to break isolation: an unflagged group listing a suffixed tag takes dev jobs. + let leakingGroups = $derived( + Object.entries(workerGroups ?? {}) + .filter(([_, c]) => c?.serves_dev_workspaces !== true) + .map(([name, c]) => ({ + name, + tags: ((c?.worker_tags ?? []) as string[]).filter((t) => t.endsWith(effectiveSuffix)) + })) + .filter((g) => g.tags.length > 0) + ) + let unservedDevTags = $derived( + enabled + ? (queueStatus ?? []).filter( + (s) => s.tag.endsWith(effectiveSuffix) && s.waiting > 0 && s.workers === 0 + ) + : [] + ) + + let groupToFlag = $state(undefined) + let collapsed = $state(true) + let showWorkspaces = $state(false) + let showAdvanced = $state(false) + + let confirmEnable = $state(false) + let confirmDisable = $state(false) + let saving = $state(false) + + async function setIsolation(on: boolean) { + saving = true + try { + await SettingService.setGlobal({ + key: DEV_WORKSPACE_ISOLATION_SETTING, + requestBody: { value: on } + }) + devWorkspaceIsolation.update((i) => ({ suffix: i?.suffix ?? effectiveSuffix, enabled: on })) + sendUserToast( + on + ? `Dev workspace and fork jobs now run on tags suffixed with ${effectiveSuffix}` + : 'Dev workspace isolation turned off' + ) + } catch (e) { + sendUserToast(`Could not save dev workspace isolation: ${e}`, true) + toggleChecked = enabled + } finally { + saving = false + } + } + + async function saveSuffix(value: string) { + saving = true + try { + await SettingService.setGlobal({ + key: DEV_WORKSPACE_TAG_SUFFIX_SETTING, + requestBody: { value } + }) + devWorkspaceIsolation.update((i) => ({ enabled: i?.enabled ?? false, suffix: value })) + sendUserToast(`Dev workspace tag suffix set to ${value}`) + } catch (e) { + sendUserToast(`Could not save the dev workspace tag suffix: ${e}`, true) + } finally { + saving = false + } + } + + function onToggle(checked: boolean) { + if (checked === enabled) return + collapsed = false + if (checked) { + if (liveFlaggedWorkers === 0) { + confirmEnable = true + } else { + setIsolation(true) + } + } else { + confirmDisable = true + } + } + + function workspaceKind(w: Workspace): string { + if (w.parent_workspace_id) { + const parent = workspaceNames[w.parent_workspace_id] ?? w.parent_workspace_id + return w.is_dev_workspace ? `dev workspace of ${parent}` : `fork of ${parent}` + } + return 'fork whose parent was deleted' + } + + + { + confirmEnable = false + toggleChecked = enabled + }} + onConfirmed={async () => { + confirmEnable = false + await setIsolation(true) + }} +> +
+

+ {#if workspaces === undefined} + Every dev workspace and fork + {:else} + {pluralize(devWorkspaces.length, 'dev workspace or fork', 'dev workspaces and forks')} + {/if} + will have their jobs queued until a worker group serves them. +

+

+ {#if flaggedGroups.length === 0} + No worker group is flagged as serving dev workspaces yet. + {:else} + The worker groups serving dev workspaces ({flaggedGroups.map((g) => g.name).join(', ')}) + have no live worker. + {/if} + Jobs never fall back to the other worker groups: they wait in the queue and run as soon as a serving + worker is up. +

+ {#if unflaggedGroupNames.length > 0 && flaggedGroups.length === 0} +
+ +
+ {/if} +
+
+ + { + confirmDisable = false + toggleChecked = enabled + }} + onConfirmed={async () => { + confirmDisable = false + await setIsolation(false) + }} +> +

+ New jobs of dev workspaces and forks will run on the same worker groups as root workspaces + again. Jobs already queued on a {effectiveSuffix} tag keep it, and the worker groups + serving dev workspaces still run them. +

+
+ +{#snippet isolationToggle()} + onToggle(e.detail)} + disabled={!canEdit || !$enterpriseLicense || saving || suffix === undefined} + options={{ right: 'Run dev workspaces and forks on separate workers' }} + size="xs" + /> +{/snippet} + +
+ {#snippet action()} + {@render isolationToggle()} + {/snippet} + {#snippet badge()} + {@render isolationToggle()} + {/snippet} + +
+
+ Root workspaces + + + Worker groups not serving dev workspaces, on their usual tags: + python3, gpu + + Dev workspaces and forks + + + {#if enabled} + Worker groups serving dev workspaces, on tags suffixed with + {effectiveSuffix}: + {:else} + Once on, worker groups serving dev workspaces, on suffixed tags: + {/if} + {withDevSuffix('python3', effectiveSuffix)}, + {withDevSuffix('gpu', effectiveSuffix)} + +
+

+ A workspace with a parent, and every fork (including a fork whose parent was deleted), counts + as a dev workspace. Every job is covered: runs, previews, schedules, triggers, flow steps, AI + agent tools and dependency jobs, and inline runs are refused on workers not serving dev + workspaces. A job whose tag no serving worker listens to stays queued: it never falls back to + the other worker groups. Dedicated workers keep their own tags. +

+ + +
+ Worker groups serving dev workspaces + {#if flaggedGroups.length > 0} +
+ {#each flaggedGroups as g (g.name)} + + {/each} +
+ {:else} + None yet. + {/if} + {#if canEdit && unflaggedGroupNames.length > 0} +
+ + + + Jobs in this workspace run on dev workers (tags suffixed with + {$devWorkspaceTagSuffix}, e.g. + {withDevSuffix('python3', $devWorkspaceTagSuffix)}), set by the instance's dev + workspace isolation. + +

+ {/if} +{/snippet} + {#if isThrowawayFork}

Dev workspace pairing is not available on a throwaway fork. This workspace is a fork of {parentId}.

+
{@render devWorkersNotice()}
{@render deployTarget?.()} {:else if isDev && parentId}
@@ -563,6 +593,7 @@ {currentLabel} branch.
+ {@render devWorkersNotice()}
{@render deployTarget?.()}
diff --git a/frontend/src/lib/components/WorkerGroup.svelte b/frontend/src/lib/components/WorkerGroup.svelte index 5e8957c31a..da9e5cf4a9 100644 --- a/frontend/src/lib/components/WorkerGroup.svelte +++ b/frontend/src/lib/components/WorkerGroup.svelte @@ -56,6 +56,12 @@ import DedicatedWorkersSelector from './DedicatedWorkersSelector.svelte' import { computeHashedTag } from './dedicated_worker' import { apiBaseUrl } from '$lib/apiBaseUrl.svelte' + import { + devWorkspaceListenSuffix, + devWorkspaceTagSuffix, + loadDevWorkspaceTagSuffix, + withDevSuffix + } from '$lib/devWorkspaceTags' import ObjectStoreConfigSettings, { type ObjectStoreConfig } from './ObjectStoreConfigSettings.svelte' @@ -106,6 +112,7 @@ native_mode?: boolean object_store_cache_config?: ObjectStoreConfig paused?: boolean + serves_dev_workspaces?: boolean } = $state({}) function loadNConfig() { @@ -214,6 +221,7 @@ native_mode?: boolean object_store_cache_config?: ObjectStoreConfig paused?: boolean + serves_dev_workspaces?: boolean } activeWorkers: number customTags: string[] | undefined @@ -319,7 +327,8 @@ 'priority_tags', 'additional_python_paths', 'pip_local_dependencies', - 'object_store_cache_config' + 'object_store_cache_config', + 'serves_dev_workspaces' ] as const function restartsWorkers(body: typeof nconfig): boolean { if (activeWorkers === 0) return false @@ -381,6 +390,13 @@ !t.startsWith('flow-') ) ) + loadDevWorkspaceTagSuffix() + let devSuffix = $derived($devWorkspaceListenSuffix) + let servesDev = $derived( + config?.serves_dev_workspaces === true && + config?.dedicated_worker == undefined && + !config?.dedicated_workers?.length + ) let isAutoNativeMode = $derived(name === 'native') let isNativeModeEnabled = $derived(nconfig?.native_mode === true || isAutoNativeMode) $effect(() => { @@ -647,6 +663,63 @@ {/if} + {#if nconfig !== undefined} + {@const flagged = nconfig.serves_dev_workspaces === true} + {@const draftTags = nconfig.worker_tags ?? []} + {@const handSuffixed = draftTags.filter((t) => t.endsWith(devSuffix))} +
+ + {/if} + {#if nconfig?.worker_tags !== undefined && nconfig?.worker_tags.length > 0}
- {#if !isAgent} + {#if !isAgent || config}
{#if canEditConfig} {#if width > 1000} @@ -1644,7 +1657,12 @@
{#snippet children()} - This group is formed with agent workers, there is no associated config. {#if $superadmin || $devopsRole} + {#if config} + This group is formed with agent workers, which ignore its config except for autoscaling. + {:else} + This group is formed with agent workers, there is no associated config. + {/if} + {#if $superadmin || $devopsRole} To modify the tags, generate a new
- - {#if worker_group?.[2] === false} + + {#if worker_group?.[2] === false || (workerGroups ?? {})[selectedTab]} {/if} {:else} From 578437885a43a3d3dc87f49e8d35ca155c3f3eb8 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 18 Oct 2026 11:12:17 +0200 Subject: [PATCH 38/46] clarify the no-tags autoscaling warning (#11861) Co-authored-by: Claude Opus 5.5 --- backend/ee-repo-ref.txt | 2 +- .../src/lib/components/AutoscalingConfigEditor.svelte | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 9b8b88cbc3..37990aa852 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -a673d2e3fe12927921be86c3a52bd9c956759c65 +e922599943c472a6d0f736f629ae04081f866686 diff --git a/frontend/src/lib/components/AutoscalingConfigEditor.svelte b/frontend/src/lib/components/AutoscalingConfigEditor.svelte index 6ae4f77743..885b6dd55c 100644 --- a/frontend/src/lib/components/AutoscalingConfigEditor.svelte +++ b/frontend/src/lib/components/AutoscalingConfigEditor.svelte @@ -117,7 +117,7 @@ - This group has no worker tags and no custom tags to autoscale on, so queued jobs never trigger - a scale-out. Set custom tags under Advanced. For agent workers, set them to the tags in the - agents' token: agents take their tags from it, not from this config, so only jobs on matching - custom tags trigger a scale-out. + Autoscaling counts waiting jobs on this group's worker tags, or on the custom tags under + Advanced, and this group has neither. Agent workers don't need either to run, since their tags + come from their token, but to scale on their queue set worker tags or custom tags to the tags + their token was issued with. {/if} From 19ec5d3cd8a36600c8896a895d0e566735f729a9 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 18 Oct 2026 12:27:06 +0200 Subject: [PATCH 39/46] fix: reject out-of-range integer args to narrow SQL types instead of wrapping (#11864) Co-authored-by: Claude Opus 5.5 --- backend/windmill-worker/src/common.rs | 10 ++ backend/windmill-worker/src/mssql_executor.rs | 8 +- backend/windmill-worker/src/pg_executor.rs | 132 ++++++++++++------ 3 files changed, 105 insertions(+), 45 deletions(-) diff --git a/backend/windmill-worker/src/common.rs b/backend/windmill-worker/src/common.rs index 32bd6dc7e9..462fb2a686 100644 --- a/backend/windmill-worker/src/common.rs +++ b/backend/windmill-worker/src/common.rs @@ -92,6 +92,16 @@ pub(crate) fn raw_to_string(x: &str) -> String { } } +/// Narrow a JSON integer to the Rust type bound for a SQL argument, erroring the way the +/// database would rather than letting an `as` cast wrap it into a different value. +pub(crate) fn narrow_sql_int(n: N, sql_type: &str) -> anyhow::Result +where + T: TryFrom, + N: std::fmt::Display + Copy, +{ + T::try_from(n).map_err(|_| anyhow!("value \"{n}\" is out of range for type {sql_type}")) +} + pub async fn build_args_map<'a>( job: &'a MiniPulledJob, client: &AuthedClient, diff --git a/backend/windmill-worker/src/mssql_executor.rs b/backend/windmill-worker/src/mssql_executor.rs index 02d0da1164..1d3a323e34 100644 --- a/backend/windmill-worker/src/mssql_executor.rs +++ b/backend/windmill-worker/src/mssql_executor.rs @@ -26,7 +26,7 @@ use windmill_queue::MiniPulledJob; use windmill_queue::{append_logs, CanceledBy}; use crate::common::{ - build_args_values, get_reserved_variables, s3_mode_args_to_worker_data, + build_args_values, get_reserved_variables, narrow_sql_int, s3_mode_args_to_worker_data, s3_stream_and_upload_with_logs, OccupancyMetrics, }; use crate::handle_child::run_future_with_polling_update_job_poller; @@ -398,13 +398,13 @@ fn json_value_to_sql<'a>( query.bind(b.to_owned()); } Value::Number(n) if n.is_u64() && arg_t == "tinyint" => { - query.bind(n.as_u64().unwrap().to_owned() as u8) + query.bind(narrow_sql_int::(n.as_u64().unwrap(), "tinyint")?) } Value::Number(n) if n.is_i64() && arg_t == "smallint" => { - query.bind(n.as_i64().unwrap().to_owned() as i16) + query.bind(narrow_sql_int::(n.as_i64().unwrap(), "smallint")?) } Value::Number(n) if n.is_i64() && arg_t == "int" => { - query.bind(n.as_i64().unwrap().to_owned() as i32) + query.bind(narrow_sql_int::(n.as_i64().unwrap(), "int")?) } Value::Number(n) if n.is_i64() && arg_t == "bigint" => { query.bind(n.as_i64().unwrap().to_owned() as i64) diff --git a/backend/windmill-worker/src/pg_executor.rs b/backend/windmill-worker/src/pg_executor.rs index 12a3665c27..f70e3dd0ca 100644 --- a/backend/windmill-worker/src/pg_executor.rs +++ b/backend/windmill-worker/src/pg_executor.rs @@ -38,7 +38,7 @@ use windmill_queue::{CanceledBy, MiniPulledJob}; use crate::agent_workers::get_datatable_resource_from_agent_http; use crate::common::{ - build_args_values, get_reserved_variables, s3_mode_args_to_worker_data, + build_args_values, get_reserved_variables, narrow_sql_int, s3_mode_args_to_worker_data, s3_stream_and_upload_with_logs, sizeof_val, OccupancyMetrics, S3ModeWorkerData, }; use crate::handle_child::run_future_with_polling_update_job_poller; @@ -1768,23 +1768,30 @@ fn parse_datetime_utc(s: &str) -> Result, chrono::ParseErr fn map_as_single_type( vec: Option<&Vec>, f: impl Fn(&Value) -> Option, +) -> anyhow::Result>>> { + try_map_as_single_type(vec, |v| Ok(f(v))) +} + +/// Like `map_as_single_type`, but `f` can reject an element of the right type +/// (e.g. an out-of-range integer) with its own error. +fn try_map_as_single_type( + vec: Option<&Vec>, + f: impl Fn(&Value) -> anyhow::Result>, ) -> anyhow::Result>>> { if let Some(vec) = vec { - Ok(Some( - vec.into_iter() - .map(|v| { - // first option is if the value is of the right type (if none, will stop the collection and throw error) - // second option is if the value is null - // allow nulls in arrays - if matches!(v, Value::Null) { - Some(None) - } else { - f(v).map(Some) - } - }) - .collect::>>>() - .ok_or_else(|| anyhow::anyhow!("Mixed types in array"))?, - )) + let mut out = Vec::with_capacity(vec.len()); + for v in vec { + // allow nulls in arrays + if matches!(v, Value::Null) { + out.push(None); + } else { + match f(v)? { + Some(x) => out.push(Some(x)), + None => return Err(anyhow::anyhow!("Mixed types in array")), + } + } + } + Ok(Some(out)) } else { Ok(None) } @@ -1819,26 +1826,23 @@ fn convert_vec_val( Type::BOOL_ARRAY, )), "char" | "character" => Ok(( - Box::new(map_as_single_type(vec, |v| { - v.as_i64() - .map(|x| x as i8) - .or_else(|| v.as_str().and_then(|s| s.parse::().ok())) + Box::new(try_map_as_single_type(vec, |v| match v.as_i64() { + Some(x) => narrow_sql_int::(x, "\"char\"").map(Some), + None => Ok(v.as_str().and_then(|s| s.parse::().ok())), })?), Type::CHAR_ARRAY, )), "smallint" | "smallserial" | "int2" | "serial2" => Ok(( - Box::new(map_as_single_type(vec, |v| { - v.as_i64() - .map(|x| x as i16) - .or_else(|| v.as_str().and_then(|s| s.parse::().ok())) + Box::new(try_map_as_single_type(vec, |v| match v.as_i64() { + Some(x) => narrow_sql_int::(x, "smallint").map(Some), + None => Ok(v.as_str().and_then(|s| s.parse::().ok())), })?), Type::INT2_ARRAY, )), "int" | "integer" | "int4" | "serial" => Ok(( - Box::new(map_as_single_type(vec, |v| { - v.as_i64() - .map(|x| x as i32) - .or_else(|| v.as_str().and_then(|s| s.parse::().ok())) + Box::new(try_map_as_single_type(vec, |v| match v.as_i64() { + Some(x) => narrow_sql_int::(x, "integer").map(Some), + None => Ok(v.as_str().and_then(|s| s.parse::().ok())), })?), Type::INT4_ARRAY, )), @@ -1859,18 +1863,18 @@ fn convert_vec_val( Type::NUMERIC_ARRAY, )), "oid" => Ok(( - Box::new(map_as_single_type(vec, |v| { - v.as_u64() - .map(|x| x as u32) - .or_else(|| v.as_str().and_then(|s| s.parse::().ok())) + Box::new(try_map_as_single_type(vec, |v| match v.as_u64() { + Some(x) => narrow_sql_int::(x, "oid").map(Some), + None => Ok(v.as_str().and_then(|s| s.parse::().ok())), })?), Type::OID_ARRAY, )), "bigint" | "bigserial" | "int8" | "serial8" => Ok(( - Box::new(map_as_single_type(vec, |v| { - v.as_i64() - .or_else(|| v.as_u64().map(|x| x as i64)) - .or_else(|| v.as_str().and_then(|s| s.parse::().ok())) + Box::new(try_map_as_single_type(vec, |v| match v.as_u64() { + Some(x) => narrow_sql_int::(x, "bigint").map(Some), + None => Ok(v + .as_i64() + .or_else(|| v.as_str().and_then(|s| s.parse::().ok()))), })?), Type::INT8_ARRAY, )), @@ -2074,7 +2078,8 @@ fn convert_val( Ok((Box::new(n.to_string()), t)) } Value::Number(n) if arg_t == "char" && n.is_i64() => { - Ok((Box::new(n.as_i64().unwrap() as i8), Type::CHAR)) + let n = narrow_sql_int::(n.as_i64().unwrap(), "\"char\"")?; + Ok((Box::new(n), Type::CHAR)) } Value::Number(n) if (arg_t == "smallint" @@ -2083,13 +2088,15 @@ fn convert_val( || arg_t == "serial2") && n.is_i64() => { - Ok((Box::new(n.as_i64().unwrap() as i16), Type::INT2)) + let n = narrow_sql_int::(n.as_i64().unwrap(), "smallint")?; + Ok((Box::new(n), Type::INT2)) } Value::Number(n) if (arg_t == "int" || arg_t == "integer" || arg_t == "int4" || arg_t == "serial") && n.is_i64() => { - Ok((Box::new(n.as_i64().unwrap() as i32), Type::INT4)) + let n = narrow_sql_int::(n.as_i64().unwrap(), "integer")?; + Ok((Box::new(n), Type::INT4)) } Value::Number(n) if (arg_t == "real" || arg_t == "float4") && n.as_f64().is_some() => { Ok((Box::new(n.as_f64().unwrap() as f32), Type::FLOAT4)) @@ -2109,7 +2116,8 @@ fn convert_val( Type::NUMERIC, )), Value::Number(n) if arg_t == "oid" && n.is_u64() => { - Ok((Box::new(n.as_u64().unwrap() as u32), Type::OID)) + let n = narrow_sql_int::(n.as_u64().unwrap(), "oid")?; + Ok((Box::new(n), Type::OID)) } Value::Number(n) if (arg_t == "bigint" @@ -2118,7 +2126,8 @@ fn convert_val( || arg_t == "serial8") && n.is_u64() => { - Ok((Box::new(n.as_u64().unwrap() as i64), Type::INT8)) + let n = narrow_sql_int::(n.as_u64().unwrap(), "bigint")?; + Ok((Box::new(n), Type::INT8)) } Value::Number(n) if n.is_i64() => Ok((Box::new(n.as_i64().unwrap()), Type::INT8)), Value::Number(n) => Ok((Box::new(n.as_f64().unwrap()), Type::FLOAT8)), @@ -3313,6 +3322,47 @@ mod tests { assert_convert_val_consistent("Number(0)/oid", json!(0), "oid", typ_for("oid"), Type::OID); } + #[test] + fn convert_val_rejects_out_of_range_integers() { + let convert = |value: Value, arg_t: &str| { + convert_val(&value, &arg_t.to_string(), &typ_for(arg_t), false) + .map(|_| ()) + .map_err(|e| e.to_string()) + }; + for (value, arg_t, sql_type) in [ + (json!(200), "char", "\"char\""), + (json!(70000), "smallint", "smallint"), + (json!(-40000), "int2", "smallint"), + (json!(4294967297u64), "int4", "integer"), + (json!(4294967296u64), "oid", "oid"), + (json!(u64::MAX), "bigint", "bigint"), + (json!([1, 70000]), "smallint[]", "smallint"), + (json!([u64::MAX]), "int8[]", "bigint"), + ] { + let err = convert(value.clone(), arg_t).expect_err(&format!("{value}/{arg_t}")); + let n = value.as_array().map_or(&value, |a| a.last().unwrap()); + assert!( + err.contains(&format!( + "value \"{n}\" is out of range for type {sql_type}" + )), + "{value}/{arg_t}: {err}" + ); + } + for (value, arg_t) in [ + (json!(127), "char"), + (json!(-128), "char"), + (json!(32767), "smallint"), + (json!(-32768), "smallint"), + (json!(2147483647), "int"), + (json!(-2147483648i64), "int"), + (json!(4294967295u64), "oid"), + (json!(i64::MAX), "bigint"), + (json!([null, -32768, 32767]), "smallint[]"), + ] { + convert(value.clone(), arg_t).unwrap_or_else(|e| panic!("{value}/{arg_t}: {e}")); + } + } + #[test] fn convert_val_float_number_against_every_arg_t() { let cases: &[(&str, Type)] = &[ From 5c205fa46915de9e5fde731a117ba8571cfa56f7 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 01:18:52 +0200 Subject: [PATCH 40/46] feat: let ALLOW_PRIVATE_MCP_SERVER_URLS name the private hosts it allows (#11869) * feat: let ALLOW_PRIVATE_MCP_SERVER_URLS name the private hosts it allows Co-Authored-By: Claude Opus 5.5 * fix: warn once about invalid MCP private-host entries Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- backend/windmill-common/src/ssrf.rs | 72 ++++++++++++++++---------- backend/windmill-mcp/src/client/mod.rs | 5 +- backend/windmill-mcp/src/lib.rs | 5 +- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/backend/windmill-common/src/ssrf.rs b/backend/windmill-common/src/ssrf.rs index 3f6dda0327..c95137a8bb 100644 --- a/backend/windmill-common/src/ssrf.rs +++ b/backend/windmill-common/src/ssrf.rs @@ -197,12 +197,6 @@ pub async fn validate_url_for_ssrf(url: &str) -> Result bool { - std::env::var(ALLOW_PRIVATE_MCP_SERVER_URLS_ENV) - .ok() - .is_some_and(|v| v == "true" || v == "1") -} - pub fn allow_private_saml_metadata_urls() -> bool { std::env::var(ALLOW_PRIVATE_SAML_METADATA_URLS_ENV) .ok() @@ -311,22 +305,22 @@ pub async fn validate_guest_jwks_url(url: &str) -> Result Result { - let parsed = - url::Url::parse(url).map_err(|e| SsrfValidationError::InvalidUrl(e.to_string()))?; - - match parsed.scheme() { - "http" | "https" => {} - scheme => return Err(SsrfValidationError::DisallowedScheme(scheme.to_string())), + // Read per call rather than cached, so warn about bad entries once, not on every connect. + static WARN_INVALID: std::sync::Once = std::sync::Once::new(); + let value = std::env::var(ALLOW_PRIVATE_MCP_SERVER_URLS_ENV).unwrap_or_default(); + let (allowance, invalid) = PrivateHostAllowance::parse(&value); + if !invalid.is_empty() { + WARN_INVALID.call_once(|| { + tracing::warn!( + "Ignoring {ALLOW_PRIVATE_MCP_SERVER_URLS_ENV} entries {invalid:?}: expected a \ + host, host:port, IP address or CIDR range" + ) + }); } - - let host = parsed.host_str().ok_or(SsrfValidationError::MissingHost)?; - - if allow_private_mcp_server_urls() { - return Ok(ValidatedTarget::unpinned(host)); - } - - validate_url_for_ssrf(url).await + validate_url_for_ssrf_allowing(url, &allowance).await } /// Save-time check only: the webhook is sent later from another task that resolves @@ -369,8 +363,9 @@ pub async fn validate_mcp_server_url_for_bad_request( pub fn mcp_ssrf_error_message(e: &SsrfValidationError) -> String { match e { SsrfValidationError::Private { .. } => format!( - "{e}. If you need to use private/internal MCP server URLs, \ - set the {ALLOW_PRIVATE_MCP_SERVER_URLS_ENV}=true environment variable" + "{e}. To use a private/internal MCP server, add its host (host, host:port or \ + CIDR range) to the comma-separated {ALLOW_PRIVATE_MCP_SERVER_URLS_ENV} environment \ + variable, or set it to true to allow every private host" ), _ => e.to_string(), } @@ -870,6 +865,25 @@ mod tests { assert!(validate_mcp_server_url("http://10.0.0.1/foo").await.is_ok()); } + #[tokio::test] + async fn validate_mcp_server_url_allows_only_listed_private_hosts() { + let _lock = TEST_ENV_LOCK.lock().await; + let _guard = PrivateMcpServerUrlsEnvGuard::set(Some("10.1.0.0/16, mcp.internal:8080")); + + assert!(validate_mcp_server_url("http://10.1.2.3/mcp").await.is_ok()); + assert!(validate_mcp_server_url("http://mcp.internal:8080/mcp") + .await + .is_ok()); + assert!(matches!( + validate_mcp_server_url("http://10.2.0.1/mcp").await, + Err(SsrfValidationError::Private { resolved: false }) + )); + assert!(matches!( + validate_mcp_server_url("http://169.254.169.254/").await, + Err(SsrfValidationError::Private { resolved: false }) + )); + } + #[tokio::test] async fn validate_mcp_server_url_keeps_syntax_guards_when_private_urls_are_allowed() { let _lock = TEST_ENV_LOCK.lock().await; @@ -893,9 +907,7 @@ mod tests { let private_error = validate_mcp_server_url("http://127.0.0.1/foo") .await .unwrap_err(); - assert!( - mcp_ssrf_error_message(&private_error).contains("ALLOW_PRIVATE_MCP_SERVER_URLS=true") - ); + assert!(mcp_ssrf_error_message(&private_error).contains(ALLOW_PRIVATE_MCP_SERVER_URLS_ENV)); let invalid_error = validate_mcp_server_url("localhost:11434/v1") .await @@ -1062,8 +1074,14 @@ mod tests { #[test] fn private_host_allowance_parses_flags_and_entries() { - assert_eq!(PrivateHostAllowance::parse("true").0, PrivateHostAllowance::All); - assert_eq!(PrivateHostAllowance::parse("false").0, PrivateHostAllowance::None); + assert_eq!( + PrivateHostAllowance::parse("true").0, + PrivateHostAllowance::All + ); + assert_eq!( + PrivateHostAllowance::parse("false").0, + PrivateHostAllowance::None + ); let (parsed, invalid) = PrivateHostAllowance::parse("Gateway.Internal., 10.1.0.0/16, x:y, 10, *.internal"); // A bare `10` would otherwise be 0.0.0.10, and `*` is no wildcard. diff --git a/backend/windmill-mcp/src/client/mod.rs b/backend/windmill-mcp/src/client/mod.rs index 6f3928e112..49e71d9734 100644 --- a/backend/windmill-mcp/src/client/mod.rs +++ b/backend/windmill-mcp/src/client/mod.rs @@ -88,8 +88,9 @@ impl McpClient { // and does not legitimately rely on redirects. .redirect(reqwest::redirect::Policy::none()); // Pin DNS to the address validated above so the connect cannot rebind to - // an internal IP between the check and the request. Empty addrs (IP literal - // or ALLOW_PRIVATE_MCP_SERVER_URLS) leave resolution untouched. + // an internal IP between the check and the request. Empty addrs (IP literal, + // or a host ALLOW_PRIVATE_MCP_SERVER_URLS allows by name or by `true`) leave + // resolution untouched. if !validated.addrs.is_empty() { client_builder = client_builder.resolve_to_addrs(&validated.host, &validated.addrs); } diff --git a/backend/windmill-mcp/src/lib.rs b/backend/windmill-mcp/src/lib.rs index 33a20be2f0..c9daf25da9 100644 --- a/backend/windmill-mcp/src/lib.rs +++ b/backend/windmill-mcp/src/lib.rs @@ -81,8 +81,9 @@ pub mod oauth { /// guard validated for the request URL so the connect cannot rebind to an /// internal IP after the check (TOCTOU). The OAuth DCR/discovery/token /// requests target author-controlled URLs and carry secrets, so they must - /// go through this rather than the unpinned client. Empty `addrs` (IP literal - /// or ALLOW_PRIVATE_MCP_SERVER_URLS) leaves resolution untouched. + /// go through this rather than the unpinned client. Empty `addrs` (IP literal, + /// or a host ALLOW_PRIVATE_MCP_SERVER_URLS allows by name or by `true`) leaves + /// resolution untouched. pub fn no_redirect_http_client_pinned( target: &windmill_common::ssrf::ValidatedTarget, ) -> Result { From 69d36f77daceb25cc903c7ea014ba8d487650b18 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 01:33:35 +0200 Subject: [PATCH 41/46] feat: probe nsjail with a real jail and add a gVisor compat mode (#11865) * feat: probe nsjail with a real jail and add a gVisor compat mode Co-Authored-By: Claude Opus 5.5 * fix: route dbt captured phases through the gVisor compat step and harden the probe dir Co-Authored-By: Claude Opus 5.5 * feat: patch nsjail with a gvisor_compat option instead of applying rlimits from the worker Co-Authored-By: Claude Opus 5.5 * fix: keep DuckDB jailed on a sandboxed worker whose nsjail probe failed Co-Authored-By: Claude Opus 5.5 * docs: link the upstream gVisor issues from the nsjail patch Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- Dockerfile | 4 +- .../windmill-worker/nsjail/probe.config.proto | 47 ++++++ backend/windmill-worker/src/common.rs | 14 ++ backend/windmill-worker/src/dbt_executor.rs | 1 + backend/windmill-worker/src/duckdb_runner.rs | 8 +- backend/windmill-worker/src/lib.rs | 1 + backend/windmill-worker/src/nsjail_compat.rs | 49 ++++++ backend/windmill-worker/src/worker.rs | 86 ++++++++-- docker/DockerfileSlim | 4 +- docker/DockerfileSlimEe | 4 +- docker/nsjail-patches/gvisor-compat.patch | 153 ++++++++++++++++++ 11 files changed, 351 insertions(+), 20 deletions(-) create mode 100644 backend/windmill-worker/nsjail/probe.config.proto create mode 100644 backend/windmill-worker/src/nsjail_compat.rs create mode 100644 docker/nsjail-patches/gvisor-compat.patch diff --git a/Dockerfile b/Dockerfile index e078c1bfef..79f9d05734 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,9 @@ RUN apt-get -y update \ pkg-config=1.8.* \ protobuf-compiler=3.21.* -RUN git clone -b master --single-branch https://github.com/google/nsjail.git . && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 +COPY docker/nsjail-patches/ /nsjail-patches/ +RUN git clone -b master --single-branch https://github.com/google/nsjail.git . && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 \ + && git apply /nsjail-patches/*.patch RUN make FROM ${RUST_IMAGE} AS rust_base diff --git a/backend/windmill-worker/nsjail/probe.config.proto b/backend/windmill-worker/nsjail/probe.config.proto new file mode 100644 index 0000000000..2fdc5abdca --- /dev/null +++ b/backend/windmill-worker/nsjail/probe.config.proto @@ -0,0 +1,47 @@ +name: "nsjail startup probe" + +mode: ONCE +hostname: "probe" +log_level: WARNING +time_limit: 10 + +# Same namespaces and rlimit handling as the job profiles (nsjail's default rlimits, a cgroup +# namespace, the user namespace unless DISABLE_NUSER): a worker whose kernel or runtime refuses +# any of them cannot run jobs either. +clone_newnet: false +clone_newuser: {CLONE_NEWUSER} + +skip_setsid: true +keep_caps: false +mount_proc: true + +mount { + src: "/bin" + dst: "/bin" + is_bind: true +} +mount { + src: "/lib" + dst: "/lib" + is_bind: true +} +mount { + src: "/lib64" + dst: "/lib64" + is_bind: true + mandatory: false +} +mount { + src: "/usr" + dst: "/usr" + is_bind: true +} +mount { + dst: "/tmp" + fstype: "tmpfs" + rw: true +} + +exec_bin { + path: "/bin/true" +} diff --git a/backend/windmill-worker/src/common.rs b/backend/windmill-worker/src/common.rs index 462fb2a686..c0ae372e38 100644 --- a/backend/windmill-worker/src/common.rs +++ b/backend/windmill-worker/src/common.rs @@ -986,12 +986,26 @@ pub fn build_command_with_isolation(program: &str, args: &[&str]) -> Command { } } +/// Under `NSJAIL_GVISOR_COMPAT`, rewrites the config of an nsjail `cmd` for gVisor. A spawn of +/// nsjail that bypasses `start_child_process` must call this itself. +pub fn apply_nsjail_gvisor_compat(cmd: &Command) -> Result<(), Error> { + if *crate::NSJAIL_GVISOR_COMPAT && cmd.as_std().get_program() == crate::NSJAIL_PATH.as_str() { + crate::nsjail_compat::apply(cmd.as_std()).map_err(|e| { + Error::ExecutionErr(format!( + "NSJAIL_GVISOR_COMPAT could not prepare nsjail: {e}" + )) + })?; + } + Ok(()) +} + pub async fn start_child_process( cmd: Command, executable: &str, disable_process_group: bool, ) -> Result, Error> { use process_wrap::tokio::*; + apply_nsjail_gvisor_compat(&cmd)?; let mut cmd = TokioCommandWrap::from(cmd); // On Windows, put the child in its own console process group so a CTRL_BREAK_EVENT diff --git a/backend/windmill-worker/src/dbt_executor.rs b/backend/windmill-worker/src/dbt_executor.rs index dbef02bec3..28db2753e1 100644 --- a/backend/windmill-worker/src/dbt_executor.rs +++ b/backend/windmill-worker/src/dbt_executor.rs @@ -4053,6 +4053,7 @@ pub(crate) async fn run_captured( ) -> error::Result { use tokio::io::AsyncReadExt; + crate::common::apply_nsjail_gvisor_compat(&cmd)?; let mut child = cmd .stdout(Stdio::piped()) .stderr(Stdio::piped()) diff --git a/backend/windmill-worker/src/duckdb_runner.rs b/backend/windmill-worker/src/duckdb_runner.rs index 46f5c5cbde..b7c0bc6321 100644 --- a/backend/windmill-worker/src/duckdb_runner.rs +++ b/backend/windmill-worker/src/duckdb_runner.rs @@ -23,8 +23,7 @@ use windmill_common::error::{Error, Result}; use crate::{ common::{build_command_with_isolation, resolve_nsjail_tmp_mount_block, DEV_CONF_NSJAIL}, - is_sandboxing_enabled, is_unshare_enabled, DISABLE_NUSER, HOME_ENV, NSJAIL_AVAILABLE, - NSJAIL_PATH, PATH_ENV, + is_sandboxing_enabled, is_unshare_enabled, DISABLE_NUSER, HOME_ENV, NSJAIL_PATH, PATH_ENV, }; const NSJAIL_CONFIG_RUN_DUCKDB_CONTENT: &str = include_str!("../nsjail/run.duckdb.config.proto"); @@ -42,7 +41,9 @@ pub(crate) enum RunnerMode { /// Decided once per job, so every connection a job opens runs the same way. pub(crate) fn runner_mode() -> RunnerMode { - if cfg!(unix) && is_sandboxing_enabled() && NSJAIL_AVAILABLE.is_some() { + // Not gated on `NSJAIL_AVAILABLE`: a sandboxed worker whose nsjail cannot jail must fail + // the job, as every other jailed executor does, not run it outside the jail. + if cfg!(unix) && is_sandboxing_enabled() { RunnerMode::Jailed } else if is_unshare_enabled() { // `build_command_with_isolation` logs and runs unisolated when `unshare` is missing, @@ -475,6 +476,7 @@ async fn spawn_runner( }); } } + crate::common::apply_nsjail_gvisor_compat(&cmd)?; let mut child = cmd.spawn().map_err(|e| { Error::InternalErr(format!("Could not start the DuckDB runner ({mode:?}): {e}")) })?; diff --git a/backend/windmill-worker/src/lib.rs b/backend/windmill-worker/src/lib.rs index e56334df67..1945d16346 100644 --- a/backend/windmill-worker/src/lib.rs +++ b/backend/windmill-worker/src/lib.rs @@ -62,6 +62,7 @@ pub mod memory_ee; pub mod memory_oss; #[cfg(feature = "mysql")] mod mysql_executor; +mod nsjail_compat; #[cfg(feature = "nu")] mod nu_executor; #[cfg(feature = "oracledb")] diff --git a/backend/windmill-worker/src/nsjail_compat.rs b/backend/windmill-worker/src/nsjail_compat.rs new file mode 100644 index 0000000000..3069dcee52 --- /dev/null +++ b/backend/windmill-worker/src/nsjail_compat.rs @@ -0,0 +1,49 @@ +//! `NSJAIL_GVISOR_COMPAT=true`: run nsjail inside gVisor (runsc). Each config is rewritten +//! right before nsjail starts, with `gvisor_compat: true` (an option of the nsjail the images +//! build, from `docker/nsjail-patches/`) and no cgroup namespace, which gVisor refuses. + +use std::ffi::OsStr; +use std::io; +use std::path::PathBuf; +use std::process::Command; + +pub(crate) fn compat_config(config: &str) -> String { + let mut out = config + .lines() + .filter(|l| { + let l = l.trim_start(); + !l.starts_with("clone_newcgroup") && !l.starts_with("gvisor_compat") + }) + .collect::>() + .join("\n"); + out.push_str("\nclone_newcgroup: false\ngvisor_compat: true\n"); + out +} + +/// Rewrites the config `cmd` (an nsjail command line) passes with `--config`. +pub(crate) fn apply(cmd: &Command) -> io::Result<()> { + let args = cmd.get_args().collect::>(); + let Some(config) = args.windows(2).find(|w| w[0] == "--config").map(|w| w[1]) else { + return Ok(()); + }; + let path = match cmd.get_current_dir() { + Some(dir) => dir.join(config), + None => PathBuf::from(config), + }; + let rewritten = compat_config(&std::fs::read_to_string(&path)?); + std::fs::write(&path, rewritten) +} + +#[cfg(test)] +mod tests { + // nsjail rejects a config that sets a scalar field twice, which would fail every jailed job. + #[test] + fn compat_config_sets_each_field_once() { + let bun = include_str!("../nsjail/run.bun.config.proto"); + assert!(bun.contains("clone_newcgroup: false")); + let twice = super::compat_config(&super::compat_config(bun)); + assert_eq!(twice.matches("clone_newcgroup").count(), 1); + assert_eq!(twice.matches("gvisor_compat").count(), 1); + assert!(twice.ends_with("\nclone_newcgroup: false\ngvisor_compat: true\n")); + } +} diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index cef3b1bbfc..4048a3603c 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -261,6 +261,7 @@ const NUM_SECS_PING: u64 = 5; const NUM_SECS_READINGS: u64 = 60; const INCLUDE_DEPS_PY_SH_CONTENT: &str = include_str!("../nsjail/download_deps.py.sh"); +const NSJAIL_CONFIG_PROBE_CONTENT: &str = include_str!("../nsjail/probe.config.proto"); const WORKER_SHELL_NAP_TIME_DURATION: u64 = 15; const WORKER_SHELL_INITIAL_NAP_TIME_DURATION: u64 = 5; @@ -335,6 +336,14 @@ pub struct PowershellRepo { pub pat: String, } +/// Runs nsjail in a form gVisor (runsc) accepts, see `nsjail_compat`. +pub static NSJAIL_GVISOR_COMPAT: std::sync::LazyLock = std::sync::LazyLock::new(|| { + std::env::var("NSJAIL_GVISOR_COMPAT") + .ok() + .and_then(|x| x.parse::().ok()) + .unwrap_or(false) +}); + lazy_static::lazy_static! { static ref SLEEP_QUEUE_BASE: u64 = std::env::var("SLEEP_QUEUE") @@ -546,29 +555,41 @@ lazy_static::lazy_static! { pub static ref NSJAIL_AVAILABLE: Option = { let nsjail_path = NSJAIL_PATH.as_str(); - let test_result = std::process::Command::new(nsjail_path) - .arg("--help") - .output(); - - match test_result { + match probe_nsjail(nsjail_path) { Ok(output) if output.status.success() => { - tracing::info!("nsjail available at: {}", nsjail_path); + tracing::info!( + "nsjail available at: {}{}", + nsjail_path, + if *NSJAIL_GVISOR_COMPAT { " (NSJAIL_GVISOR_COMPAT)" } else { "" } + ); Some(nsjail_path.to_string()) }, Ok(output) => { - let stderr = String::from_utf8_lossy(&output.stderr); - tracing::error!( - "nsjail test failed (exit code: {}). stderr: '{}'. path: '{}'. \ - Nsjail sandboxing will NOT be available. \ - nsjail should be included in all standard windmill images. \ - If job_isolation is set to 'nsjail_sandboxing' in Instance Settings, jobs will fail.", + let msg = format!( + "nsjail could not run a test jail (exit code: {}). stderr: '{}'. path: '{}'. \ + Nsjail sandboxing will NOT be available: the worker reports its job isolation \ + without nsjail, and jobs that require nsjail fail. Under gVisor (runsc), see \ + NSJAIL_GVISOR_COMPAT.", output.status, - stderr.trim(), + String::from_utf8_lossy(&output.stderr).trim(), nsjail_path ); + // Most workers never jail anything, and most containers cannot. + if *DISABLE_NSJAIL { + tracing::info!("{msg}"); + } else { + tracing::error!("{msg}"); + } + None + }, + Err(NsjailProbeError::Setup(e)) => { + tracing::error!( + "Could not prepare the nsjail test jail: {}. Nsjail sandboxing will NOT be available.", + e + ); None }, - Err(e) => { + Err(NsjailProbeError::Start(e)) => { if e.kind() == std::io::ErrorKind::NotFound { tracing::error!( "nsjail not found at '{}'. Nsjail sandboxing will NOT be available. \ @@ -1021,6 +1042,43 @@ pub(crate) fn artifact_cache_name( format!("mod-{}", windmill_common::utils::calculate_hash(&keyed)) } +/// Runs `/bin/true` in a jail built like a job's, through the same spawn path, so a worker +/// whose runtime lets nsjail start but not jail (a container without the privileges, gVisor) +/// does not report nsjail isolation. +enum NsjailProbeError { + /// The probe could not be prepared: nothing is known about nsjail. + Setup(std::io::Error), + /// nsjail itself could not be executed. + Start(std::io::Error), +} + +fn probe_nsjail(nsjail_path: &str) -> Result { + // A fresh private directory: the worker runs what this config says, as itself. + let dir = std::env::temp_dir().join(format!("windmill-nsjail-probe-{}", uuid::Uuid::new_v4())); + let mut builder = std::fs::DirBuilder::new(); + #[cfg(unix)] + std::os::unix::fs::DirBuilderExt::mode(&mut builder, 0o700); + builder.create(&dir).map_err(NsjailProbeError::Setup)?; + let output = (|| { + std::fs::write( + dir.join("probe.config.proto"), + NSJAIL_CONFIG_PROBE_CONTENT.replace("{CLONE_NEWUSER}", &(!*DISABLE_NUSER).to_string()), + ) + .map_err(NsjailProbeError::Setup)?; + let mut cmd = std::process::Command::new(nsjail_path); + cmd.current_dir(&dir) + .env_clear() + .env("PATH", PATH_ENV.as_str()) + .args(["--config", "probe.config.proto"]); + if *NSJAIL_GVISOR_COMPAT { + crate::nsjail_compat::apply(&cmd).map_err(NsjailProbeError::Setup)?; + } + cmd.output().map_err(NsjailProbeError::Start) + })(); + let _ = std::fs::remove_dir_all(&dir); + output +} + pub fn is_sandboxing_enabled() -> bool { if !*DISABLE_NSJAIL { return true; diff --git a/docker/DockerfileSlim b/docker/DockerfileSlim index ef976f83d3..630f454f01 100644 --- a/docker/DockerfileSlim +++ b/docker/DockerfileSlim @@ -23,7 +23,9 @@ RUN apt-get -y update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN git clone -b master --single-branch https://github.com/google/nsjail.git . && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 +COPY docker/nsjail-patches/ /nsjail-patches/ +RUN git clone -b master --single-branch https://github.com/google/nsjail.git . && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 \ + && git apply /nsjail-patches/*.patch RUN make FROM ${DEBIAN_IMAGE} diff --git a/docker/DockerfileSlimEe b/docker/DockerfileSlimEe index 67de36eac7..8189e74bf9 100644 --- a/docker/DockerfileSlimEe +++ b/docker/DockerfileSlimEe @@ -23,7 +23,9 @@ RUN apt-get -y update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN git clone -b master --single-branch https://github.com/google/nsjail.git . && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 +COPY docker/nsjail-patches/ /nsjail-patches/ +RUN git clone -b master --single-branch https://github.com/google/nsjail.git . && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 \ + && git apply /nsjail-patches/*.patch RUN make FROM ${DEBIAN_IMAGE} diff --git a/docker/nsjail-patches/gvisor-compat.patch b/docker/nsjail-patches/gvisor-compat.patch new file mode 100644 index 0000000000..70176b7272 --- /dev/null +++ b/docker/nsjail-patches/gvisor-compat.patch @@ -0,0 +1,153 @@ +gvisor_compat: an opt-in nsjail option (config field and --gvisor_compat) for running inside +gVisor (runsc). With it false, nsjail behaves as upstream. With it true: +- no rtnetlink link cache when no interface is moved into the jail: gVisor acks NLM_F_DUMP + requests before NLMSG_DONE and libnl rejects that (google/gvisor#15945); +- an EPERM from setrlimit(RLIMIT_MSGQUEUE) is a warning: gVisor refuses that limit for any + value (google/gvisor#15944); +- an EPERM from PR_SET_SECUREBITS is tolerated when the UID does not change, where the bits + have no effect (SECBIT_NO_SETUID_FIXUP lands in gVisor with google/gvisor#15130). +Applied to google/nsjail dccf911fd2659e7b08ce9507c25b2b38ec2c5800 by the Dockerfiles. + +diff --git a/cmdline.cc b/cmdline.cc +index 1b52b33..b49ce16 100644 +--- a/cmdline.cc ++++ b/cmdline.cc +@@ -115,6 +115,7 @@ struct custom_option custom_opts[] = { + { { "rlimit_rtprio", required_argument, NULL, 0x0210 }, "RLIMIT_RTPRIO, 'max' or 'hard' for the current hard limit, 'def' or 'soft' for the current soft limit, 'inf' for RLIM64_INFINITY (default: 'soft')" }, + { { "rlimit_msgqueue", required_argument, NULL, 0x0211 }, "RLIMIT_MSGQUEUE in bytes, 'max' or 'hard' for the current hard limit, 'def' or 'soft' for the current soft limit, 'inf' for RLIM64_INFINITY (default: 'soft')" }, + { { "disable_rlimits", no_argument, NULL, 0x0208 }, "Disable all rlimits, default to limits set by parent" }, ++ { { "gvisor_compat", no_argument, NULL, 0x0510 }, "Tolerate what gVisor (runsc) does not implement (see config.proto)" }, + { { "persona_addr_compat_layout", no_argument, NULL, 0x0301 }, "personality(ADDR_COMPAT_LAYOUT)" }, + { { "persona_mmap_page_zero", no_argument, NULL, 0x0302 }, "personality(MMAP_PAGE_ZERO)" }, + { { "persona_read_implies_exec", no_argument, NULL, 0x0303 }, "personality(READ_IMPLIES_EXEC)" }, +@@ -437,6 +438,7 @@ std::unique_ptr parseArgs(int argc, char* argv[]) { + nsjconf->rl_rtpr = parseRLimit(RLIMIT_RTPRIO, "soft", 1); + nsjconf->rl_msgq = parseRLimit(RLIMIT_MSGQUEUE, "soft", 1); + nsjconf->disable_rl = false; ++ nsjconf->gvisor_compat = false; + nsjconf->personality = 0; + nsjconf->clone_newnet = true; + nsjconf->clone_newuser = true; +@@ -603,6 +605,9 @@ std::unique_ptr parseArgs(int argc, char* argv[]) { + case 0x0208: + nsjconf->disable_rl = true; + break; ++ case 0x0510: ++ nsjconf->gvisor_compat = true; ++ break; + case 0x0301: + nsjconf->personality |= ADDR_COMPAT_LAYOUT; + break; +diff --git a/config.cc b/config.cc +index 620d08e..9427069 100644 +--- a/config.cc ++++ b/config.cc +@@ -166,6 +166,7 @@ static bool configParseInternal(nsjconf_t* nsjconf, const nsjail::NsJailConfig& + configRLimit(RLIMIT_MSGQUEUE, njc.rlimit_msgqueue_type(), njc.rlimit_msgqueue()); + + nsjconf->disable_rl = njc.disable_rl(); ++ nsjconf->gvisor_compat = njc.gvisor_compat(); + + if (njc.persona_addr_compat_layout()) { + nsjconf->personality |= ADDR_COMPAT_LAYOUT; +diff --git a/config.proto b/config.proto +index cd297ae..96b477c 100644 +--- a/config.proto ++++ b/config.proto +@@ -266,4 +266,10 @@ message NsJailConfig { + /* Binary path (with arguments) to be executed. If not specified here, it + can be specified with cmd-line as "-- /path/to/command arg1 arg2" */ + optional Exe exec_bin = 90; ++ ++ /* Tolerate what gVisor (runsc) does not implement: an EPERM from ++ setrlimit(RLIMIT_MSGQUEUE) or from PR_SET_SECUREBITS when the UID does ++ not change, and no rtnetlink link cache when no interface is moved ++ into the jail */ ++ optional bool gvisor_compat = 93 [default = false]; + } +diff --git a/contain.cc b/contain.cc +index b5120cc..41e69f8 100644 +--- a/contain.cc ++++ b/contain.cc +@@ -172,8 +172,12 @@ static bool containSetLimits(nsjconf_t* nsjconf) { + } + rl.rlim_cur = rl.rlim_max = nsjconf->rl_msgq; + if (setrlimit64(RLIMIT_MSGQUEUE, &rl) == -1) { +- PLOG_E("setrlimit64(0, RLIMIT_MSGQUEUE , %" PRIu64 ")", nsjconf->rl_msgq); +- return false; ++ if (!nsjconf->gvisor_compat || errno != EPERM) { ++ PLOG_E("setrlimit64(0, RLIMIT_MSGQUEUE , %" PRIu64 ")", nsjconf->rl_msgq); ++ return false; ++ } ++ PLOG_W("setrlimit64(0, RLIMIT_MSGQUEUE , %" PRIu64 "), ignored (gvisor_compat)", ++ nsjconf->rl_msgq); + } + return true; + } +diff --git a/net.cc b/net.cc +index 87c3df9..b4c64f4 100644 +--- a/net.cc ++++ b/net.cc +@@ -138,6 +138,10 @@ bool initNsFromParent(nsjconf_t* nsjconf, int pid) { + if (!nsjconf->clone_newnet) { + return true; + } ++ /* gVisor's rtnetlink replies are rejected by libnl's link cache, which is unused here */ ++ if (nsjconf->gvisor_compat && nsjconf->ifaces.empty() && nsjconf->iface_vs.empty()) { ++ return true; ++ } + struct nl_sock* sk = nl_socket_alloc(); + if (!sk) { + LOG_E("Could not allocate socket with nl_socket_alloc()"); +diff --git a/nsjail.h b/nsjail.h +index 5687ca7..fa2b9fa 100644 +--- a/nsjail.h ++++ b/nsjail.h +@@ -119,6 +119,7 @@ struct nsjconf_t { + uint64_t rl_rtpr; + uint64_t rl_msgq; + bool disable_rl; ++ bool gvisor_compat; + unsigned long personality; + bool clone_newnet; + bool clone_newuser; +diff --git a/user.cc b/user.cc +index a335e2d..f3e578b 100644 +--- a/user.cc ++++ b/user.cc +@@ -260,10 +260,24 @@ bool initNsFromChild(nsjconf_t* nsjconf) { + * Make sure all capabilities are retained after the subsequent setuid/setgid, as they will + * be needed for privileged operations: mounts, uts change etc. + */ ++ bool securebits_set = true; + if (prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS | SECBIT_NO_SETUID_FIXUP, 0UL, 0UL, 0UL) == + -1) { +- PLOG_E("prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS | SECBIT_NO_SETUID_FIXUP)"); +- return false; ++ /* ++ * The bits only matter when setresuid() below changes the UID: without them, ++ * leaving UID 0 clears the capabilities still needed by the jail setup. ++ */ ++ uid_t ruid, euid, suid; ++ const uid_t uid = nsjconf->uids[0].inside_id; ++ if (!nsjconf->gvisor_compat || errno != EPERM || ++ getresuid(&ruid, &euid, &suid) == -1 || ruid != uid || euid != uid || ++ suid != uid) { ++ PLOG_E("prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS | SECBIT_NO_SETUID_FIXUP)"); ++ return false; ++ } ++ PLOG_W("prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS | SECBIT_NO_SETUID_FIXUP), " ++ "ignored (gvisor_compat, UID unchanged)"); ++ securebits_set = false; + } + + /* +@@ -306,7 +320,7 @@ bool initNsFromChild(nsjconf_t* nsjconf) { + * unexpectedly retaining capabilities after a UID/GID + * change. + */ +- if (prctl(PR_SET_SECUREBITS, 0UL, 0UL, 0UL, 0UL) == -1) { ++ if (securebits_set && prctl(PR_SET_SECUREBITS, 0UL, 0UL, 0UL, 0UL) == -1) { + PLOG_E("prctl(PR_SET_SECUREBITS, 0)"); + return false; + } From a7561fd8bde5c4a766a050507c2d9b9823c08bcc Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 01:38:00 +0200 Subject: [PATCH 42/46] fix: insert ApiAuthed into request extensions in no-auth mode (#11868) Co-authored-by: Claude Opus 5.5 --- backend/windmill-api-auth/src/auth.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/windmill-api-auth/src/auth.rs b/backend/windmill-api-auth/src/auth.rs index 8bf02acede..6bc9a930a4 100644 --- a/backend/windmill-api-auth/src/auth.rs +++ b/backend/windmill-api-auth/src/auth.rs @@ -1154,10 +1154,10 @@ pub async fn resolve_opt_job_authed( }; if is_no_auth() { - return Ok(( - OptJobAuthed { authed: no_auth_admin_authed(), job_id: None }, - parts, - )); + let authed = no_auth_admin_authed(); + // Handlers taking `Extension` read this insert, as on the token path. + parts.extensions.insert(authed.clone()); + return Ok((OptJobAuthed { authed, job_id: None }, parts)); } // Safe only while what the route checks below read is fixed before the first From bfa093e09c1da13db7ba22e668f9b3631894287c Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 01:53:17 +0200 Subject: [PATCH 43/46] fix: fork deploy override and selection out of step with the item list (#11871) * fix: keep the fork deploy override across selection changes * fix: drop selected rows that leave the fork comparison --- .../lib/components/CompareWorkspaces.svelte | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/components/CompareWorkspaces.svelte b/frontend/src/lib/components/CompareWorkspaces.svelte index e139d22910..5a22ed012d 100644 --- a/frontend/src/lib/components/CompareWorkspaces.svelte +++ b/frontend/src/lib/components/CompareWorkspaces.svelte @@ -813,7 +813,19 @@ } let deploymentErrorMessage = $state('') - let allowBehindChangesOverride = $state(false) + // The override acknowledges the outdated items listed next to it, not the + // selection, so it holds while every outdated item is one the user ticked it + // for: a refresh bringing in a new one asks again, one leaving the list does not. + let acknowledgedBehindKeys = $state | undefined>() + let allowBehindChangesOverride = $derived( + acknowledgedBehindKeys != undefined && + itemsWithBehindChanges.every((d) => acknowledgedBehindKeys!.has(getItemKey(d))) + ) + function setBehindChangesOverride(allow: boolean) { + acknowledgedBehindKeys = allow + ? new Set(itemsWithBehindChanges.map((d) => getItemKey(d))) + : undefined + } async function isComparisonUpToDate(): Promise { if (!comparison) { @@ -1122,18 +1134,17 @@ const current = new Set(diffs.filter(removesInTarget).map((d) => getItemKey(d))) const flipped = [...current].filter((k) => !removalKeys.has(k)) removalKeys = current - if (flipped.some((k) => selectedItems.includes(k))) { - selectedItems = selectedItems.filter((k) => !flipped.includes(k)) + // A row that left the list (made workspace specific, synced elsewhere) takes its + // tick with it: the deploy button counts the selection, and a key with no row + // would be reported as undeployable. + const listed = new Set(selectableDiffs.map((d) => getItemKey(d))) + const kept = selectedItems.filter((k) => listed.has(k) && !flipped.includes(k)) + if (kept.length !== selectedItems.length) { + selectedItems = kept } }) }) - // Reset override when selection or direction changes - $effect(() => { - ;[selectedItems, mergeIntoParent] - allowBehindChangesOverride = false - }) - // Trigger and schedule rows now flow through `comparison.diffs` like every // other deployable kind — the backend's `compareWorkspaces` populates them // from `workspace_diff`, with runtime fields ignored by `compare_two_*`. @@ -1582,7 +1593,8 @@ setBehindChangesOverride(e.currentTarget.checked)} class="rounded max-w-4" /> Override: Deploy despite {itemsWithBehindChanges.length} outdated item{itemsWithBehindChanges.length !== From de66e47b1c9fd4ca8c3aa0cba0e723bd338e55b4 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 01:53:42 +0200 Subject: [PATCH 44/46] chore(main): release 1.841.0 (#11860) * chore(main): release 1.841.0 * Apply automatic changes --------- Co-authored-by: rubenfiszel <275584+rubenfiszel@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 16 ++ backend/Cargo.lock | 162 +++++++++--------- backend/Cargo.toml | 4 +- .../parsers/windmill-parser-wasm/Cargo.lock | 48 +++--- .../parsers/windmill-parser-wasm/Cargo.toml | 2 +- backend/windmill-api/openapi.yaml | 2 +- benchmarks/lib.ts | 2 +- chat-sdk/package-lock.json | 4 +- chat-sdk/package.json | 2 +- cli/src/core/constants.ts | 2 +- frontend/package-lock.json | 4 +- frontend/package.json | 2 +- lsp/Pipfile | 2 +- openflow.openapi.yaml | 2 +- .../WindmillClient/WindmillClient.psd1 | 2 +- python-client/wmill/pyproject.toml | 2 +- typescript-client/jsr.json | 2 +- typescript-client/package.json | 2 +- version.txt | 2 +- windmill-yaml-validator/package-lock.json | 4 +- windmill-yaml-validator/package.json | 2 +- 22 files changed, 144 insertions(+), 128 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 98dbdc3deb..3714717023 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.840.0" + ".": "1.841.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 15223268e8..659adb9e25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## [1.841.0](https://github.com/windmill-labs/windmill/compare/v1.840.0...v1.841.0) (2026-10-18) + + +### Features + +* let agent workers authenticate with a workload identity token ([#11858](https://github.com/windmill-labs/windmill/issues/11858)) ([be23abb](https://github.com/windmill-labs/windmill/commit/be23abb3602ed9c45f1c66c98d5f84e7676dccfa)) +* let ALLOW_PRIVATE_MCP_SERVER_URLS name the private hosts it allows ([#11869](https://github.com/windmill-labs/windmill/issues/11869)) ([5c205fa](https://github.com/windmill-labs/windmill/commit/5c205fa46915de9e5fde731a117ba8571cfa56f7)) +* probe nsjail with a real jail and add a gVisor compat mode ([#11865](https://github.com/windmill-labs/windmill/issues/11865)) ([69d36f7](https://github.com/windmill-labs/windmill/commit/69d36f77daceb25cc903c7ea014ba8d487650b18)) + + +### Bug Fixes + +* insert ApiAuthed into request extensions in no-auth mode ([#11868](https://github.com/windmill-labs/windmill/issues/11868)) ([a7561fd](https://github.com/windmill-labs/windmill/commit/a7561fd8bde5c4a766a050507c2d9b9823c08bcc)) +* reject out-of-range integer args to narrow SQL types instead of wrapping ([#11864](https://github.com/windmill-labs/windmill/issues/11864)) ([19ec5d3](https://github.com/windmill-labs/windmill/commit/19ec5d3cd8a36600c8896a895d0e566735f729a9)) +* warn when an autoscaled worker group has no tags to count ([#11859](https://github.com/windmill-labs/windmill/issues/11859)) ([8b14a78](https://github.com/windmill-labs/windmill/commit/8b14a78822f95fb045d80940dfd9197f79ea88cc)) + ## [1.840.0](https://github.com/windmill-labs/windmill/compare/v1.839.0...v1.840.0) (2026-10-17) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 4ddc1a6f87..3f2dfbffec 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "arc-swap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b" +checksum = "380962b3d93b99642e50b9febf72c071e97e8b32d86eae9cf4ef582bb960ae6e" dependencies = [ "rustversion", ] @@ -15486,7 +15486,7 @@ dependencies = [ [[package]] name = "windmill" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-nats", @@ -15576,7 +15576,7 @@ dependencies = [ [[package]] name = "windmill-ai" -version = "1.840.0" +version = "1.841.0" dependencies = [ "async-stream", "async-trait", @@ -15611,7 +15611,7 @@ dependencies = [ [[package]] name = "windmill-alerting" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15624,7 +15624,7 @@ dependencies = [ [[package]] name = "windmill-api" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "argon2", @@ -15767,7 +15767,7 @@ dependencies = [ [[package]] name = "windmill-api-agent-workers" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15791,7 +15791,7 @@ dependencies = [ [[package]] name = "windmill-api-assets" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15808,7 +15808,7 @@ dependencies = [ [[package]] name = "windmill-api-auth" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -15834,7 +15834,7 @@ dependencies = [ [[package]] name = "windmill-api-client" -version = "1.840.0" +version = "1.841.0" dependencies = [ "reqwest 0.12.28", "serde", @@ -15844,7 +15844,7 @@ dependencies = [ [[package]] name = "windmill-api-configs" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15861,7 +15861,7 @@ dependencies = [ [[package]] name = "windmill-api-debug" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "base64 0.22.1", @@ -15883,7 +15883,7 @@ dependencies = [ [[package]] name = "windmill-api-embeddings" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -15906,7 +15906,7 @@ dependencies = [ [[package]] name = "windmill-api-flow-conversations" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15922,7 +15922,7 @@ dependencies = [ [[package]] name = "windmill-api-flows" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15944,7 +15944,7 @@ dependencies = [ [[package]] name = "windmill-api-groups" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15966,7 +15966,7 @@ dependencies = [ [[package]] name = "windmill-api-inputs" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -15980,7 +15980,7 @@ dependencies = [ [[package]] name = "windmill-api-integration-tests" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-nats", @@ -16016,7 +16016,7 @@ dependencies = [ [[package]] name = "windmill-api-jobs" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -16042,7 +16042,7 @@ dependencies = [ [[package]] name = "windmill-api-npm-proxy" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -16070,7 +16070,7 @@ dependencies = [ [[package]] name = "windmill-api-openapi" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -16092,7 +16092,7 @@ dependencies = [ [[package]] name = "windmill-api-schedule" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -16112,7 +16112,7 @@ dependencies = [ [[package]] name = "windmill-api-scripts" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -16154,7 +16154,7 @@ dependencies = [ [[package]] name = "windmill-api-settings" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -16184,7 +16184,7 @@ dependencies = [ [[package]] name = "windmill-api-sse" -version = "1.840.0" +version = "1.841.0" dependencies = [ "lazy_static", "serde", @@ -16196,7 +16196,7 @@ dependencies = [ [[package]] name = "windmill-api-users" -version = "1.840.0" +version = "1.841.0" dependencies = [ "argon2", "axum", @@ -16220,7 +16220,7 @@ dependencies = [ [[package]] name = "windmill-api-workers" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -16235,7 +16235,7 @@ dependencies = [ [[package]] name = "windmill-api-workspaces" -version = "1.840.0" +version = "1.841.0" dependencies = [ "axum", "chrono", @@ -16274,7 +16274,7 @@ dependencies = [ [[package]] name = "windmill-audit" -version = "1.840.0" +version = "1.841.0" dependencies = [ "chrono", "lazy_static", @@ -16289,7 +16289,7 @@ dependencies = [ [[package]] name = "windmill-autoscaling" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "axum", @@ -16308,7 +16308,7 @@ dependencies = [ [[package]] name = "windmill-common" -version = "1.840.0" +version = "1.841.0" dependencies = [ "aes-gcm", "aho-corasick", @@ -16426,7 +16426,7 @@ dependencies = [ [[package]] name = "windmill-dep-map" -version = "1.840.0" +version = "1.841.0" dependencies = [ "chrono", "futures", @@ -16446,7 +16446,7 @@ dependencies = [ [[package]] name = "windmill-git-sync" -version = "1.840.0" +version = "1.841.0" dependencies = [ "regex", "serde", @@ -16463,7 +16463,7 @@ dependencies = [ [[package]] name = "windmill-indexer" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "astral-tokio-tar", @@ -16490,7 +16490,7 @@ dependencies = [ [[package]] name = "windmill-jseval" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "futures", @@ -16507,7 +16507,7 @@ dependencies = [ [[package]] name = "windmill-macros" -version = "1.840.0" +version = "1.841.0" dependencies = [ "itertools 0.14.0", "lazy_static", @@ -16523,7 +16523,7 @@ dependencies = [ [[package]] name = "windmill-mcp" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -16545,7 +16545,7 @@ dependencies = [ [[package]] name = "windmill-native-triggers" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -16576,7 +16576,7 @@ dependencies = [ [[package]] name = "windmill-oauth" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "arc-swap", @@ -16601,7 +16601,7 @@ dependencies = [ [[package]] name = "windmill-object-store" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-stream", @@ -16637,7 +16637,7 @@ dependencies = [ [[package]] name = "windmill-operator" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "futures", @@ -16656,7 +16656,7 @@ dependencies = [ [[package]] name = "windmill-parser" -version = "1.840.0" +version = "1.841.0" dependencies = [ "convert_case 0.6.0", "serde", @@ -16665,7 +16665,7 @@ dependencies = [ [[package]] name = "windmill-parser-bash" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -16677,7 +16677,7 @@ dependencies = [ [[package]] name = "windmill-parser-csharp" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde_json", @@ -16689,7 +16689,7 @@ dependencies = [ [[package]] name = "windmill-parser-go" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "gosyn", @@ -16701,7 +16701,7 @@ dependencies = [ [[package]] name = "windmill-parser-graphql" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -16713,7 +16713,7 @@ dependencies = [ [[package]] name = "windmill-parser-java" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde_json", @@ -16725,7 +16725,7 @@ dependencies = [ [[package]] name = "windmill-parser-nu" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "nu-parser", @@ -16736,7 +16736,7 @@ dependencies = [ [[package]] name = "windmill-parser-php" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -16747,7 +16747,7 @@ dependencies = [ [[package]] name = "windmill-parser-py" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -16759,7 +16759,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-asset" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -16770,7 +16770,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-imports" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-recursion", @@ -16793,7 +16793,7 @@ dependencies = [ [[package]] name = "windmill-parser-r" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde_json", @@ -16805,7 +16805,7 @@ dependencies = [ [[package]] name = "windmill-parser-ruby" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -16819,7 +16819,7 @@ dependencies = [ [[package]] name = "windmill-parser-rust" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -16836,7 +16836,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -16849,7 +16849,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql-asset" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde", @@ -16861,7 +16861,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -16879,7 +16879,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts-asset" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde-wasm-bindgen", @@ -16895,7 +16895,7 @@ dependencies = [ [[package]] name = "windmill-parser-wac" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -16912,7 +16912,7 @@ dependencies = [ [[package]] name = "windmill-parser-yaml" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -16926,7 +16926,7 @@ dependencies = [ [[package]] name = "windmill-queue" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-recursion", @@ -16965,7 +16965,7 @@ dependencies = [ [[package]] name = "windmill-runtime-nativets" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "const_format", @@ -17003,7 +17003,7 @@ dependencies = [ [[package]] name = "windmill-sql-datatype-parser-wasm" -version = "1.840.0" +version = "1.841.0" dependencies = [ "getrandom 0.3.4", "wasm-bindgen", @@ -17014,7 +17014,7 @@ dependencies = [ [[package]] name = "windmill-store" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-recursion", @@ -17049,7 +17049,7 @@ dependencies = [ [[package]] name = "windmill-test-utils" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17073,7 +17073,7 @@ dependencies = [ [[package]] name = "windmill-trigger" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17106,7 +17106,7 @@ dependencies = [ [[package]] name = "windmill-trigger-amqp" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17133,7 +17133,7 @@ dependencies = [ [[package]] name = "windmill-trigger-azure" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17166,7 +17166,7 @@ dependencies = [ [[package]] name = "windmill-trigger-email" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17186,7 +17186,7 @@ dependencies = [ [[package]] name = "windmill-trigger-gcp" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17220,7 +17220,7 @@ dependencies = [ [[package]] name = "windmill-trigger-http" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17257,7 +17257,7 @@ dependencies = [ [[package]] name = "windmill-trigger-kafka" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17280,7 +17280,7 @@ dependencies = [ [[package]] name = "windmill-trigger-mqtt" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17304,7 +17304,7 @@ dependencies = [ [[package]] name = "windmill-trigger-nats" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-nats", @@ -17328,7 +17328,7 @@ dependencies = [ [[package]] name = "windmill-trigger-postgres" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17363,7 +17363,7 @@ dependencies = [ [[package]] name = "windmill-trigger-sqs" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17391,7 +17391,7 @@ dependencies = [ [[package]] name = "windmill-trigger-websocket" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-trait", @@ -17416,7 +17416,7 @@ dependencies = [ [[package]] name = "windmill-types" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "bitflags 2.13.2", @@ -17435,7 +17435,7 @@ dependencies = [ [[package]] name = "windmill-worker" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-once-cell", @@ -17553,7 +17553,7 @@ dependencies = [ [[package]] name = "windmill-worker-volumes" -version = "1.840.0" +version = "1.841.0" dependencies = [ "bytes", "futures", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 049ae66063..1851f386c2 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windmill" -version = "1.840.0" +version = "1.841.0" authors.workspace = true edition.workspace = true @@ -88,7 +88,7 @@ members = [ exclude = ["./windmill-duckdb-ffi-internal", "./parsers/windmill-parser-wasm"] [workspace.package] -version = "1.840.0" +version = "1.841.0" authors = ["Ruben Fiszel "] edition = "2021" diff --git a/backend/parsers/windmill-parser-wasm/Cargo.lock b/backend/parsers/windmill-parser-wasm/Cargo.lock index ff51e06c6c..f89fa1d49a 100644 --- a/backend/parsers/windmill-parser-wasm/Cargo.lock +++ b/backend/parsers/windmill-parser-wasm/Cargo.lock @@ -6340,7 +6340,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windmill-common" -version = "1.840.0" +version = "1.841.0" dependencies = [ "aes-gcm", "aho-corasick", @@ -6430,7 +6430,7 @@ dependencies = [ [[package]] name = "windmill-macros" -version = "1.840.0" +version = "1.841.0" dependencies = [ "proc-macro2", "quote", @@ -6442,7 +6442,7 @@ dependencies = [ [[package]] name = "windmill-parser" -version = "1.840.0" +version = "1.841.0" dependencies = [ "convert_case", "serde", @@ -6451,7 +6451,7 @@ dependencies = [ [[package]] name = "windmill-parser-bash" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -6463,7 +6463,7 @@ dependencies = [ [[package]] name = "windmill-parser-csharp" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde_json", @@ -6475,7 +6475,7 @@ dependencies = [ [[package]] name = "windmill-parser-go" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "gosyn", @@ -6487,7 +6487,7 @@ dependencies = [ [[package]] name = "windmill-parser-graphql" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -6499,7 +6499,7 @@ dependencies = [ [[package]] name = "windmill-parser-java" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde_json", @@ -6511,7 +6511,7 @@ dependencies = [ [[package]] name = "windmill-parser-nu" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "nu-parser", @@ -6522,7 +6522,7 @@ dependencies = [ [[package]] name = "windmill-parser-php" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -6533,7 +6533,7 @@ dependencies = [ [[package]] name = "windmill-parser-py" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -6545,7 +6545,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-asset" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -6556,7 +6556,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-imports" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "async-recursion", @@ -6579,7 +6579,7 @@ dependencies = [ [[package]] name = "windmill-parser-r" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde_json", @@ -6591,7 +6591,7 @@ dependencies = [ [[package]] name = "windmill-parser-ruby" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -6605,7 +6605,7 @@ dependencies = [ [[package]] name = "windmill-parser-rust" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "convert_case", @@ -6622,7 +6622,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -6635,7 +6635,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql-asset" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde", @@ -6647,7 +6647,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -6665,7 +6665,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts-asset" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "serde-wasm-bindgen", @@ -6681,7 +6681,7 @@ dependencies = [ [[package]] name = "windmill-parser-wac" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -6698,7 +6698,7 @@ dependencies = [ [[package]] name = "windmill-parser-wasm" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "getrandom 0.2.17", @@ -6730,7 +6730,7 @@ dependencies = [ [[package]] name = "windmill-parser-yaml" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "lazy_static", @@ -6744,7 +6744,7 @@ dependencies = [ [[package]] name = "windmill-types" -version = "1.840.0" +version = "1.841.0" dependencies = [ "anyhow", "bitflags", diff --git a/backend/parsers/windmill-parser-wasm/Cargo.toml b/backend/parsers/windmill-parser-wasm/Cargo.toml index 5926c4dd7d..d6c0389840 100644 --- a/backend/parsers/windmill-parser-wasm/Cargo.toml +++ b/backend/parsers/windmill-parser-wasm/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" members = ["."] [workspace.package] -version = "1.840.0" +version = "1.841.0" edition = "2021" authors = ["Ruben Fiszel "] diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index f851ada1c0..64534d0afc 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -1,7 +1,7 @@ openapi: "3.0.3" info: - version: 1.840.0 + version: 1.841.0 title: Windmill API contact: diff --git a/benchmarks/lib.ts b/benchmarks/lib.ts index 3c4e13839b..61315e1683 100644 --- a/benchmarks/lib.ts +++ b/benchmarks/lib.ts @@ -2,7 +2,7 @@ import { sleep } from "https://deno.land/x/sleep@v1.2.1/mod.ts"; import * as windmill from "https://deno.land/x/windmill@v1.174.0/mod.ts"; import * as api from "https://deno.land/x/windmill@v1.174.0/windmill-api/index.ts"; -export const VERSION = "v1.840.0"; +export const VERSION = "v1.841.0"; export async function login(email: string, password: string): Promise { return await windmill.UserService.login({ diff --git a/chat-sdk/package-lock.json b/chat-sdk/package-lock.json index 85647c34a6..93d3e00348 100644 --- a/chat-sdk/package-lock.json +++ b/chat-sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@windmill-labs/chat-sdk", - "version": "1.840.0", + "version": "1.841.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@windmill-labs/chat-sdk", - "version": "1.840.0", + "version": "1.841.0", "license": "Apache-2.0", "devDependencies": { "@ai-sdk/react": "^4.0.102", diff --git a/chat-sdk/package.json b/chat-sdk/package.json index 089b41a1ee..ca4b73df45 100644 --- a/chat-sdk/package.json +++ b/chat-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@windmill-labs/chat-sdk", "description": "Build chat interfaces on Windmill flows deployed in chat mode, from any frontend or raw app", - "version": "1.840.0", + "version": "1.841.0", "author": "Ruben Fiszel", "license": "Apache-2.0", "homepage": "https://github.com/windmill-labs/windmill/tree/main/chat-sdk#readme", diff --git a/cli/src/core/constants.ts b/cli/src/core/constants.ts index 7ab4151f59..d65b343bfe 100644 --- a/cli/src/core/constants.ts +++ b/cli/src/core/constants.ts @@ -10,4 +10,4 @@ export const WM_FORK_PREFIX = "wm-fork"; // (e.g. utils.ts) can read it without importing main.ts and creating a circular // dependency (main → workspace → utils → main) that triggers a TDZ. // Re-exported from main.ts for backwards compatibility. -export const VERSION = "1.840.0"; +export const VERSION = "1.841.0"; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 220d9e2d33..30ac859fce 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "@windmill-labs/components", - "version": "1.840.0", + "version": "1.841.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@windmill-labs/components", - "version": "1.840.0", + "version": "1.841.0", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/frontend/package.json b/frontend/package.json index cbab8b4faa..7320d9c5f6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@windmill-labs/components", - "version": "1.840.0", + "version": "1.841.0", "scripts": { "dev": "vite dev", "dev:ui-builder": "mv static/ui_builder static/ui_builder.dev-disabled 2>/dev/null || true ; trap 'mv static/ui_builder.dev-disabled static/ui_builder 2>/dev/null || true' EXIT ; vite dev", diff --git a/lsp/Pipfile b/lsp/Pipfile index ea0f102c49..46dab6afb9 100644 --- a/lsp/Pipfile +++ b/lsp/Pipfile @@ -4,7 +4,7 @@ verify_ssl = true name = "pypi" [packages] -wmill = ">=1.840.0" +wmill = ">=1.841.0" sendgrid = "*" mysql-connector-python = "*" pymongo = "*" diff --git a/openflow.openapi.yaml b/openflow.openapi.yaml index 4fd1d4a5a6..57e5009b90 100644 --- a/openflow.openapi.yaml +++ b/openflow.openapi.yaml @@ -1,7 +1,7 @@ openapi: '3.0.3' info: - version: 1.840.0 + version: 1.841.0 title: OpenFlow Spec contact: name: Ruben Fiszel diff --git a/powershell-client/WindmillClient/WindmillClient.psd1 b/powershell-client/WindmillClient/WindmillClient.psd1 index 29259c8a01..35e7468900 100644 --- a/powershell-client/WindmillClient/WindmillClient.psd1 +++ b/powershell-client/WindmillClient/WindmillClient.psd1 @@ -12,7 +12,7 @@ RootModule = 'WindmillClient.psm1' # Version number of this module. - ModuleVersion = '1.840.0' + ModuleVersion = '1.841.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/python-client/wmill/pyproject.toml b/python-client/wmill/pyproject.toml index 812b98244b..2c9f5143bf 100644 --- a/python-client/wmill/pyproject.toml +++ b/python-client/wmill/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wmill" -version = "1.840.0" +version = "1.841.0" description = "A client library for accessing Windmill server wrapping the Windmill client API" license = "Apache-2.0" homepage = "https://windmill.dev" diff --git a/typescript-client/jsr.json b/typescript-client/jsr.json index 8319cc8c7e..4fe0db6362 100644 --- a/typescript-client/jsr.json +++ b/typescript-client/jsr.json @@ -1,6 +1,6 @@ { "name": "@windmill/windmill", - "version": "1.840.0", + "version": "1.841.0", "exports": "./src/index.ts", "publish": { "exclude": ["!src", "./s3Types.ts", "./sqlUtils.ts", "./client.ts", "./wacError.ts"] diff --git a/typescript-client/package.json b/typescript-client/package.json index 579a9d6f93..28d7c1a372 100644 --- a/typescript-client/package.json +++ b/typescript-client/package.json @@ -1,7 +1,7 @@ { "name": "windmill-client", "description": "Windmill SDK client for browsers and Node.js", - "version": "1.840.0", + "version": "1.841.0", "author": "Ruben Fiszel", "license": "Apache 2.0", "homepage": "https://github.com/windmill-labs/windmill/tree/main/typescript-client#readme", diff --git a/version.txt b/version.txt index 0b6baeaae9..d3f2471c1f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.840.0 +1.841.0 diff --git a/windmill-yaml-validator/package-lock.json b/windmill-yaml-validator/package-lock.json index 32d3eaf688..7dd2fc2d48 100644 --- a/windmill-yaml-validator/package-lock.json +++ b/windmill-yaml-validator/package-lock.json @@ -1,12 +1,12 @@ { "name": "windmill-yaml-validator", - "version": "1.840.0", + "version": "1.841.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "windmill-yaml-validator", - "version": "1.840.0", + "version": "1.841.0", "license": "Apache 2.0", "dependencies": { "@stoplight/yaml": "^4.3.0", diff --git a/windmill-yaml-validator/package.json b/windmill-yaml-validator/package.json index 105e7aff81..ea082c2268 100644 --- a/windmill-yaml-validator/package.json +++ b/windmill-yaml-validator/package.json @@ -1,6 +1,6 @@ { "name": "windmill-yaml-validator", - "version": "1.840.0", + "version": "1.841.0", "description": "YAML validator for Windmill flow, schedule, and trigger files", "main": "dist/index.js", "types": "dist/index.d.ts", From adae5b32a3599b300112201d16c6a14c42cd1410 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 12:55:30 +0200 Subject: [PATCH 45/46] chore: drop the temporary git sync e2e loop and race diagnostics (#11877) Co-authored-by: Claude Opus 5.5 --- .github/workflows/git-sync-test.yml | 11 ++--------- integration_tests/test/git_sync_test.py | 12 ------------ 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/workflows/git-sync-test.yml b/.github/workflows/git-sync-test.yml index dd29837926..b19f899a20 100644 --- a/.github/workflows/git-sync-test.yml +++ b/.github/workflows/git-sync-test.yml @@ -206,21 +206,14 @@ jobs: curl -sf http://localhost:8000/api/version > /dev/null || { echo "Windmill failed to start"; exit 1; } - name: Run git sync E2E tests - timeout-minutes: 75 + timeout-minutes: 10 env: GITEA_DOCKER_URL: http://localhost:3000 LICENSE_KEY: ${{ secrets.WM_LICENSE_KEY_CI }} run: | python3 -m venv .venv .venv/bin/pip install -r integration_tests/requirements.txt - cd integration_tests - fails=0 - for i in $(seq 1 8); do - echo "TEMP-LOOP iteration $i" - ../.venv/bin/python -m unittest -v test.git_sync_test || fails=$((fails+1)) - done - echo "TEMP-LOOP failed iterations: $fails" - [ "$fails" = 0 ] + cd integration_tests && ../.venv/bin/python -m unittest -v test.git_sync_test - name: Archive logs uses: actions/upload-artifact@v4 diff --git a/integration_tests/test/git_sync_test.py b/integration_tests/test/git_sync_test.py index 13032f070d..aee7ea1088 100644 --- a/integration_tests/test/git_sync_test.py +++ b/integration_tests/test/git_sync_test.py @@ -253,18 +253,6 @@ class GitSyncTestBase(unittest.TestCase): interval=2, message=f"no push job for {script_path}", ) - # TEMP-DIAG: would the old count-based wait have returned before our push? - ours = self._new_sync_jobs(seen, script_path) - ours_ids = {j["id"] for j in ours} - ours_done = min(j.get("completed_at") or "" for j in ours) - others = [ - (j["id"], j.get("completed_at"), (j.get("args") or {}).get("repo_url_resource_path")) - for j in self._client.get_completed_jobs(job_kinds="deploymentcallback") - if j["id"] not in seen and j["id"] not in ours_ids - and (j.get("completed_at") or "") < ours_done - ] - print(f"TEMP-DIAG seed={script_path} ours_done={ours_done} earlier_others={others}" - + (" RACE-HIT" if others else ""), flush=True) failed = [j for j in self._new_sync_jobs(seen, script_path) if not j.get("success")] self.assertEqual(failed, [], f"the push of {script_path} failed") return script_path From a3a4fa503804eb9f031699b60e00a196d223cbe6 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 19 Oct 2026 13:09:03 +0200 Subject: [PATCH 46/46] fix: let devops users reach instance pages without a workspace (#11876) * fix: let devops users reach instance pages without a workspace Co-Authored-By: Claude Opus 5.5 * fix: hide workspace-bound worker actions when no workspace is selected Co-Authored-By: Claude Opus 5.5 * fix: keep the page header bar in the no-workspace instance view Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- frontend/src/lib/instanceRoutes.ts | 10 +++++ .../src/routes/(root)/(logged)/+layout.svelte | 31 ++++++++++++- .../user/(user)/workspaces/+page.svelte | 43 +++++++++++++------ .../(root)/(logged)/workers/+page.svelte | 15 +++++-- frontend/src/routes/(root)/+layout.svelte | 4 +- 5 files changed, 84 insertions(+), 19 deletions(-) create mode 100644 frontend/src/lib/instanceRoutes.ts diff --git a/frontend/src/lib/instanceRoutes.ts b/frontend/src/lib/instanceRoutes.ts new file mode 100644 index 0000000000..7d57dc1b81 --- /dev/null +++ b/frontend/src/lib/instanceRoutes.ts @@ -0,0 +1,10 @@ +/** + * Pages a devops user can open without belonging to any workspace. Devops grants no workspace + * access, so such a page renders with `$workspaceStore` and `$userStore` unset and must hide + * whatever needs them (a workspace-scoped call or a link into a workspace) rather than break. + */ +const INSTANCE_ROUTES = ['/workers', '/service_logs'] + +export function isInstanceRoute(pathname: string): boolean { + return INSTANCE_ROUTES.some((r) => pathname === r || pathname.startsWith(r + '/')) +} diff --git a/frontend/src/routes/(root)/(logged)/+layout.svelte b/frontend/src/routes/(root)/(logged)/+layout.svelte index 918b5cd4d7..3fe47a74fc 100644 --- a/frontend/src/routes/(root)/(logged)/+layout.svelte +++ b/frontend/src/routes/(root)/(logged)/+layout.svelte @@ -79,8 +79,11 @@ Home, Play, Search, - WandSparkles + WandSparkles, + ArrowLeft } from 'lucide-svelte' + import { Button } from '$lib/components/common' + import { isInstanceRoute } from '$lib/instanceRoutes' import { getUserExt } from '$lib/user' import { confirmPendingLoginMethod } from '$lib/lastLoginMethod' import { deepEqual } from 'fast-equals' @@ -796,6 +799,11 @@ } let devOnly = $derived(page.url.pathname.startsWith('/scripts/dev')) + // A devops user who belongs to no workspace has no `$userStore`, and would otherwise wait on + // "Loading user..." forever on the instance pages their role exists for. + let instanceOnlyView = $derived( + !$workspaceStore && !!$devopsRole && isInstanceRoute(page.url.pathname) + ) async function loadDefaultScripts(workspace: string, user: UserExt | undefined) { if (!user?.operator) { @@ -1566,6 +1574,27 @@ outside this layout, and their shortcut must reopen the URL that is their creden />
+{:else if instanceOnlyView} + +
+
+ +
+ +
+
+
+ {@render children?.()} +
+
{:else} {/if} diff --git a/frontend/src/routes/(root)/(logged)/user/(user)/workspaces/+page.svelte b/frontend/src/routes/(root)/(logged)/user/(user)/workspaces/+page.svelte index 2c5e626578..046f723e85 100644 --- a/frontend/src/routes/(root)/(logged)/user/(user)/workspaces/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/user/(user)/workspaces/+page.svelte @@ -9,6 +9,7 @@ import { UserService, type WorkspaceInvite, WorkspaceService } from '$lib/gen' import { superadmin, + devopsRole, usersWorkspaceStore, userWorkspaces, workspaceStore, @@ -30,7 +31,9 @@ Search, ChevronsDownUp, ChevronsUpDown, - LogOut + LogOut, + Logs, + ServerCog } from 'lucide-svelte' import { isCloudHosted } from '$lib/cloud' import { isValidLogoutRedirect, toSameOriginRelativePath } from '$lib/logoutRedirect' @@ -169,17 +172,17 @@ let workspacesLoaded = $derived.by( () => workspaces !== undefined && $usersWorkspaceStore !== undefined ) - // Not for a superadmin: this page is also where they reach the instance settings and the - // list-all toggle, and standing the picker down takes both away — a superadmin with no - // membership of their own has business here besides creating a workspace. Waiting for the - // store to answer rather than reading `!$superadmin`, which is true while `globalWhoami` - // is still in flight. + // Not for a superadmin or devops user: this page is also where they reach the instance + // settings, the list-all toggle and the instance pages, and standing the picker down takes + // those away — they have business here besides creating a workspace. `$devopsRole` is truthy + // for a superadmin too. Waiting for the store to answer rather than reading `!$devopsRole`, + // which is true while `globalWhoami` is still in flight. let nothingToChoose = $derived( workspacesLoaded && invitesLoaded && createWorkspace && - $superadmin !== undefined && - !$superadmin && + $devopsRole !== undefined && + !$devopsRole && !list_all_as_super_admin && allWorkspaces.length === 0 && invites.length === 0 @@ -206,11 +209,11 @@ let showCreate = $state(false) $effect(() => { if (nothingToChoose) showCreate = true - // Except for a superadmin, whom `nothingToChoose` excludes — so this only ever undoes a - // latch that should not have happened: one taken on a stale `false` before the forced - // `refreshSuperadmin` above answered. Without it that superadmin would be stuck on the - // create form, instance settings and the list-all toggle gone with it, until a reload. - else if ($superadmin) showCreate = false + // Except for a superadmin or devops user, whom `nothingToChoose` excludes — so this only + // ever undoes a latch that should not have happened: one taken on a stale `false` before + // the forced `refreshSuperadmin` above answered. Without it they would be stuck on the + // create form, with what they came here for gone with it, until a reload. + else if ($devopsRole) showCreate = false }) async function speakFriendAndEnterWorkspace(workspaceId: string) { @@ -518,6 +521,20 @@ {/if} {/if} + + {#if !showCreate && $devopsRole && !$superadmin} +

Instance

+
+ + +
+ {/if} + diff --git a/frontend/src/routes/(root)/(logged)/workers/+page.svelte b/frontend/src/routes/(root)/(logged)/workers/+page.svelte index 78caf47cf1..5fa5ef7f56 100644 --- a/frontend/src/routes/(root)/(logged)/workers/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/workers/+page.svelte @@ -602,9 +602,12 @@ if (!config || !config.worker_tags || config.worker_tags.length === 0) cols += 1 // Worker tags if ((!config || config?.dedicated_worker == undefined) && ($superadmin || $devopsRole)) cols += 2 // Last job, Occupancy rate - if ($superadmin || $devopsRole) cols += 1 // Repl + if (replAvailable) cols += 1 // Repl return cols }) + // The REPL runs its commands as jobs in the selected workspace, which a devops user who + // belongs to no workspace does not have (see `isInstanceRoute`). + let replAvailable = $derived(($superadmin || $devopsRole) && !!$workspaceStore) {#if $superadmin || $devopsRole} @@ -1022,7 +1025,7 @@ Limits Version Status - {#if $superadmin || $devopsRole} + {#if replAvailable} Repl @@ -1152,13 +1155,17 @@ {jobs_executed} {#if (!config || config?.dedicated_worker == undefined) && ($superadmin || $devopsRole)} - {#if last_job_id} + + {#if last_job_id && $workspaceStore}
View last job
{last_job_workspace_id} + {:else if last_job_id} + {last_job_workspace_id} {/if} @@ -1277,7 +1284,7 @@
{pingText}
- {#if $superadmin || $devopsRole} + {#if replAvailable}