mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-13 00:03:00 +00:00
fix: add tag_override for script in flows
This commit is contained in:
@@ -1438,7 +1438,7 @@ pub async fn run_worker<R: rsmq_async::RsmqConnection + Send + Sync + Clone + 's
|
||||
}
|
||||
} else if let Ok(_) = killpill_rx.try_recv() {
|
||||
if !killed_but_draining_same_worker_jobs {
|
||||
tracing::info!("received killpill for worker {}, processing only same worker jobs", i_worker);
|
||||
tracing::info!("received killpill for worker {}, jobs are not pulled anymore except same_worker jobs", i_worker);
|
||||
killed_but_draining_same_worker_jobs = true;
|
||||
job_completed_tx.0.send(SendResult::Kill).await.expect("send kill to job completed tx");
|
||||
}
|
||||
|
||||
@@ -3557,7 +3557,14 @@ async fn script_to_payload(
|
||||
tag_override: &Option<String>,
|
||||
) -> Result<JobPayloadWithTag, Error> {
|
||||
let (payload, tag, delete_after_use, script_timeout) = if script_hash.is_none() {
|
||||
script_path_to_payload(script_path, db, &flow_job.workspace_id).await?
|
||||
let (jp, tag, delete_after_use, script_timeout) =
|
||||
script_path_to_payload(script_path, db, &flow_job.workspace_id).await?;
|
||||
(
|
||||
jp,
|
||||
tag_override.to_owned().or(tag),
|
||||
delete_after_use,
|
||||
script_timeout,
|
||||
)
|
||||
} else {
|
||||
let hash = script_hash.clone().unwrap();
|
||||
let mut tx: sqlx::Transaction<'_, sqlx::Postgres> = db.begin().await?;
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
let logOffset = 0
|
||||
async function getLogs() {
|
||||
if (jobId) {
|
||||
console.log('getLogs')
|
||||
|
||||
const getUpdate = await JobService.getJobUpdates({
|
||||
workspace: workspaceId ?? $workspaceStore!,
|
||||
id: jobId,
|
||||
|
||||
@@ -91,6 +91,8 @@
|
||||
|
||||
export async function getLogs() {
|
||||
if (job) {
|
||||
console.log('getLogs')
|
||||
|
||||
const getUpdate = await JobService.getJobUpdates({
|
||||
workspace: workspace!,
|
||||
id: job.id,
|
||||
@@ -172,6 +174,8 @@
|
||||
try {
|
||||
if (job && `running` in job) {
|
||||
const offset = logOffset == 0 ? (job.logs?.length ? job.logs?.length + 1 : 0) : logOffset
|
||||
console.log('getLogs')
|
||||
|
||||
let previewJobUpdates = await JobService.getJobUpdates({
|
||||
workspace: workspace!,
|
||||
id,
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
class={classNames(
|
||||
'relative transform overflow-hidden rounded-lg bg-surface px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6',
|
||||
open
|
||||
? 'ease-out duration-300 opacity-80 translate-y-0 sm:scale-100'
|
||||
? 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100'
|
||||
: 'ease-in duration-200 opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import { WorkerService, type FlowModule } from '$lib/gen'
|
||||
import { type FlowModule } from '$lib/gen'
|
||||
import { createEventDispatcher, getContext } from 'svelte'
|
||||
import {
|
||||
Bed,
|
||||
@@ -17,25 +17,16 @@
|
||||
import Popover from '../../Popover.svelte'
|
||||
import type { FlowEditorContext } from '../types'
|
||||
import { sendUserToast } from '$lib/utils'
|
||||
import { workerTags } from '$lib/stores'
|
||||
import { getLatestHashForScript } from '$lib/scripts'
|
||||
import type { FlowBuilderWhitelabelCustomUi } from '$lib/components/custom_ui'
|
||||
import FlowModuleWorkerTagSelect from './FlowModuleWorkerTagSelect.svelte'
|
||||
|
||||
export let module: FlowModule
|
||||
const { scriptEditorDrawer, flowStore, selectedId } =
|
||||
getContext<FlowEditorContext>('FlowEditorContext')
|
||||
const { scriptEditorDrawer } = getContext<FlowEditorContext>('FlowEditorContext')
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
let customUi: undefined | FlowBuilderWhitelabelCustomUi = getContext('customUi')
|
||||
|
||||
loadWorkerGroups()
|
||||
|
||||
async function loadWorkerGroups() {
|
||||
if (!$workerTags) {
|
||||
$workerTags = await WorkerService.getCustomTags()
|
||||
}
|
||||
}
|
||||
|
||||
$: moduleRetry = module.retry?.constant || module.retry?.exponential
|
||||
</script>
|
||||
|
||||
@@ -134,6 +125,7 @@
|
||||
Edit {#if module.value.hash != undefined} (locked hash){/if}
|
||||
</Button>
|
||||
{/if}
|
||||
<FlowModuleWorkerTagSelect bind:tag={module.value.tag_override} />
|
||||
{#if customUi?.scriptFork != false}
|
||||
<Button
|
||||
size="xs"
|
||||
@@ -148,42 +140,7 @@
|
||||
{/if}
|
||||
<div class="px-0.5" />
|
||||
{#if module.value.type === 'rawscript'}
|
||||
{#if $workerTags}
|
||||
{#if $workerTags?.length > 0}
|
||||
<div class="w-40">
|
||||
{#if $flowStore.tag == undefined}
|
||||
<select
|
||||
placeholder="Tag"
|
||||
bind:value={module.value.tag}
|
||||
on:change={(e) => {
|
||||
if (module.value.type === 'rawscript') {
|
||||
if (module.value.tag == '') {
|
||||
module.value.tag = undefined
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if module.value.tag}
|
||||
<option value="">reset to default</option>
|
||||
{:else}
|
||||
<option value="" disabled selected>Tag</option>
|
||||
{/if}
|
||||
{#each $workerTags ?? [] as tag (tag)}
|
||||
<option value={tag}>{tag}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<button
|
||||
title="Worker Group is defined at the flow level"
|
||||
class="w-full text-left items-center font-normal p-1 border text-xs rounded"
|
||||
on:click={() => ($selectedId = 'settings-worker-group')}
|
||||
>
|
||||
Flow's WG: {$flowStore.tag}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
<FlowModuleWorkerTagSelect bind:tag={module.value.tag} />
|
||||
<Button
|
||||
size="xs"
|
||||
color="light"
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte'
|
||||
import type { FlowEditorContext } from '../types'
|
||||
import { workerTags } from '$lib/stores'
|
||||
import { WorkerService } from '$lib/gen'
|
||||
|
||||
export let tag: string | undefined
|
||||
|
||||
const { flowStore, selectedId } = getContext<FlowEditorContext>('FlowEditorContext')
|
||||
|
||||
loadWorkerGroups()
|
||||
|
||||
async function loadWorkerGroups() {
|
||||
if (!$workerTags) {
|
||||
$workerTags = await WorkerService.getCustomTags()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $workerTags}
|
||||
{#if $workerTags?.length > 0}
|
||||
<div class="w-40">
|
||||
{#if $flowStore.tag == undefined}
|
||||
<select
|
||||
placeholder="Tag"
|
||||
bind:value={tag}
|
||||
on:change={(e) => {
|
||||
if (tag == '') {
|
||||
tag = undefined
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if tag}
|
||||
<option value="">reset to default</option>
|
||||
{:else}
|
||||
<option value="" disabled selected>Tag</option>
|
||||
{/if}
|
||||
{#each $workerTags ?? [] as tag (tag)}
|
||||
<option value={tag}>{tag}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<button
|
||||
title="Worker Group is defined at the flow level"
|
||||
class="w-full text-left items-center font-normal p-1 border text-xs rounded"
|
||||
on:click={() => ($selectedId = 'settings-worker-group')}
|
||||
>
|
||||
Flow's WG: {$flowStore.tag}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -281,6 +281,8 @@ components:
|
||||
type: string
|
||||
enum:
|
||||
- script
|
||||
tag_override:
|
||||
type: string
|
||||
required:
|
||||
- type
|
||||
- path
|
||||
|
||||
Reference in New Issue
Block a user