fix: register cloud schedules without a timezone (#5139)

This commit is contained in:
Mauricio Siu
2026-10-22 12:12:37 -06:00
parent 9c06e34bec
commit e59ba0636b
4 changed files with 22 additions and 49 deletions
+1 -1
View File
@@ -267,7 +267,7 @@ export const backupRouter = createTRPCRouter({
const value = await removeBackupById(input.backupId);
if (IS_CLOUD && value) {
removeJob({
await removeJob({
backupId: input.backupId,
cronSchedule: value.schedule,
type: "backup",
+1 -1
View File
@@ -66,7 +66,7 @@ export const scheduleRouter = createTRPCRouter({
if (newSchedule?.enabled) {
if (IS_CLOUD) {
schedule({
await schedule({
scheduleId: newSchedule.scheduleId,
type: "schedule",
cronSchedule: newSchedule.cronExpression,
+19 -46
View File
@@ -26,56 +26,29 @@ type QueueJob =
cronSchedule: string;
volumeBackupId: string;
};
export const schedule = async (job: QueueJob) => {
try {
const result = await fetch(`${process.env.JOBS_URL}/create-backup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});
const data = await result.json();
return data;
} catch (error) {
throw error;
const postJob = async (path: string, job: QueueJob) => {
const result = await fetch(`${process.env.JOBS_URL}${path}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});
const data = await result.json();
if (!result.ok) {
throw new Error(
`Jobs service ${path} failed (${result.status}): ${JSON.stringify(data)}`,
);
}
return data;
};
export const removeJob = async (job: QueueJob) => {
try {
const result = await fetch(`${process.env.JOBS_URL}/remove-job`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});
const data = await result.json();
return data;
} catch (error) {
throw error;
}
};
export const schedule = (job: QueueJob) => postJob("/create-backup", job);
export const updateJob = async (job: QueueJob) => {
try {
const result = await fetch(`${process.env.JOBS_URL}/update-backup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});
const data = await result.json();
return data;
} catch (error) {
throw error;
}
};
export const removeJob = (job: QueueJob) => postJob("/remove-job", job);
export const updateJob = (job: QueueJob) => postJob("/update-backup", job);
export const cancelJobs = async (backups: BackupScheduleList) => {
for (const backup of backups) {
+1 -1
View File
@@ -15,7 +15,7 @@ export const jobQueueSchema = z.discriminatedUnion("type", [
cronSchedule: z.string(),
type: z.literal("schedule"),
scheduleId: z.string(),
timezone: z.string().optional(),
timezone: z.string().nullish(),
}),
z.object({
cronSchedule: z.string(),