feat(backend): add job_id as a query arg to force set the new job_id

This commit is contained in:
Ruben Fiszel
2023-05-15 10:50:36 +02:00
parent da2902aa9d
commit 9ea18b4593
10 changed files with 55 additions and 1 deletions
+1
View File
@@ -842,6 +842,7 @@ impl RunJob {
/* schedule_path */ None,
/* parent_job */ None,
/* root job */ None,
/* job_id */ None,
/* is_flow_step */ false,
/* running */ false,
None,
+18
View File
@@ -2517,6 +2517,7 @@ paths:
schema:
type: integer
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- name: invisible_to_owner
description: make the run invisible to the the script owner (default false)
in: query
@@ -2549,6 +2550,7 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/ScriptPath"
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- $ref: "#/components/parameters/QueueLimit"
@@ -2576,6 +2578,7 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/ScriptPath"
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- $ref: "#/components/parameters/QueueLimit"
- $ref: "#/components/parameters/Payload"
@@ -2598,6 +2601,7 @@ paths:
- $ref: "#/components/parameters/ScriptPath"
- $ref: "#/components/parameters/IncludeHeader"
- $ref: "#/components/parameters/QueueLimit"
- $ref: "#/components/parameters/NewJobId"
requestBody:
description: script args
@@ -3344,6 +3348,7 @@ paths:
schema:
type: integer
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the flow owner (default false)
@@ -3389,6 +3394,7 @@ paths:
schema:
type: integer
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the script owner (default false)
@@ -3426,6 +3432,8 @@ paths:
in: query
schema:
type: boolean
- $ref: "#/components/parameters/NewJobId"
requestBody:
description: preview
required: true
@@ -3457,6 +3465,7 @@ paths:
in: query
schema:
type: boolean
- $ref: "#/components/parameters/NewJobId"
requestBody:
description: preview
@@ -5076,6 +5085,15 @@ components:
schema:
type: string
format: uuid
NewJobId:
name: job_id
description:
The job id to assign to the created job. if missing, job is chosen randomly using the ULID scheme.
If a job id already exists in the queue or as a completed job, the request to create one will fail (Bad Request)
in: query
schema:
type: string
format: uuid
IncludeHeader:
name: include_header
description: |
+1
View File
@@ -811,6 +811,7 @@ async fn execute_component(
None,
None,
None,
None,
false,
false,
None,
+2
View File
@@ -257,6 +257,7 @@ async fn create_flow(
None,
None,
None,
None,
false,
false,
None,
@@ -425,6 +426,7 @@ async fn update_flow(
None,
None,
None,
None,
false,
false,
None,
+10
View File
@@ -348,6 +348,7 @@ pub struct RunJobQuery {
invisible_to_owner: Option<bool>,
queue_limit: Option<i64>,
payload: Option<String>,
job_id: Option<Uuid>,
}
lazy_static::lazy_static! {
@@ -1314,6 +1315,7 @@ pub async fn run_flow_by_path(
None,
run_query.parent_job,
run_query.parent_job,
run_query.job_id,
false,
false,
None,
@@ -1352,6 +1354,7 @@ pub async fn run_job_by_path(
scheduled_for,
None,
run_query.parent_job,
run_query.job_id,
run_query.parent_job,
false,
false,
@@ -1550,6 +1553,7 @@ pub async fn run_wait_result_job_by_path_get(
None,
run_query.parent_job,
run_query.parent_job,
run_query.job_id,
false,
false,
None,
@@ -1599,6 +1603,7 @@ pub async fn run_wait_result_job_by_path(
None,
run_query.parent_job,
run_query.parent_job,
run_query.job_id,
false,
false,
None,
@@ -1648,6 +1653,7 @@ pub async fn run_wait_result_job_by_hash(
None,
run_query.parent_job,
run_query.parent_job,
run_query.job_id,
false,
false,
None,
@@ -1696,6 +1702,7 @@ pub async fn run_wait_result_flow_by_path(
None,
run_query.parent_job,
run_query.parent_job,
run_query.job_id,
false,
false,
None,
@@ -1745,6 +1752,7 @@ async fn run_preview_job(
None,
None,
None,
run_query.job_id,
false,
false,
None,
@@ -1782,6 +1790,7 @@ async fn run_preview_flow_job(
None,
None,
None,
run_query.job_id,
false,
false,
None,
@@ -1821,6 +1830,7 @@ pub async fn run_job_by_hash(
None,
run_query.parent_job,
run_query.parent_job,
run_query.job_id,
false,
false,
None,
+1
View File
@@ -796,6 +796,7 @@ async fn slack_command(
None,
None,
None,
None,
false,
false,
None,
+1
View File
@@ -489,6 +489,7 @@ async fn create_script(
None,
None,
None,
None,
false,
false,
None,
+19 -1
View File
@@ -324,6 +324,7 @@ pub async fn push<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
schedule_path: Option<String>,
parent_job: Option<Uuid>,
root_job: Option<Uuid>,
job_id: Option<Uuid>,
is_flow_step: bool,
mut same_worker: bool,
pre_run_error: Option<&windmill_common::error::Error>,
@@ -331,7 +332,24 @@ pub async fn push<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
mut tag: Option<String>,
) -> Result<(Uuid, QueueTransaction<'c, R>), Error> {
let args_json = serde_json::Value::Object(args);
let job_id: Uuid = Ulid::new().into();
let job_id: Uuid = if let Some(job_id) = job_id {
let conflicting_id = sqlx::query_scalar!(
"SELECT 1 FROM queue WHERE id = $1 UNION ALL select 1 FROM completed_job WHERE id = $1",
job_id
)
.fetch_optional(&mut tx)
.await?;
if conflicting_id.is_some() {
return Err(Error::BadRequest(format!(
"Job with id {job_id} already exists"
)));
}
job_id
} else {
Ulid::new().into()
};
if cfg!(feature = "enterprise") {
let premium_workspace = *CLOUD_HOSTED
+1
View File
@@ -102,6 +102,7 @@ pub async fn push_scheduled_job<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
Some(schedule.path.clone()),
None,
None,
None,
false,
false,
None,
@@ -1387,6 +1387,7 @@ async fn push_next_flow_job<R: rsmq_async::RsmqConnection + Send + Sync + Clone>
flow_job.schedule_path.clone(),
Some(flow_job.id),
root_job,
None,
true,
continue_on_same_worker,
err,