Skip to content

Commit 7579cec

Browse files
committed
feat: enhance application error handling and alert messages for no running instances
1 parent 9f1c7ac commit 7579cec

File tree

6 files changed

+67
-6
lines changed

6 files changed

+67
-6
lines changed

src/routes/dataproduct/errors/+page.gql

+13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ query AllIngresses {
1616
}
1717
}
1818

19+
... on Application {
20+
instances {
21+
nodes {
22+
id
23+
name
24+
status {
25+
state
26+
message
27+
}
28+
}
29+
}
30+
}
31+
1932
status {
2033
errors {
2134
level

src/routes/dataproduct/errors/+page.svelte

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
null,
3333
2
3434
)}
35+
{#if workload.__typename === 'Application'}
36+
{#each workload.instances.nodes as instance (instance.id)}
37+
{#if instance.status.state !== 'RUNNING'}
38+
{JSON.stringify(instance.status, null, 2)}
39+
{/if}
40+
{/each}
41+
{/if}
3542
</div>
3643
{/each}
3744
{/if}

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

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ query TeamOverview($team: Slug!) @cache(policy: NetworkOnly) {
3131
... on WorkloadStatusNoRunningInstances {
3232
level
3333
}
34+
... on WorkloadStatusFailedRun {
35+
detail
36+
name
37+
}
3438
}
3539
}
3640
}

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@
3131
{#if (getErrors('WorkloadStatusNoRunningInstances') ?? []).length > 0}
3232
{@const noRunningInstances = getErrors('WorkloadStatusNoRunningInstances')!}
3333
<Alert variant="error">
34-
<Heading level="2" size="small">No running instances</Heading>
35-
<BodyShort>
36-
There are no running instances of the following application{noRunningInstances.length === 1
37-
? ''
38-
: 's'}.
34+
<Heading level="2" size="small" spacing>No Running Instances</Heading>
35+
<BodyShort spacing>
36+
The following application{noRunningInstances.length === 1 ? ' has' : 's have'} no running instances.
3937
</BodyShort>
4038
<div>
4139
{#each noRunningInstances as workload (workload.id)}

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ query App($app: String!, $team: Slug!, $env: String!) {
1313
}
1414
instances {
1515
nodes {
16+
id
17+
name
1618
image {
1719
name
1820
tag
1921
}
22+
status {
23+
state
24+
message
25+
}
2026
}
2127
}
2228
deletionStartedAt
@@ -36,16 +42,21 @@ query App($app: String!, $team: Slug!, $env: String!) {
3642
status {
3743
errors {
3844
__typename
39-
level
4045
... on WorkloadStatusDeprecatedRegistry {
46+
level
4147
registry
4248
}
4349
... on WorkloadStatusSynchronizationFailing {
50+
level
4451
detail
4552
}
4653
... on WorkloadStatusInvalidNaisYaml {
54+
level
4755
detail
4856
}
57+
... on WorkloadStatusNoRunningInstances {
58+
level
59+
}
4960
}
5061
}
5162

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

+28
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,34 @@
7474
<div class="wrapper">
7575
<div class="app-content">
7676
<div class="main-section">
77+
{#if app.status.errors.some((error) => error.__typename === 'WorkloadStatusNoRunningInstances')}
78+
<Alert
79+
variant={levelVariant(
80+
app.status.errors.find(
81+
(error) => error.__typename === 'WorkloadStatusNoRunningInstances'
82+
)?.level
83+
)}
84+
>
85+
<div style="display: grid; gap: var(--a-spacing-3);">
86+
<Heading level="2" size="small">No Running Instances</Heading>
87+
<BodyShort>The application has no running instances.</BodyShort>
88+
89+
<Heading level="3" size="xsmall">Failing instances:</Heading>
90+
<ul style="margin: 0;">
91+
{#each app.instances.nodes as instance (instance.id)}
92+
<li>
93+
<code style="font-size: 1rem; line-height: 1.75;">{instance.name}</code>:
94+
<strong>{instance.status.message}</strong>
95+
</li>
96+
{/each}
97+
</ul>
98+
<BodyLong>
99+
Check logs if available. If this is unexpected and you cannot resolve the issue,
100+
please contact the Nais team.
101+
</BodyLong>
102+
</div>
103+
</Alert>
104+
{/if}
77105
{#if app.status.errors.some((error) => error.__typename === 'WorkloadStatusInvalidNaisYaml')}
78106
<Alert
79107
variant={levelVariant(

0 commit comments

Comments
 (0)