Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/ee-repo-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cac1d382a7c22e8a4e9c56832ad12d11de5bba7f
57c9ae5b1b5c594fcdd9b398052a24006a367117
8 changes: 4 additions & 4 deletions backend/windmill-queue/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4992,10 +4992,10 @@ pub async fn pull(
};

if let Some(job) = job.as_ref() {
if (job.is_flow() || job.is_dependency())
&& !(job.kind.is_preview()
&& PREVIEW_TAGS_OVERRIDE.load(std::sync::atomic::Ordering::Relaxed))
{
// An agent worker cannot drive a flow, so a flow preview on an agent's tag is
// requeued too, preview tags override or not: the job keeps its tag in v2_job
// for its steps.
if job.is_flow() || job.is_dependency() {
let tag = match configured_dependency_job_tag(
&job.kind,
job.script_lang.as_ref(),
Expand Down
81 changes: 81 additions & 0 deletions backend/windmill-queue/tests/custom_query_flow_requeue_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//! A flow job pulled through a caller's own query (an agent worker's) is handed to the generic
//! flow tag, flow previews under the preview tag override included: an agent cannot drive a flow.
//!
//! Run with:
//! cargo test -p windmill-queue --test custom_query_flow_requeue_test
use std::collections::HashMap;
use std::sync::atomic::Ordering;

use sqlx::{Pool, Postgres};
use windmill_common::jobs::JobPayload;
use windmill_common::worker::{make_pull_query, PREVIEW_TAGS_OVERRIDE};
use windmill_queue::{pull, push, PushArgs, PushIsolationLevel};

#[sqlx::test(migrations = "../migrations", fixtures("base"))]
async fn flow_preview_on_an_agent_tag_goes_to_the_flow_tag(db: Pool<Postgres>) {
PREVIEW_TAGS_OVERRIDE.store(true, Ordering::Relaxed);

let payload = JobPayload::RawFlow {
value: serde_json::from_value(serde_json::json!({ "modules": [] })).unwrap(),
path: None,
restarted_from: None,
};
let args = HashMap::new();
let (id, tx) = push(
&db,
PushIsolationLevel::IsolatedRoot(db.clone()),
"test-workspace",
payload,
PushArgs { extra: None, args: &args },
"test-user",
"test@windmill.dev",
"u/test-user".to_string(),
None,
None,
None,
None,
None,
None,
None,
None,
false,
false,
None,
true,
Some("agentx".to_string()),
None,
None,
None,
None,
false,
None,
None,
None,
None,
)
.await
.expect("push");
tx.commit().await.expect("commit push");

let query = (String::new(), make_pull_query(&["agentx".to_string()]));
let pulled = pull(&db, false, "ag-test", Some(&query))
.await
.expect("pull");
assert!(pulled.job.is_none(), "an agent must not receive a flow job");

let (queue_tag, running): (String, bool) =
sqlx::query_as("SELECT tag, running FROM v2_job_queue WHERE id = $1")
.bind(id)
.fetch_one(&db)
.await
.unwrap();
assert_eq!((queue_tag.as_str(), running), ("flow", false));
// Its steps inherit this one.
let job_tag: String = sqlx::query_scalar("SELECT tag FROM v2_job WHERE id = $1")
.bind(id)
.fetch_one(&db)
.await
.unwrap();
assert_eq!(job_tag, "agentx");
}
2 changes: 1 addition & 1 deletion backend/windmill-worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5312,7 +5312,7 @@ pub async fn handle_queued_job(
Ok(JobOutcome::Completed)
} else {
return Err(Error::internal_err(
"Could not handle flow job with agent worker".to_string(),
"Agent workers do not run flow jobs: the server hands a flow on an agent's tag to a regular worker serving the flow tag".to_string(),
));
}
} else {
Expand Down
Loading