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

View File

@@ -177,7 +177,7 @@ const addSwarmSettings = z.object({
modeSwarm: createStringToJSONSchema(ServiceModeSwarmSchema).nullable(),
labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(),
networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(),
stopGracePeriodSwarm: z.string().nullable(),
stopGracePeriodSwarm: z.bigint().nullable(),
});
type AddSwarmSettings = z.infer<typeof addSwarmSettings>;
@@ -226,6 +226,7 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
modeSwarm: null,
labelsSwarm: null,
networkSwarm: null,
stopGracePeriodSwarm: null,
},
resolver: zodResolver(addSwarmSettings),
});
@@ -257,7 +258,12 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
networkSwarm: data.networkSwarm
? JSON.stringify(data.networkSwarm, null, 2)
: null,
stopGracePeriodSwarm: data.stopGracePeriodSwarm ?? null,
stopGracePeriodSwarm:
// type === "application" &&
// "stopGracePeriodSwarm" in data &&
data.stopGracePeriodSwarm
? BigInt(data.stopGracePeriodSwarm)
: null,
});
}
}, [form, form.reset, data]);
@@ -783,12 +789,12 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
name="stopGracePeriodSwarm"
render={({ field }) => (
<FormItem className="relative max-lg:px-4 lg:pl-6 ">
<FormLabel>Stop Grace Period</FormLabel>
<FormLabel>Stop Grace Period (nanoseconds)</FormLabel>
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger asChild>
<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" />
</FormDescription>
</TooltipTrigger>
@@ -799,11 +805,11 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
>
<code>
<pre>
{`Duration string format:
"30s" - 30 seconds
• "2m" - 2 minutes
• "1h" - 1 hour
• "0" - no grace period`}
{`Enter duration in nanoseconds:
• 30000000000 - 30 seconds
• 120000000000 - 2 minutes
• 3600000000000 - 1 hour
• 0 - no grace period`}
</pre>
</code>
</TooltipContent>
@@ -811,10 +817,16 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
</TooltipProvider>
<FormControl>
<Input
placeholder="30s"
type="number"
placeholder="30000000000"
className="font-mono"
{...field}
value={field?.value || ""}
value={field?.value?.toString() || ""}
onChange={(e) =>
field.onChange(
e.target.value ? BigInt(e.target.value) : null,
)
}
/>
</FormControl>
<pre>

View File

@@ -1 +0,0 @@
ALTER TABLE "application" ADD COLUMN "stopGracePeriodSwarm" text;

View File

@@ -743,6 +743,13 @@
"when": 1754259281559,
"tag": "0105_clumsy_quicksilver",
"breakpoints": true
},
{
"idx": 106,
"version": "7",
"when": 1754487585323,
"tag": "0106_wakeful_gressill",
"breakpoints": true
}
]
}

View File

@@ -1,5 +1,6 @@
import { relations } from "drizzle-orm";
import {
bigint,
boolean,
integer,
json,
@@ -162,7 +163,7 @@ export const applications = pgTable("application", {
modeSwarm: json("modeSwarm").$type<ServiceModeSwarm>(),
labelsSwarm: json("labelsSwarm").$type<LabelsSwarm>(),
networkSwarm: json("networkSwarm").$type<NetworkSwarm[]>(),
stopGracePeriodSwarm: text("stopGracePeriodSwarm"),
stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }),
//
replicas: integer("replicas").default(1).notNull(),
applicationStatus: applicationStatus("applicationStatus")
@@ -310,7 +311,7 @@ const createSchema = createInsertSchema(applications, {
previewRequireCollaboratorPermissions: z.boolean().optional(),
watchPaths: z.array(z.string()).optional(),
cleanCache: z.boolean().optional(),
stopGracePeriodSwarm: z.string().nullable(),
stopGracePeriodSwarm: z.bigint().nullable(),
});
export const apiCreateApplication = createSchema.pick({

View File

@@ -142,6 +142,7 @@ export const mechanizeDockerContainer = async (
RollbackConfig,
UpdateConfig,
Networks,
StopGracePeriod,
} = generateConfigContainer(application);
const bindsMount = generateBindMounts(mounts);
@@ -190,6 +191,7 @@ export const mechanizeDockerContainer = async (
})),
},
UpdateConfig,
...(StopGracePeriod && { StopGracePeriod }),
};
try {

View File

@@ -414,7 +414,7 @@ export const generateConfigContainer = (
},
}),
...(stopGracePeriodSwarm && {
StopGracePeriod: parseInt(stopGracePeriodSwarm, 10),
StopGracePeriod: stopGracePeriodSwarm,
}),
...(networkSwarm
? {