From 12030e0b173721396527761b0c02d4a833b5cfb8 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 5 Nov 2023 18:59:32 +0100 Subject: [PATCH] add version to workers --- backend/windmill-api/openapi.yaml | 71 +++++++++++++------ backend/windmill-api/src/workers.rs | 3 +- backend/windmill-common/src/worker.rs | 5 +- .../(root)/(logged)/workers/+page.svelte | 10 ++- 4 files changed, 61 insertions(+), 28 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 3c0bb5e12f752..49b29d1cc7848 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -2094,7 +2094,8 @@ paths: /w/{workspace}/resources/get_value_interpolated/{path}: get: - summary: get resource interpolated (variables and resources are fully unrolled) + summary: + get resource interpolated (variables and resources are fully unrolled) operationId: getResourceValueInterpolated tags: - resource @@ -2782,7 +2783,8 @@ paths: schema: type: string - name: first_parent_hash - description: mask to filter scripts whom first direct parent has exact hash + description: + mask to filter scripts whom first direct parent has exact hash in: query schema: type: string @@ -2977,7 +2979,8 @@ paths: /workers/custom_tags: get: - summary: get all instance custom tags (tags are used to dispatch jobs to + summary: + get all instance custom tags (tags are used to dispatch jobs to different worker groups) operationId: getCustomTags tags: @@ -3028,7 +3031,8 @@ paths: /w/{workspace}/scripts/delete/h/{hash}: post: - summary: delete script by hash (erase content but keep hash, require admin) + summary: + delete script by hash (erase content but keep hash, require admin) operationId: deleteScriptByHash tags: - script @@ -3220,14 +3224,16 @@ paths: type: string format: date-time - name: scheduled_in_secs - description: schedule the script to execute in the number of seconds starting now + description: + schedule the script to execute in the number of seconds starting now in: query 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) + description: + make the run invisible to the the script owner (default false) in: query schema: type: boolean @@ -4200,7 +4206,8 @@ paths: type: string format: date-time - name: scheduled_in_secs - description: schedule the script to execute in the number of seconds starting now + description: + schedule the script to execute in the number of seconds starting now in: query schema: type: integer @@ -4208,7 +4215,8 @@ paths: - $ref: "#/components/parameters/NewJobId" - $ref: "#/components/parameters/IncludeHeader" - name: invisible_to_owner - description: make the run invisible to the the flow owner (default false) + description: + make the run invisible to the the flow owner (default false) in: query schema: type: boolean @@ -4246,7 +4254,9 @@ paths: schema: type: string - name: branch_or_iteration_n - description: for branchall or loop, the iteration at which the flow should restart + description: + for branchall or loop, the iteration at which the flow should + restart required: true in: path schema: @@ -4258,7 +4268,8 @@ paths: type: string format: date-time - name: scheduled_in_secs - description: schedule the script to execute in the number of seconds starting now + description: + schedule the script to execute in the number of seconds starting now in: query schema: type: integer @@ -4266,7 +4277,8 @@ paths: - $ref: "#/components/parameters/NewJobId" - $ref: "#/components/parameters/IncludeHeader" - name: invisible_to_owner - description: make the run invisible to the the flow owner (default false) + description: + make the run invisible to the the flow owner (default false) in: query schema: type: boolean @@ -4304,7 +4316,8 @@ paths: type: string format: date-time - name: scheduled_in_secs - description: schedule the script to execute in the number of seconds starting now + description: + schedule the script to execute in the number of seconds starting now in: query schema: type: integer @@ -4312,7 +4325,8 @@ paths: - $ref: "#/components/parameters/NewJobId" - $ref: "#/components/parameters/IncludeHeader" - name: invisible_to_owner - description: make the run invisible to the the script owner (default false) + description: + make the run invisible to the the script owner (default false) in: query schema: type: boolean @@ -4343,7 +4357,8 @@ paths: - $ref: "#/components/parameters/WorkspaceId" - $ref: "#/components/parameters/IncludeHeader" - name: invisible_to_owner - description: make the run invisible to the the script owner (default false) + description: + make the run invisible to the the script owner (default false) in: query schema: type: boolean @@ -4376,7 +4391,8 @@ paths: - $ref: "#/components/parameters/WorkspaceId" - $ref: "#/components/parameters/IncludeHeader" - name: invisible_to_owner - description: make the run invisible to the the script owner (default false) + description: + make the run invisible to the the script owner (default false) in: query schema: type: boolean @@ -4591,7 +4607,8 @@ paths: - job responses: "200": - description: the timestamp of the db that can be used to compute the drift + description: + the timestamp of the db that can be used to compute the drift content: application/json: schema: @@ -4827,7 +4844,8 @@ paths: /w/{workspace}/jobs/resume_urls/{id}/{resume_id}: get: - summary: get resume urls given a job_id, resume_id and a nonce to resume a flow + summary: + get resume urls given a job_id, resume_id and a nonce to resume a flow operationId: getResumeUrls tags: - job @@ -5340,7 +5358,8 @@ paths: - $ref: "#/components/parameters/WorkspaceId" - name: only_member_of in: query - description: only list the groups the user is member of (default false) + description: + only list the groups the user is member of (default false) schema: type: boolean responses: @@ -5528,7 +5547,8 @@ paths: - $ref: "#/components/parameters/WorkspaceId" - name: only_member_of in: query - description: only list the folders the user is member of (default false) + description: + only list the folders the user is member of (default false) schema: type: boolean responses: @@ -6246,7 +6266,8 @@ components: type: integer PerPage: name: per_page - description: number of items to return for a given page (default 30, max 100) + description: + number of items to return for a given page (default 30, max 100) in: query schema: type: integer @@ -6380,7 +6401,8 @@ components: type: boolean ArgsFilter: name: args - description: filter on jobs containing those args as a json subset (@> in postgres) + description: + filter on jobs containing those args as a json subset (@> in postgres) in: query schema: type: string @@ -6392,7 +6414,8 @@ components: type: string ResultFilter: name: result - description: filter on jobs containing those result as a json subset (@> in postgres) + description: + filter on jobs containing those result as a json subset (@> in postgres) in: query schema: type: string @@ -7760,6 +7783,8 @@ components: type: string worker_group: type: string + wm_version: + type: string required: - worker - worker_instance @@ -7768,7 +7793,7 @@ components: - ip - jobs_executed - worker_group - + - wm_version UserWorkspaceList: type: object properties: diff --git a/backend/windmill-api/src/workers.rs b/backend/windmill-api/src/workers.rs index 7385bb33df9ab..4e6828e580033 100644 --- a/backend/windmill-api/src/workers.rs +++ b/backend/windmill-api/src/workers.rs @@ -39,6 +39,7 @@ struct WorkerPing { jobs_executed: i32, custom_tags: Option>, worker_group: String, + wm_version: String, } #[derive(Serialize, Deserialize)] @@ -57,7 +58,7 @@ async fn list_worker_pings( let rows = sqlx::query_as!( WorkerPing, - "SELECT worker, worker_instance, EXTRACT(EPOCH FROM (now() - ping_at))::integer as last_ping, started_at, ip, jobs_executed, custom_tags, worker_group FROM worker_ping ORDER BY ping_at desc LIMIT $1 OFFSET $2", + "SELECT worker, worker_instance, EXTRACT(EPOCH FROM (now() - ping_at))::integer as last_ping, started_at, ip, jobs_executed, custom_tags, worker_group, wm_version FROM worker_ping ORDER BY ping_at desc LIMIT $1 OFFSET $2", per_page as i64, offset as i64 ) diff --git a/backend/windmill-common/src/worker.rs b/backend/windmill-common/src/worker.rs index 5864edcb2acb4..f8faba8a547cc 100644 --- a/backend/windmill-common/src/worker.rs +++ b/backend/windmill-common/src/worker.rs @@ -135,13 +135,14 @@ pub async fn update_ping(worker_instance: &str, worker_name: &str, ip: &str, db: ) }; sqlx::query!( - "INSERT INTO worker_ping (worker_instance, worker, ip, custom_tags, worker_group, dedicated_worker) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (worker) DO UPDATE set ip = $3, custom_tags = $4, worker_group = $5", + "INSERT INTO worker_ping (worker_instance, worker, ip, custom_tags, worker_group, dedicated_worker, wm_version) VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (worker) DO UPDATE set ip = $3, custom_tags = $4, worker_group = $5", worker_instance, worker_name, ip, tags.as_slice(), *WORKER_GROUP, - dw + dw, + crate::utils::GIT_VERSION ) .execute(db) .await diff --git a/frontend/src/routes/(root)/(logged)/workers/+page.svelte b/frontend/src/routes/(root)/(logged)/workers/+page.svelte index 11e8f47b5abf3..c701df02342db 100644 --- a/frontend/src/routes/(root)/(logged)/workers/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/workers/+page.svelte @@ -313,6 +313,7 @@ Last ping Worker start Nb of jobs executed + Version Liveness @@ -321,7 +322,7 @@ @@ -334,7 +335,7 @@ {#if workers} - {#each workers as { worker, custom_tags, last_ping, started_at, jobs_executed }} + {#each workers as { worker, custom_tags, last_ping, started_at, jobs_executed, wm_version }} {worker} @@ -348,6 +349,11 @@ {last_ping != undefined ? last_ping + timeSinceLastPing : -1}s ago {displayDate(started_at)} {jobs_executed} +
{wm_version.split('-')[0]}{wm_version}