|
1 | 1 | <script lang="ts">
|
2 | 2 | import { page } from '$app/state';
|
3 |
| - import { graphql, type WorkloadStatusErrorLevel$options } from '$houdini'; |
| 3 | + import { graphql } from '$houdini'; |
4 | 4 | import AggregatedCostForWorkload from '$lib/components/AggregatedCostForWorkload.svelte';
|
| 5 | + import ErrorMessage from '$lib/components/ErrorMessage.svelte'; |
5 | 6 | import Image from '$lib/components/Image.svelte';
|
6 | 7 | import NetworkPolicy from '$lib/components/NetworkPolicy.svelte';
|
7 | 8 | import Persistence from '$lib/components/persistence/Persistence.svelte';
|
8 | 9 | import Secrets from '$lib/components/Secrets.svelte';
|
9 | 10 | import WorkloadDeploy from '$lib/components/WorkloadDeploy.svelte';
|
10 |
| - import { docURL } from '$lib/doc'; |
11 | 11 | import GraphErrors from '$lib/GraphErrors.svelte';
|
12 | 12 | import Time from '$lib/Time.svelte';
|
13 |
| - import { Alert, BodyLong, BodyShort, Button, Heading } from '@nais/ds-svelte-community'; |
| 13 | + import { Alert, Button, Heading } from '@nais/ds-svelte-community'; |
14 | 14 | import type { PageProps } from './$houdini';
|
15 | 15 | import Runs from './Runs.svelte';
|
16 | 16 | import Schedule from './Schedule.svelte';
|
|
60 | 60 | });
|
61 | 61 | };
|
62 | 62 |
|
63 |
| - const levelVariant = (level?: WorkloadStatusErrorLevel$options) => { |
64 |
| - switch (level) { |
65 |
| - case 'ERROR': |
66 |
| - return 'error'; |
67 |
| - case 'WARNING': |
68 |
| - return 'warning'; |
69 |
| - case 'TODO': |
70 |
| - default: |
71 |
| - return 'info'; |
72 |
| - } |
| 63 | + const getError = (type: string) => { |
| 64 | + const error = $Job.data?.team.environment.job.status.errors.find( |
| 65 | + (error) => error.__typename === type |
| 66 | + ); |
| 67 | + return error ? { ...error, workloadType: 'Job' as const } : undefined; |
73 | 68 | };
|
74 | 69 | </script>
|
75 | 70 |
|
|
79 | 74 | {@const job = $Job.data.team.environment.job}
|
80 | 75 | <div class="job-content">
|
81 | 76 | <div style="display:flex; flex-direction: column; gap: 1rem;">
|
82 |
| - {#if job.status.errors.some((error) => error.__typename === 'WorkloadStatusFailedRun')} |
83 |
| - <Alert |
84 |
| - variant={levelVariant( |
85 |
| - job.status.errors.find((error) => error.__typename === 'WorkloadStatusFailedRun')?.level |
86 |
| - )} |
87 |
| - > |
88 |
| - <div style="display: grid; gap: var(--a-spacing-3);"> |
89 |
| - <Heading level="2" size="small">Job Failed</Heading> |
90 |
| - <BodyLong>The last run of this job failed.</BodyLong> |
91 |
| - <div> |
92 |
| - <code> |
93 |
| - {job.status.errors.find((error) => error.__typename === 'WorkloadStatusFailedRun') |
94 |
| - ?.name} |
95 |
| - </code>: |
96 |
| - {job.status.errors.find((error) => error.__typename === 'WorkloadStatusFailedRun') |
97 |
| - ?.detail} |
98 |
| - </div> |
99 |
| - <BodyLong> |
100 |
| - Check logs if available. If you're unable to resolve the issue, contact the Nais team. |
101 |
| - </BodyLong> |
102 |
| - </div> |
103 |
| - </Alert> |
104 |
| - {/if} |
105 |
| - |
106 |
| - {#if job.status.errors.some((error) => error.__typename === 'WorkloadStatusInvalidNaisYaml')} |
107 |
| - <Alert |
108 |
| - variant={levelVariant( |
109 |
| - job.status.errors.find((error) => error.__typename === 'WorkloadStatusInvalidNaisYaml') |
110 |
| - ?.level |
111 |
| - )} |
112 |
| - > |
113 |
| - <div style="display: grid; gap: var(--a-spacing-3);"> |
114 |
| - <Heading level="2" size="small">Rollout Failed - Invalid Manifest</Heading> |
115 |
| - <BodyLong> |
116 |
| - The rollout of your job has failed due to an error in the job manifest. |
117 |
| - </BodyLong> |
118 |
| - |
119 |
| - <Heading level="3" size="xsmall">Error details</Heading> |
120 |
| - |
121 |
| - <code style="font-size: 0.8rem; line-height: 1.75;" |
122 |
| - >{job.status.errors.find( |
123 |
| - (error) => error.__typename === 'WorkloadStatusInvalidNaisYaml' |
124 |
| - )?.detail}</code |
125 |
| - > |
126 |
| - |
127 |
| - <BodyLong> |
128 |
| - To resolve this issue, review the job manifest and correct any errors. Consult the <a |
129 |
| - target="_blank" |
130 |
| - rel="noopener noreferrer" |
131 |
| - href={docURL('/workloads/job/reference/naisjob-spec/')}>Nais job reference</a |
132 |
| - > for manifest requirements. |
133 |
| - </BodyLong> |
134 |
| - </div> |
135 |
| - </Alert> |
136 |
| - {/if} |
137 |
| - {#if job.status.errors.some((error) => error.__typename === 'WorkloadStatusSynchronizationFailing')} |
138 |
| - <Alert |
139 |
| - variant={levelVariant( |
140 |
| - job.status.errors.find( |
141 |
| - (error) => error.__typename === 'WorkloadStatusSynchronizationFailing' |
142 |
| - )?.level |
143 |
| - )} |
144 |
| - > |
145 |
| - <Heading level="2" size="small" spacing>Rollout Failed - Synchronization Error</Heading> |
146 |
| - <BodyLong spacing> |
147 |
| - The rollout of the job is failing, meaning it is not in sync with the latest deployment. |
148 |
| - This may be due to a misconfiguration or a temporary issue, so try again in a few |
149 |
| - minutes. If the problem persists, contact the Nais team. |
150 |
| - </BodyLong> |
151 |
| - |
152 |
| - <Heading level="3" size="xsmall" spacing>Error details</Heading> |
153 |
| - |
154 |
| - <code style="font-size: 0.8rem; line-height: 1;" |
155 |
| - >{job.status.errors.find( |
156 |
| - (error) => error.__typename === 'WorkloadStatusSynchronizationFailing' |
157 |
| - )?.detail}</code |
158 |
| - > |
159 |
| - </Alert> |
160 |
| - {/if} |
161 |
| - {#if job.status.errors.some((error) => error.__typename === 'WorkloadStatusDeprecatedRegistry')} |
162 |
| - <Alert |
163 |
| - variant={levelVariant( |
164 |
| - job.status.errors.find( |
165 |
| - (error) => error.__typename === 'WorkloadStatusDeprecatedRegistry' |
166 |
| - )?.level |
167 |
| - )} |
168 |
| - > |
169 |
| - <BodyShort spacing |
170 |
| - >This job is using a deprecated image registry ({job.status.errors.find( |
171 |
| - (error) => error.__typename === 'WorkloadStatusDeprecatedRegistry' |
172 |
| - )?.registry}).</BodyShort |
173 |
| - > |
174 |
| - |
175 |
| - <BodyLong |
176 |
| - >Starting April 1st, applications and jobs on Nais must use images from Google Artifact |
177 |
| - Registry (GAR). The easiest way to ensure that images are stored in GAR is to use Nais' |
178 |
| - GitHub Actions in the workflow. <a |
179 |
| - href="https://nais.io/log/#2025-02-24-image-policy" |
180 |
| - target="_blank" |
181 |
| - rel="noopener noreferrer">Read more in Nais announcement</a |
182 |
| - >. |
183 |
| - </BodyLong> |
184 |
| - </Alert> |
185 |
| - {/if} |
| 77 | + {#each ['WorkloadStatusInvalidNaisYaml', 'WorkloadStatusSynchronizationFailing', 'WorkloadStatusFailedRun', 'WorkloadStatusDeprecatedRegistry'].map(getError) as error} |
| 78 | + {#if error} |
| 79 | + <ErrorMessage {error} /> |
| 80 | + {/if} |
| 81 | + {/each} |
186 | 82 |
|
187 | 83 | {#if job.deletionStartedAt}
|
188 | 84 | <Alert variant="info" size="small" fullWidth={false}>
|
|
0 commit comments