Skip to content

Commit 86c3173

Browse files
committed
feat: add synchronization failing error handling in app and job components
1 parent 2d39afe commit 86c3173

File tree

4 files changed

+69
-42
lines changed

4 files changed

+69
-42
lines changed

src/routes/team/[team]/[env]/app/[app]/+page.gql

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ query App($app: String!, $team: Slug!, $env: String!) {
4040
... on WorkloadStatusDeprecatedRegistry {
4141
registry
4242
}
43+
... on WorkloadStatusSynchronizationFailing {
44+
detail
45+
}
4346
}
4447
}
4548

src/routes/team/[team]/[env]/app/[app]/+page.svelte

+26-21
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import GraphErrors from '$lib/GraphErrors.svelte';
1313
import Time from '$lib/Time.svelte';
1414
import { Alert, BodyLong, BodyShort, Button, Heading } from '@nais/ds-svelte-community';
15-
import { ArrowCirclepathIcon, ExternalLinkIcon } from '@nais/ds-svelte-community/icons';
15+
import { ArrowCirclepathIcon } from '@nais/ds-svelte-community/icons';
1616
import type { PageData } from './$houdini';
1717
import Ingresses from './Ingresses.svelte';
1818
import Instances from './Instances.svelte';
@@ -56,11 +56,6 @@
5656
});
5757
};
5858
59-
let deployFailed = $derived(
60-
$App.data?.team.environment.application.deployments.nodes.at(0)?.statuses.nodes.at(0)?.state ===
61-
'FAILURE'
62-
);
63-
6459
const levelVariant = (level?: WorkloadStatusErrorLevel$options) => {
6560
switch (level) {
6661
case 'ERROR':
@@ -82,6 +77,30 @@
8277
<div class="wrapper">
8378
<div class="app-content">
8479
<div class="main-section">
80+
{#if app.status.errors.some((error) => error.__typename === 'WorkloadStatusSynchronizationFailing')}
81+
<Alert
82+
variant={levelVariant(
83+
app.status.errors.find(
84+
(error) => error.__typename === 'WorkloadStatusSynchronizationFailing'
85+
)?.level
86+
)}
87+
>
88+
<Heading level="2" size="small" spacing>Synchronization failing</Heading>
89+
<BodyLong spacing>
90+
The rollout of the application is failing, meaning it is not in sync with the latest
91+
deployment. This may be due to a misconfiguration or a temporary issue, so try again
92+
in a few minutes. If the problem persists, please contact the Nais team.
93+
</BodyLong>
94+
95+
<Heading level="3" size="xsmall" spacing>Error details</Heading>
96+
97+
<code style="font-size: 0.8rem; line-height: 1;"
98+
>{app.status.errors.find(
99+
(error) => error.__typename === 'WorkloadStatusSynchronizationFailing'
100+
)?.detail}</code
101+
>
102+
</Alert>
103+
{/if}
85104
{#if app.status.errors.some((error) => error.__typename === 'WorkloadStatusDeprecatedRegistry')}
86105
<Alert
87106
variant={levelVariant(
@@ -107,6 +126,7 @@
107126
</BodyLong>
108127
</Alert>
109128
{/if}
129+
110130
{#if app.deletionStartedAt}
111131
<Alert variant="info" size="small" fullWidth={false}>
112132
This application is being deleted. Deletion started <Time
@@ -115,21 +135,6 @@
115135
/>. If the deletion is taking too long, please contact the Nais team.
116136
</Alert>
117137
{/if}
118-
{#if deployFailed}
119-
<Alert variant="error" fullWidth={false}>
120-
<Heading level="2" size="small" spacing>Last deployment failed</Heading>
121-
<BodyShort spacing>
122-
<strong>Error message:</strong>
123-
{$App.data?.team.environment.application.deployments.nodes.at(0)?.statuses.nodes.at(0)
124-
?.message}
125-
</BodyShort>
126-
{#if $App.data?.team.environment.application.deployments.nodes.at(0)?.triggerUrl}
127-
<a href={$App.data?.team.environment.application.deployments.nodes.at(0)?.triggerUrl}
128-
>Github action <ExternalLinkIcon /></a
129-
>
130-
{/if}
131-
</Alert>
132-
{/if}
133138

134139
<div style="display:flex; flex-direction: column; gap: var(--a-spacing-4);">
135140
<div class="instances-header">

src/routes/team/[team]/[env]/job/[job]/+page.gql

+4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ query Job($job: String!, $team: Slug!, $env: String!) @cache(policy: NetworkOnly
2525
status {
2626
errors {
2727
__typename
28+
level
2829
... on WorkloadStatusDeprecatedRegistry {
2930
registry
3031
}
32+
... on WorkloadStatusSynchronizationFailing {
33+
detail
34+
}
3135
}
3236
}
3337

src/routes/team/[team]/[env]/job/[job]/+page.svelte

+36-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { page } from '$app/state';
3-
import { graphql } from '$houdini';
3+
import { graphql, type WorkloadStatusErrorLevel$options } from '$houdini';
44
import AggregatedCostForWorkload from '$lib/components/AggregatedCostForWorkload.svelte';
55
import Image from '$lib/components/Image.svelte';
66
import NetworkPolicy from '$lib/components/NetworkPolicy.svelte';
@@ -10,7 +10,6 @@
1010
import GraphErrors from '$lib/GraphErrors.svelte';
1111
import Time from '$lib/Time.svelte';
1212
import { Alert, BodyLong, BodyShort, Button, Heading } from '@nais/ds-svelte-community';
13-
import { ExternalLinkIcon } from '@nais/ds-svelte-community/icons';
1413
import type { PageData } from './$houdini';
1514
import Runs from './Runs.svelte';
1615
import Schedule from './Schedule.svelte';
@@ -64,10 +63,17 @@
6463
});
6564
};
6665
67-
let deployFailed = $derived(
68-
$Job.data?.team.environment.job.deployments.nodes.at(0)?.statuses.nodes.at(0)?.state ===
69-
'FAILURE'
70-
);
66+
const levelVariant = (level?: WorkloadStatusErrorLevel$options) => {
67+
switch (level) {
68+
case 'ERROR':
69+
return 'error';
70+
case 'WARNING':
71+
return 'warning';
72+
case 'TODO':
73+
default:
74+
return 'info';
75+
}
76+
};
7177
</script>
7278

7379
<GraphErrors errors={$Job.errors} />
@@ -76,6 +82,30 @@
7682
{@const job = $Job.data.team.environment.job}
7783
<div class="job-content">
7884
<div style="display:flex; flex-direction: column; gap: 1rem;">
85+
{#if job.status.errors.some((error) => error.__typename === 'WorkloadStatusSynchronizationFailing')}
86+
<Alert
87+
variant={levelVariant(
88+
job.status.errors.find(
89+
(error) => error.__typename === 'WorkloadStatusSynchronizationFailing'
90+
)?.level
91+
)}
92+
>
93+
<Heading level="2" size="small" spacing>Synchronization failing</Heading>
94+
<BodyLong spacing>
95+
The rollout of the job is failing, meaning it is not in sync with the latest deployment.
96+
This may be due to a misconfiguration or a temporary issue, so try again in a few
97+
minutes. If the problem persists, please contact the Nais team.
98+
</BodyLong>
99+
100+
<Heading level="3" size="xsmall" spacing>Error details</Heading>
101+
102+
<code style="font-size: 0.8rem; line-height: 1;"
103+
>{job.status.errors.find(
104+
(error) => error.__typename === 'WorkloadStatusSynchronizationFailing'
105+
)?.detail}</code
106+
>
107+
</Alert>
108+
{/if}
79109
{#if job.status.errors.some((error) => error.__typename === 'WorkloadStatusDeprecatedRegistry')}
80110
<Alert variant="error">
81111
<BodyShort spacing
@@ -105,21 +135,6 @@
105135
</Alert>
106136
{/if}
107137

108-
{#if deployFailed}
109-
<Alert variant="error" fullWidth={false}>
110-
<Heading level="2" size="small" spacing>Last deployment failed</Heading>
111-
<BodyShort spacing>
112-
<strong>Error message:</strong>
113-
{$Job.data?.team.environment.job.deployments.nodes.at(0)?.statuses.nodes.at(0)?.message}
114-
</BodyShort>
115-
{#if $Job.data?.team.environment.job.deployments.nodes[0].triggerUrl}
116-
<a href={$Job.data?.team.environment.job.deployments.nodes.at(0)?.triggerUrl}
117-
>Github action <ExternalLinkIcon /></a
118-
>
119-
{/if}
120-
</Alert>
121-
{/if}
122-
123138
<div style="display:flex; flex-direction: column; gap:0.5rem;">
124139
<div class="runs-header">
125140
<Heading level="2" size="medium">Runs</Heading>

0 commit comments

Comments
 (0)