mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 08:00:45 +00:00
native mode nits (#7981)
* native mode UI nits * accept flow jobs on native workers * limit native mode to non-dep jobs + flow tag infobox
This commit is contained in:
@@ -1083,6 +1083,10 @@ async fn create_script_internal<'c>(
|
||||
))
|
||||
} else if ns.tag.as_ref().is_some_and(|x| x.contains("$args[")) {
|
||||
None
|
||||
} else if lang == ScriptLang::Bunnative {
|
||||
// if a custom tag is set for a bunnative script, this prevents the custom tag to be used for the dependency job
|
||||
// forcing the bundling to run on a worker with the bun tag
|
||||
None
|
||||
} else {
|
||||
ns.tag
|
||||
};
|
||||
|
||||
@@ -3011,6 +3011,17 @@ pub async fn handle_queued_job(
|
||||
}
|
||||
|
||||
if NATIVE_MODE_RESOLVED.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
// Block all dependency jobs: native scripts don't have dependency jobs, and bunnative
|
||||
// dep jobs are routed to bun workers (lang=bun, tag=bun) even when they have a custom tag .
|
||||
if matches!(
|
||||
job.kind,
|
||||
JobKind::FlowDependencies | JobKind::AppDependencies | JobKind::Dependencies
|
||||
) || job.tag == "dependency"
|
||||
{
|
||||
return Err(Error::ExecutionErr(
|
||||
"Worker is in native mode and cannot execute dependency jobs".to_string(),
|
||||
));
|
||||
}
|
||||
if let Some(lang) = &job.script_lang {
|
||||
if !lang.is_native() {
|
||||
return Err(Error::ExecutionErr(format!(
|
||||
|
||||
@@ -290,8 +290,11 @@
|
||||
(workers.length > 0 &&
|
||||
workers.some(([_, pings]) => pings.some((p) => p.native_mode === true)))
|
||||
)
|
||||
let nonNativeTags = $derived((nconfig?.worker_tags ?? []).filter((t) => !nativeTags.includes(t)))
|
||||
let nonNativeTags = $derived(
|
||||
(nconfig?.worker_tags ?? []).filter((t) => !nativeTags.includes(t) && t !== 'flow')
|
||||
)
|
||||
let isAutoNativeMode = $derived(name === 'native')
|
||||
let isNativeModeEnabled = $derived(nconfig?.native_mode === true || isAutoNativeMode)
|
||||
$effect(() => {
|
||||
;($superadmin || $devopsRole) && listWorkspaces()
|
||||
})
|
||||
@@ -399,33 +402,53 @@
|
||||
<Label label="Tags to listen to">
|
||||
{#snippet action()}
|
||||
{#if nconfig?.worker_tags != undefined}
|
||||
{@const resetTags = isNativeModeEnabled ? nativeTags : defaultTags.concat(nativeTags)}
|
||||
{@const dropdownResetToAllTags = [
|
||||
{
|
||||
label: 'Reset to all tags minus native ones',
|
||||
label: isNativeModeEnabled
|
||||
? 'Reset to all tags'
|
||||
: 'Reset to all tags minus native ones',
|
||||
onClick: () => {
|
||||
if (nconfig != undefined) {
|
||||
nconfig.worker_tags = defaultTags
|
||||
nconfig.worker_tags = isNativeModeEnabled
|
||||
? defaultTagPerWorkspace && workspaceTag
|
||||
? defaultTags.concat(nativeTags).map((nt) => `${nt}-${workspaceTag}`)
|
||||
: defaultTags.concat(nativeTags)
|
||||
: defaultTagPerWorkspace && workspaceTag
|
||||
? defaultTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: defaultTags
|
||||
}
|
||||
},
|
||||
disabled: !canEditConfig,
|
||||
tooltip: (defaultTagPerWorkspace
|
||||
? defaultTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: defaultTags
|
||||
).join(', ')
|
||||
},
|
||||
{
|
||||
label: 'Reset to native tags',
|
||||
onClick: () => {
|
||||
if (nconfig != undefined) {
|
||||
nconfig.worker_tags = nativeTags
|
||||
}
|
||||
},
|
||||
disabled: !canEditConfig,
|
||||
tooltip: (defaultTagPerWorkspace && workspaceTag
|
||||
? nativeTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: nativeTags
|
||||
? (isNativeModeEnabled ? defaultTags.concat(nativeTags) : defaultTags).map(
|
||||
(nt) => `${nt}-${workspaceTag}`
|
||||
)
|
||||
: isNativeModeEnabled
|
||||
? defaultTags.concat(nativeTags)
|
||||
: defaultTags
|
||||
).join(', ')
|
||||
},
|
||||
...(!isNativeModeEnabled
|
||||
? [
|
||||
{
|
||||
label: 'Reset to native tags',
|
||||
onClick: () => {
|
||||
if (nconfig != undefined) {
|
||||
nconfig.worker_tags =
|
||||
defaultTagPerWorkspace && workspaceTag
|
||||
? nativeTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: nativeTags
|
||||
}
|
||||
},
|
||||
disabled: !canEditConfig,
|
||||
tooltip: (defaultTagPerWorkspace && workspaceTag
|
||||
? nativeTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: nativeTags
|
||||
).join(', ')
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Clear tags',
|
||||
onClick: () => {
|
||||
@@ -444,8 +467,8 @@
|
||||
if (nconfig != undefined) {
|
||||
nconfig.worker_tags =
|
||||
defaultTagPerWorkspace && workspaceTag
|
||||
? defaultTags.concat(nativeTags).map((nt) => `${nt}-${workspaceTag}`)
|
||||
: defaultTags.concat(nativeTags)
|
||||
? resetTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: resetTags
|
||||
}
|
||||
}}
|
||||
dropdownItems={dropdownResetToAllTags}
|
||||
@@ -453,11 +476,12 @@
|
||||
startIcon={{ icon: RotateCcw }}
|
||||
disabled={!canEditConfig}
|
||||
>
|
||||
Reset to all tags <Tooltip>
|
||||
{isNativeModeEnabled ? 'Reset to native tags' : 'Reset to all tags'}
|
||||
<Tooltip>
|
||||
{#snippet text()}
|
||||
{(defaultTagPerWorkspace && workspaceTag
|
||||
? defaultTags.concat(nativeTags).map((nt) => `${nt}-${workspaceTag}`)
|
||||
: defaultTags.concat(nativeTags)
|
||||
? resetTags.map((nt) => `${nt}-${workspaceTag}`)
|
||||
: resetTags
|
||||
).join(', ')}
|
||||
{/snippet}
|
||||
</Tooltip>
|
||||
@@ -511,6 +535,69 @@
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
{#if nconfig !== undefined}
|
||||
<div class="mt-8"></div>
|
||||
<Label label="Native mode">
|
||||
{#snippet header()}
|
||||
<Tooltip>
|
||||
{#snippet text()}
|
||||
When enabled, the worker will only accept native jobs (nativets, postgresql, mysql,
|
||||
etc.) and automatically runs with 8 subworkers for optimal throughput. Non-native
|
||||
jobs will be failed.
|
||||
{/snippet}
|
||||
</Tooltip>
|
||||
{/snippet}
|
||||
<Toggle
|
||||
size="sm"
|
||||
options={{
|
||||
right: isAutoNativeMode ? 'Native mode (automatically enabled)' : 'Enable native mode'
|
||||
}}
|
||||
checked={nconfig?.native_mode === true || isAutoNativeMode}
|
||||
on:change={(ev) => {
|
||||
if (nconfig !== undefined) {
|
||||
nconfig.native_mode = ev.detail ? true : undefined
|
||||
}
|
||||
}}
|
||||
disabled={!canEditConfig || isAutoNativeMode}
|
||||
/>
|
||||
{#if isNativeModeEnabled}
|
||||
<p class="text-xs text-secondary mt-1"
|
||||
>8 subworkers will automatically be used for optimal throughput.</p
|
||||
>
|
||||
{/if}
|
||||
{#if isNativeModeEnabled && nonNativeTags.length > 0}
|
||||
<Alert size="xs" type="warning" title="Non-native tags detected">
|
||||
This worker group has native mode enabled but includes non-native tags: {nonNativeTags.join(
|
||||
', '
|
||||
)}. Non-native jobs will be failed. This is fine if those custom tags are only used
|
||||
for native language jobs.
|
||||
</Alert>
|
||||
{/if}
|
||||
{#if isNativeModeEnabled && nconfig?.worker_tags != undefined && !nconfig.worker_tags.includes(defaultTagPerWorkspace && workspaceTag ? `flow-${workspaceTag}` : 'flow')}
|
||||
<Alert size="xs" type="info" title="Flow tag not included">
|
||||
Adding the flow tag to native workers can improve efficiency, but may cause issues
|
||||
with large inputs.
|
||||
<div class="mt-2 w-fit">
|
||||
<Button
|
||||
variant="default"
|
||||
on:click={() => {
|
||||
if (nconfig?.worker_tags != undefined) {
|
||||
const flowTag =
|
||||
defaultTagPerWorkspace && workspaceTag ? `flow-${workspaceTag}` : 'flow'
|
||||
nconfig.worker_tags = [...nconfig.worker_tags, flowTag]
|
||||
}
|
||||
}}
|
||||
disabled={!canEditConfig}
|
||||
startIcon={{ icon: Plus }}
|
||||
>
|
||||
Add flow tag
|
||||
</Button>
|
||||
</div>
|
||||
</Alert>
|
||||
{/if}
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
{#if nconfig !== undefined}
|
||||
<div class="mt-8"></div>
|
||||
<Label
|
||||
@@ -545,43 +632,6 @@
|
||||
{/if}
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
{#if nconfig !== undefined}
|
||||
<div class="mt-8"></div>
|
||||
<Label label="Native mode">
|
||||
{#snippet header()}
|
||||
<Tooltip>
|
||||
{#snippet text()}
|
||||
When enabled, the worker will only accept native jobs (nativets, postgresql, mysql,
|
||||
etc.) and automatically runs with NUM_WORKERS=8 for optimal throughput. Non-native
|
||||
jobs will be failed.
|
||||
{/snippet}
|
||||
</Tooltip>
|
||||
{/snippet}
|
||||
<Toggle
|
||||
size="sm"
|
||||
options={{
|
||||
right: isAutoNativeMode
|
||||
? 'Native mode (automatically enabled)'
|
||||
: 'Enable native mode'
|
||||
}}
|
||||
checked={nconfig?.native_mode === true || isAutoNativeMode}
|
||||
on:change={(ev) => {
|
||||
if (nconfig !== undefined) {
|
||||
nconfig.native_mode = ev.detail ? true : undefined
|
||||
}
|
||||
}}
|
||||
disabled={!canEditConfig || isAutoNativeMode}
|
||||
/>
|
||||
{#if (nconfig.native_mode || isAutoNativeMode) && nonNativeTags.length > 0}
|
||||
<Alert size="xs" type="warning" title="Non-native tags detected">
|
||||
This worker group has native mode enabled but includes non-native tags: {nonNativeTags.join(
|
||||
', '
|
||||
)}. Non-native jobs will be failed. This is fine if those custom tags are only used for native language jobs.
|
||||
</Alert>
|
||||
{/if}
|
||||
</Label>
|
||||
{/if}
|
||||
{:else if selected == 'dedicated'}
|
||||
<div class="flex flex-col gap-4">
|
||||
{#if $superadmin || $devopsRole}
|
||||
|
||||
@@ -1010,7 +1010,7 @@
|
||||
</Cell>
|
||||
</tr>
|
||||
{#if workers}
|
||||
{#each workers as { worker, custom_tags, last_ping, started_at, jobs_executed, last_job_id, last_job_workspace_id, occupancy_rate_15s, occupancy_rate_5m, occupancy_rate_30m, occupancy_rate, wm_version, vcpus, memory, memory_usage, wm_memory_usage }}
|
||||
{#each workers as { worker, custom_tags, last_ping, started_at, jobs_executed, last_job_id, last_job_workspace_id, occupancy_rate_15s, occupancy_rate_5m, occupancy_rate_30m, occupancy_rate, wm_version, vcpus, memory, memory_usage, wm_memory_usage, native_mode }}
|
||||
{@const isWorkerAlive = isWorkerMaybeAlive(last_ping)}
|
||||
{@const tagMismatchInfo = getTagMismatchInfo(
|
||||
custom_tags,
|
||||
@@ -1072,6 +1072,9 @@
|
||||
{/snippet}
|
||||
</MeltTooltip>
|
||||
{/if}
|
||||
{#if native_mode}
|
||||
<Badge color="blue" small>Native</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
</Cell>
|
||||
{#if !config || !config.worker_tags || config.worker_tags.length === 0}
|
||||
|
||||
Reference in New Issue
Block a user