Skip to content

Commit ea6f66b

Browse files
authored
Improved schedule engine (#2174)
1 parent a42c9ac commit ea6f66b

File tree

59 files changed

+2097
-1165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2097
-1165
lines changed

apps/webapp/app/components/runs/v3/RetryDeploymentIndexingDialog.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

apps/webapp/app/env.server.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,46 @@ const EnvironmentSchema = z.object({
692692
COMMON_WORKER_REDIS_TLS_DISABLED: z.string().default(process.env.REDIS_TLS_DISABLED ?? "false"),
693693
COMMON_WORKER_REDIS_CLUSTER_MODE_ENABLED: z.string().default("0"),
694694

695+
SCHEDULE_ENGINE_LOG_LEVEL: z.enum(["log", "error", "warn", "info", "debug"]).default("info"),
696+
SCHEDULE_WORKER_ENABLED: z.string().default(process.env.WORKER_ENABLED ?? "true"),
697+
SCHEDULE_WORKER_CONCURRENCY_WORKERS: z.coerce.number().int().default(1),
698+
SCHEDULE_WORKER_CONCURRENCY_TASKS_PER_WORKER: z.coerce.number().int().default(1),
699+
SCHEDULE_WORKER_POLL_INTERVAL: z.coerce.number().int().default(1000),
700+
SCHEDULE_WORKER_IMMEDIATE_POLL_INTERVAL: z.coerce.number().int().default(50),
701+
SCHEDULE_WORKER_CONCURRENCY_LIMIT: z.coerce.number().int().default(50),
702+
SCHEDULE_WORKER_SHUTDOWN_TIMEOUT_MS: z.coerce.number().int().default(30_000),
703+
SCHEDULE_WORKER_DISTRIBUTION_WINDOW_SECONDS: z.coerce.number().int().default(30),
704+
705+
SCHEDULE_WORKER_REDIS_HOST: z
706+
.string()
707+
.optional()
708+
.transform((v) => v ?? process.env.REDIS_HOST),
709+
SCHEDULE_WORKER_REDIS_READER_HOST: z
710+
.string()
711+
.optional()
712+
.transform((v) => v ?? process.env.REDIS_READER_HOST),
713+
SCHEDULE_WORKER_REDIS_READER_PORT: z.coerce
714+
.number()
715+
.optional()
716+
.transform(
717+
(v) =>
718+
v ?? (process.env.REDIS_READER_PORT ? parseInt(process.env.REDIS_READER_PORT) : undefined)
719+
),
720+
SCHEDULE_WORKER_REDIS_PORT: z.coerce
721+
.number()
722+
.optional()
723+
.transform((v) => v ?? (process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT) : undefined)),
724+
SCHEDULE_WORKER_REDIS_USERNAME: z
725+
.string()
726+
.optional()
727+
.transform((v) => v ?? process.env.REDIS_USERNAME),
728+
SCHEDULE_WORKER_REDIS_PASSWORD: z
729+
.string()
730+
.optional()
731+
.transform((v) => v ?? process.env.REDIS_PASSWORD),
732+
SCHEDULE_WORKER_REDIS_TLS_DISABLED: z.string().default(process.env.REDIS_TLS_DISABLED ?? "false"),
733+
SCHEDULE_WORKER_REDIS_CLUSTER_MODE_ENABLED: z.string().default("0"),
734+
695735
TASK_EVENT_PARTITIONING_ENABLED: z.string().default("0"),
696736
TASK_EVENT_PARTITIONED_WINDOW_IN_SECONDS: z.coerce.number().int().default(60), // 1 minute
697737

apps/webapp/app/presenters/v3/NextRunListPresenter.server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ export class NextRunListPresenter {
190190
prisma: this.replica as PrismaClient,
191191
});
192192

193+
function clampToNow(date: Date): Date {
194+
const now = new Date();
195+
return date > now ? now : date;
196+
}
197+
193198
const { runs, pagination } = await runsRepository.listRuns({
194199
organizationId,
195200
environmentId,
@@ -200,8 +205,8 @@ export class NextRunListPresenter {
200205
tags,
201206
scheduleId,
202207
period: periodMs ?? undefined,
203-
from,
204-
to,
208+
from: time.from ? time.from.getTime() : undefined,
209+
to: time.to ? clampToNow(time.to).getTime() : undefined,
205210
isTest,
206211
rootOnly,
207212
batchId,

apps/webapp/app/presenters/v3/RunListPresenter.server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ export class RunListPresenter extends BasePresenter {
179179

180180
const periodMs = time.period ? parse(time.period) : undefined;
181181

182+
function clampToNow(date: Date): Date {
183+
const now = new Date();
184+
185+
return date > now ? now : date;
186+
}
187+
182188
//get the runs
183189
const runs = await this._replica.$queryRaw<
184190
{
@@ -282,7 +288,9 @@ WHERE
282288
: Prisma.empty
283289
}
284290
${
285-
time.to ? Prisma.sql`AND tr."createdAt" <= ${time.to.toISOString()}::timestamp` : Prisma.empty
291+
time.to
292+
? Prisma.sql`AND tr."createdAt" <= ${clampToNow(time.to).toISOString()}::timestamp`
293+
: Prisma.sql`AND tr."createdAt" <= CURRENT_TIMESTAMP`
286294
}
287295
${
288296
tags && tags.length > 0

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.deployments/route.tsx

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { ArrowPathIcon, ArrowUturnLeftIcon, BookOpenIcon } from "@heroicons/react/20/solid";
2-
import { type MetaFunction, Outlet, useLocation, useParams, useNavigate } from "@remix-run/react";
1+
import { ArrowUturnLeftIcon, BookOpenIcon } from "@heroicons/react/20/solid";
2+
import { type MetaFunction, Outlet, useLocation, useNavigate, useParams } from "@remix-run/react";
33
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
4+
import { useEffect } from "react";
45
import { typedjson, useTypedLoaderData } from "remix-typedjson";
56
import { z } from "zod";
67
import { PromoteIcon } from "~/assets/icons/PromoteIcon";
78
import { DeploymentsNone, DeploymentsNoneDev } from "~/components/BlankStatePanels";
9+
import { GitMetadata } from "~/components/GitMetadata";
810
import { UserAvatar } from "~/components/UserProfilePhoto";
911
import { MainCenteredContainer, PageBody, PageContainer } from "~/components/layout/AppLayout";
1012
import { Badge } from "~/components/primitives/Badge";
@@ -34,7 +36,6 @@ import {
3436
deploymentStatusDescription,
3537
deploymentStatuses,
3638
} from "~/components/runs/v3/DeploymentStatus";
37-
import { RetryDeploymentIndexingDialog } from "~/components/runs/v3/RetryDeploymentIndexingDialog";
3839
import {
3940
PromoteDeploymentDialog,
4041
RollbackDeploymentDialog,
@@ -52,8 +53,6 @@ import { EnvironmentParamSchema, docsPath, v3DeploymentPath } from "~/utils/path
5253
import { createSearchParams } from "~/utils/searchParams";
5354
import { deploymentIndexingIsRetryable } from "~/v3/deploymentStatus";
5455
import { compareDeploymentVersions } from "~/v3/utils/deploymentVersions";
55-
import { useEffect } from "react";
56-
import { GitMetadata } from "~/components/GitMetadata";
5756

5857
export const meta: MetaFunction = () => {
5958
return [
@@ -388,26 +387,6 @@ function DeploymentActionsCell({
388387
/>
389388
</Dialog>
390389
)}
391-
{canRetryIndexing && (
392-
<Dialog>
393-
<DialogTrigger asChild>
394-
<Button
395-
variant="small-menu-item"
396-
LeadingIcon={ArrowPathIcon}
397-
leadingIconClassName="text-blue-500"
398-
fullWidth
399-
textAlignLeft
400-
>
401-
Retry indexing…
402-
</Button>
403-
</DialogTrigger>
404-
<RetryDeploymentIndexingDialog
405-
projectId={project.id}
406-
deploymentShortCode={deployment.shortCode}
407-
redirectPath={`${location.pathname}${location.search}`}
408-
/>
409-
</Dialog>
410-
)}
411390
</>
412391
}
413392
/>

apps/webapp/app/routes/resources.$projectId.deployments.$deploymentShortCode.retry-indexing.ts

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)