-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(deployments): show local build hint during depot outages #2646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
73c4b4e
Add an API endpoint to query remote build provider status
myftija 7cc05bc
Show local build hint for failed deployments when Depot is down
myftija ba6c809
Show the local build flag in the help output
myftija 28ab123
Add changeset
myftija 507bcb9
Fix import
myftija d69838e
Fix docs link
myftija File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "trigger.dev": patch | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| Added a hint about the `--force-local-build` flag on failed deployments due to upstream provider outages. |
94 changes: 94 additions & 0 deletions
94
apps/webapp/app/routes/api.v1.remote-build-provider-status.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { json } from "@remix-run/node"; | ||
| import { err, fromPromise, fromSafePromise, ok } from "neverthrow"; | ||
| import z from "zod"; | ||
| import { logger } from "~/services/logger.server"; | ||
| import { type RemoteBuildProviderStatusResponseBody } from "@trigger.dev/core/v3/schemas"; | ||
|
|
||
| const DEPOT_STATUS_URL = "https://status.depot.dev/proxy/status.depot.dev"; | ||
| const FETCH_TIMEOUT_MS = 2000; | ||
|
|
||
| export async function loader() { | ||
| return await fetchDepotStatus().match( | ||
| ({ summary: { ongoing_incidents } }) => { | ||
| if (ongoing_incidents.length > 0) { | ||
| return json( | ||
| { | ||
| status: "degraded", | ||
| message: | ||
| "Our remote build provider is currently facing issues. You can use the `--force-local-build` flag to build and deploy the image locally. Read more about local builds here: https://trigger.dev/docs/deployment/overview#local-builds", | ||
| } satisfies RemoteBuildProviderStatusResponseBody, | ||
| { status: 200 } | ||
| ); | ||
| } | ||
|
|
||
| return json( | ||
| { | ||
| status: "operational", | ||
| message: "Depot is operational", | ||
| } satisfies RemoteBuildProviderStatusResponseBody, | ||
| { status: 200 } | ||
| ); | ||
| }, | ||
| () => { | ||
| return json( | ||
| { | ||
| status: "unknown", | ||
| message: "Failed to fetch remote build provider status", | ||
| } satisfies RemoteBuildProviderStatusResponseBody, | ||
| { status: 200 } | ||
| ); | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| function fetchDepotStatus() { | ||
| return fromPromise( | ||
| fetch(DEPOT_STATUS_URL, { | ||
| signal: AbortSignal.timeout(FETCH_TIMEOUT_MS), | ||
| }), | ||
| (error) => { | ||
| if ( | ||
| error instanceof Error && | ||
| (error.name === "TimeoutError" || error.name === "AbortError") | ||
| ) { | ||
| return { | ||
| type: "timeout" as const, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| type: "other" as const, | ||
| cause: error, | ||
| }; | ||
| } | ||
| ) | ||
| .andThen((response) => { | ||
| if (!response.ok) { | ||
| return err({ | ||
| type: "other" as const, | ||
| cause: new Error(`Failed to fetch Depot status: ${response.status}`), | ||
| }); | ||
| } | ||
|
|
||
| return fromSafePromise(response.json()); | ||
| }) | ||
| .andThen((json) => { | ||
| const parsed = DepotStatusResponseSchema.safeParse(json); | ||
|
|
||
| if (!parsed.success) { | ||
| logger.warn("Invalid Depot status response", { error: parsed.error }); | ||
| return err({ | ||
| type: "validation_failed" as const, | ||
| }); | ||
| } | ||
|
|
||
| return ok(parsed.data); | ||
| }); | ||
| } | ||
|
|
||
| // partial schema | ||
| const DepotStatusResponseSchema = z.object({ | ||
| summary: z.object({ | ||
| ongoing_incidents: z.array(z.any()), | ||
| }), | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.