testing changes

This commit is contained in:
Lucas Manchine
2025-08-06 14:55:30 -03:00
parent 825a1fc495
commit 8ea64f9de1
6 changed files with 36 additions and 15 deletions
@@ -177,7 +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(), stopGracePeriodSwarm: z.bigint().nullable(),
}); });
type AddSwarmSettings = z.infer<typeof addSwarmSettings>; type AddSwarmSettings = z.infer<typeof addSwarmSettings>;
@@ -226,6 +226,7 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
modeSwarm: null, modeSwarm: null,
labelsSwarm: null, labelsSwarm: null,
networkSwarm: null, networkSwarm: null,
stopGracePeriodSwarm: null,
}, },
resolver: zodResolver(addSwarmSettings), resolver: zodResolver(addSwarmSettings),
}); });
@@ -257,7 +258,12 @@ export const AddSwarmSettings = ({ id, type }: 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, stopGracePeriodSwarm:
// type === "application" &&
// "stopGracePeriodSwarm" in data &&
data.stopGracePeriodSwarm
? BigInt(data.stopGracePeriodSwarm)
: null,
}); });
} }
}, [form, form.reset, data]); }, [form, form.reset, data]);
@@ -783,12 +789,12 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
name="stopGracePeriodSwarm" name="stopGracePeriodSwarm"
render={({ field }) => ( render={({ field }) => (
<FormItem className="relative max-lg:px-4 lg:pl-6 "> <FormItem className="relative max-lg:px-4 lg:pl-6 ">
<FormLabel>Stop Grace Period</FormLabel> <FormLabel>Stop Grace Period (nanoseconds)</FormLabel>
<TooltipProvider delayDuration={0}> <TooltipProvider delayDuration={0}>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<FormDescription className="break-all w-fit flex flex-row gap-1 items-center"> <FormDescription className="break-all w-fit flex flex-row gap-1 items-center">
Check the format Duration in nanoseconds
<HelpCircle className="size-4 text-muted-foreground" /> <HelpCircle className="size-4 text-muted-foreground" />
</FormDescription> </FormDescription>
</TooltipTrigger> </TooltipTrigger>
@@ -799,11 +805,11 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
> >
<code> <code>
<pre> <pre>
{`Duration string format: {`Enter duration in nanoseconds:
• "30s" - 30 seconds • 30000000000 - 30 seconds
• "2m" - 2 minutes • 120000000000 - 2 minutes
• "1h" - 1 hour • 3600000000000 - 1 hour
• "0" - no grace period`} • 0 - no grace period`}
</pre> </pre>
</code> </code>
</TooltipContent> </TooltipContent>
@@ -811,10 +817,16 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
</TooltipProvider> </TooltipProvider>
<FormControl> <FormControl>
<Input <Input
placeholder="30s" type="number"
placeholder="30000000000"
className="font-mono" className="font-mono"
{...field} {...field}
value={field?.value || ""} value={field?.value?.toString() || ""}
onChange={(e) =>
field.onChange(
e.target.value ? BigInt(e.target.value) : null,
)
}
/> />
</FormControl> </FormControl>
<pre> <pre>
@@ -1 +0,0 @@
ALTER TABLE "application" ADD COLUMN "stopGracePeriodSwarm" text;
+7
View File
@@ -743,6 +743,13 @@
"when": 1754259281559, "when": 1754259281559,
"tag": "0105_clumsy_quicksilver", "tag": "0105_clumsy_quicksilver",
"breakpoints": true "breakpoints": true
},
{
"idx": 106,
"version": "7",
"when": 1754487585323,
"tag": "0106_wakeful_gressill",
"breakpoints": true
} }
] ]
} }
+3 -2
View File
@@ -1,5 +1,6 @@
import { relations } from "drizzle-orm"; import { relations } from "drizzle-orm";
import { import {
bigint,
boolean, boolean,
integer, integer,
json, json,
@@ -162,7 +163,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"), stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }),
// //
replicas: integer("replicas").default(1).notNull(), replicas: integer("replicas").default(1).notNull(),
applicationStatus: applicationStatus("applicationStatus") applicationStatus: applicationStatus("applicationStatus")
@@ -310,7 +311,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(), stopGracePeriodSwarm: z.bigint().nullable(),
}); });
export const apiCreateApplication = createSchema.pick({ export const apiCreateApplication = createSchema.pick({
@@ -142,6 +142,7 @@ export const mechanizeDockerContainer = async (
RollbackConfig, RollbackConfig,
UpdateConfig, UpdateConfig,
Networks, Networks,
StopGracePeriod,
} = generateConfigContainer(application); } = generateConfigContainer(application);
const bindsMount = generateBindMounts(mounts); const bindsMount = generateBindMounts(mounts);
@@ -190,6 +191,7 @@ export const mechanizeDockerContainer = async (
})), })),
}, },
UpdateConfig, UpdateConfig,
...(StopGracePeriod && { StopGracePeriod }),
}; };
try { try {
+1 -1
View File
@@ -414,7 +414,7 @@ export const generateConfigContainer = (
}, },
}), }),
...(stopGracePeriodSwarm && { ...(stopGracePeriodSwarm && {
StopGracePeriod: parseInt(stopGracePeriodSwarm, 10), StopGracePeriod: stopGracePeriodSwarm,
}), }),
...(networkSwarm ...(networkSwarm
? { ? {