feat: Add stop_grace_period to swarm settings

This commit is contained in:
Lucas Manchine
2025-07-23 20:38:27 +00:00
committed by GitHub
parent b95dfed8fc
commit b4a5221caf
6 changed files with 6182 additions and 0 deletions
@@ -1,6 +1,7 @@
import { AlertBlock } from "@/components/shared/alert-block"; import { AlertBlock } from "@/components/shared/alert-block";
import { CodeEditor } from "@/components/shared/code-editor"; import { CodeEditor } from "@/components/shared/code-editor";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { import {
Dialog, Dialog,
DialogContent, DialogContent,
@@ -176,6 +177,7 @@ const addSwarmSettings = z.object({
modeSwarm: createStringToJSONSchema(ServiceModeSwarmSchema).nullable(), modeSwarm: createStringToJSONSchema(ServiceModeSwarmSchema).nullable(),
labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(), labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(),
networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(), networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(),
stopGracePeriodSwarm: z.string().nullable(),
}); });
type AddSwarmSettings = z.infer<typeof addSwarmSettings>; type AddSwarmSettings = z.infer<typeof addSwarmSettings>;
@@ -238,6 +240,7 @@ export const AddSwarmSettings = ({ applicationId }: Props) => {
networkSwarm: data.networkSwarm networkSwarm: data.networkSwarm
? JSON.stringify(data.networkSwarm, null, 2) ? JSON.stringify(data.networkSwarm, null, 2)
: null, : null,
stopGracePeriodSwarm: data.stopGracePeriodSwarm ?? null,
}); });
} }
}, [form, form.reset, data]); }, [form, form.reset, data]);
@@ -253,6 +256,7 @@ export const AddSwarmSettings = ({ applicationId }: Props) => {
modeSwarm: data.modeSwarm, modeSwarm: data.modeSwarm,
labelsSwarm: data.labelsSwarm, labelsSwarm: data.labelsSwarm,
networkSwarm: data.networkSwarm, networkSwarm: data.networkSwarm,
stopGracePeriodSwarm: data.stopGracePeriodSwarm ?? null,
}) })
.then(async () => { .then(async () => {
toast.success("Swarm settings updated"); toast.success("Swarm settings updated");
@@ -752,6 +756,28 @@ export const AddSwarmSettings = ({ applicationId }: Props) => {
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={form.control}
name="stopGracePeriodSwarm"
render={({ field }) => (
<FormItem className="relative max-lg:px-4 lg:pr-6 ">
<FormLabel>Stop Grace Period</FormLabel>
<FormDescription>
Time to wait for the container to stop gracefully.
</FormDescription>
<FormControl>
<Input
placeholder="e.g, 30s"
{...field}
value={field?.value || ""}
/>
</FormControl>
<pre>
<FormMessage />
</pre>
</FormItem>
)}
/>
<DialogFooter className="flex w-full flex-row justify-end md:col-span-2 m-0 sticky bottom-0 right-0 bg-muted border"> <DialogFooter className="flex w-full flex-row justify-end md:col-span-2 m-0 sticky bottom-0 right-0 bg-muted border">
<Button <Button
@@ -0,0 +1 @@
ALTER TABLE "application" ADD COLUMN "stopGracePeriodSwarm" text;
File diff suppressed because it is too large Load Diff
+7
View File
@@ -729,6 +729,13 @@
"when": 1752465764072, "when": 1752465764072,
"tag": "0103_cultured_pestilence", "tag": "0103_cultured_pestilence",
"breakpoints": true "breakpoints": true
},
{
"idx": 104,
"version": "7",
"when": 1753302204161,
"tag": "0104_free_thunderbolt",
"breakpoints": true
} }
] ]
} }
@@ -202,6 +202,7 @@ export const applications = pgTable("application", {
modeSwarm: json("modeSwarm").$type<ServiceModeSwarm>(), modeSwarm: json("modeSwarm").$type<ServiceModeSwarm>(),
labelsSwarm: json("labelsSwarm").$type<LabelsSwarm>(), labelsSwarm: json("labelsSwarm").$type<LabelsSwarm>(),
networkSwarm: json("networkSwarm").$type<NetworkSwarm[]>(), networkSwarm: json("networkSwarm").$type<NetworkSwarm[]>(),
stopGracePeriodSwarm: text("stopGracePeriodSwarm"),
// //
replicas: integer("replicas").default(1).notNull(), replicas: integer("replicas").default(1).notNull(),
applicationStatus: applicationStatus("applicationStatus") applicationStatus: applicationStatus("applicationStatus")
@@ -435,6 +436,7 @@ const createSchema = createInsertSchema(applications, {
previewRequireCollaboratorPermissions: z.boolean().optional(), previewRequireCollaboratorPermissions: z.boolean().optional(),
watchPaths: z.array(z.string()).optional(), watchPaths: z.array(z.string()).optional(),
cleanCache: z.boolean().optional(), cleanCache: z.boolean().optional(),
stopGracePeriodSwarm: z.string().nullable(),
}); });
export const apiCreateApplication = createSchema.pick({ export const apiCreateApplication = createSchema.pick({
@@ -360,6 +360,7 @@ export const generateConfigContainer = (application: ApplicationNested) => {
replicas, replicas,
mounts, mounts,
networkSwarm, networkSwarm,
stopGracePeriodSwarm,
} = application; } = application;
const haveMounts = mounts.length > 0; const haveMounts = mounts.length > 0;
@@ -410,6 +411,9 @@ export const generateConfigContainer = (application: ApplicationNested) => {
Order: "start-first", Order: "start-first",
}, },
}), }),
...(stopGracePeriodSwarm && {
StopGracePeriod: parseInt(stopGracePeriodSwarm, 10),
}),
...(networkSwarm ...(networkSwarm
? { ? {
Networks: networkSwarm, Networks: networkSwarm,