Skip to content

Commit

Permalink
Job status (#12)
Browse files Browse the repository at this point in the history
provide status on jobs
  • Loading branch information
rbjornstad authored Sep 22, 2023
1 parent de8645e commit 8223800
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 75 deletions.
13 changes: 13 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ type External {
ports: [Port!]!
}

type FailedRunError implements StateError {
level: ErrorLevel!
revision: String!
runMessage: String!
runName: String!
}

type Flag {
name: String!
value: String!
Expand Down Expand Up @@ -336,6 +343,11 @@ type InvalidNaisYamlError implements StateError {
revision: String!
}

type JobState {
errors: [StateError!]!
state: State!
}

type Kafka implements Storage {
"""The kafka pool name"""
name: String!
Expand Down Expand Up @@ -394,6 +406,7 @@ type NaisJob implements Node {
env: Env!
id: ID!
image: String!
jobState: JobState!
manifest: String!
name: String!
parallelism: Int!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,29 @@
$: team = $page.params.team;
$: env = $page.params.env;
$: app = $page.params.app;
$: job = $page.params.job;
</script>

<div class="wrapper">
{#if $data.revision == PendingValue}
{#if $data.revision == PendingValue}
<div class="wrapper">
<Loading />
{:else if $data.__typename === 'DeprecatedRegistryError'}
</div>
{:else if $data.__typename === 'DeprecatedRegistryError'}
<div class="wrapper">
<Alert variant="warning">
Deprecated image registry <strong>{$data.registry}</strong> for image
<strong>{$data.name}</strong>. See
<a href="https://github.com/nais/docker-build-push"> docker-build-push</a> on how to migrate to
Google Artifact Registry.
</Alert>
{:else if $data.__typename === 'NoRunningInstancesError'}
</div>
{:else if $data.__typename === 'NoRunningInstancesError'}
<div class="wrapper">
<Alert variant="error">
No running instances of <strong>{app}</strong> in <strong>{env}</strong>.
</Alert>
{:else if $data.__typename === 'DeprecatedIngressError'}
</div>
{:else if $data.__typename === 'DeprecatedIngressError'}
<div class="wrapper">
<Alert variant="warning">
Deprecated ingress <strong>{$data.ingress}</strong>. See
{#if env === 'dev-gcp'}
Expand All @@ -92,11 +97,15 @@
<a href="https://doc.nais.io/clusters/on-premises/#prod-fss"> ingress documentation</a>
{/if} for available ingress domains.
</Alert>
{:else if $data.__typename === 'InvalidNaisYamlError'}
</div>
{:else if $data.__typename === 'InvalidNaisYamlError'}
<div class="wrapper">
<Alert variant="error">
Nais-yaml might be invalid for application <strong>{app}</strong>.
</Alert>
{:else if $data.__typename === 'NewInstancesFailingError'}
</div>
{:else if $data.__typename === 'NewInstancesFailingError'}
<div class="wrapper">
<Alert variant="warning">
{#if app}
New instances of <strong>{app}</strong> in <strong>{env}</strong> are failing. Check logs
Expand All @@ -105,13 +114,11 @@
<br /><a href="/team/{team}/{env}/app/{app}/logs?name={instance}">{instance}</a>
{/each}
{/if}
{#if job}
Job runs are failing. Please check <a href="/team/{team}/{env}/job/{job}/logs">logs</a> of new
runs.
{/if}
</Alert>
{:else if $data.__typename === 'InboundAccessError'}
{#if $data.rule.mutualExplanation !== 'NO_ZERO_TRUST'}
</div>
{:else if $data.__typename === 'InboundAccessError'}
{#if $data.rule.mutualExplanation !== 'NO_ZERO_TRUST' && $data.rule.mutualExplanation !== 'CLUSTER_NOT_FOUND'}
<div class="wrapper">
<Alert variant="warning"
><a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
Expand Down Expand Up @@ -149,8 +156,10 @@
>Nais Application reference - accessPolicy</a
>.</Alert
>
{/if}
{:else if $data.__typename === 'OutboundAccessError'}
</div>
{/if}
{:else if $data.__typename === 'OutboundAccessError'}
<div class="wrapper">
<Alert variant="warning"
><a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
Expand All @@ -166,9 +175,15 @@
{#if $data.rule.mutualExplanation == 'APP_NOT_FOUND'}
Please verify inbound rule for {app}. Check rule in
<a href="/team/{team}/{env}/app/{app}/yaml">manifest</a>. Are namespace or cluster missing
from rule?
from rule? Does the application exist?
{:else if $data.rule.mutualExplanation === 'RULE_NOT_FOUND'}
Fant ikke
Please add inbound rule for {app}.{team}.{env} to {$data.rule.application}.{$data.rule
.namespace || team}.{$data.rule.cluster ? $data.rule.cluster : env}
<a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
? $data.rule.cluster
: env}/app/{$data.rule.application}/yaml">manifest</a
>.
{:else}
{$data.rule.mutualExplanation}
{/if}
Expand All @@ -177,10 +192,12 @@
>Nais Application reference - accessPolicy</a
>.</Alert
>
{:else}
</div>
{:else}
<div class="wrapper">
<Alert variant="error">Unkown error</Alert>
{/if}
</div>
</div>
{/if}

<style>
.wrapper :global(.navds-alert__wrapper) {
Expand Down
162 changes: 162 additions & 0 deletions src/lib/JobErrorTypeToMessage.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<script lang="ts">
import { page } from '$app/stores';
import { PendingValue, fragment, graphql, type JobErrorFragment } from '$houdini';
import { Alert } from '@nais/ds-svelte-community';
import Loading from './Loading.svelte';
export let error: JobErrorFragment;
$: data = fragment(
error,
graphql(`
fragment JobErrorFragment on StateError {
revision @loading
type: __typename
... on DeprecatedRegistryError {
level
name
registry
repository
revision
tag
}
... on InvalidNaisYamlError {
level
detail
}
... on InboundAccessError {
level
rule {
application
cluster
mutual
mutualExplanation
namespace
}
}
... on OutboundAccessError {
level
rule {
application
cluster
mutual
mutualExplanation
namespace
}
}
... on FailedRunError {
level
runMessage
runName
}
}
`)
);
$: team = $page.params.team;
$: env = $page.params.env;
$: job = $page.params.job;
</script>

<div class="wrapper">
{#if $data.revision == PendingValue}
<Loading />
{:else if $data.__typename === 'DeprecatedRegistryError'}
<Alert variant="warning">
Deprecated image registry <strong>{$data.registry}</strong> for image
<strong>{$data.name}</strong>. See
<a href="https://github.com/nais/docker-build-push"> docker-build-push</a> on how to migrate to
Google Artifact Registry.
</Alert>
{:else if $data.__typename === 'InvalidNaisYamlError'}
<!---->
<Alert variant="error">
Nais-yaml might be invalid for application <strong>{job}</strong>.
</Alert>
{:else if $data.__typename === 'InboundAccessError'}
{#if $data.rule.mutualExplanation !== 'NO_ZERO_TRUST' && $data.rule.mutualExplanation !== 'CLUSTER_NOT_FOUND'}
<Alert variant="warning"
><a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
? $data.rule.cluster
: env}/app/{$data.rule.application}"
>{$data.rule.application}.{$data.rule.namespace || team}.{$data.rule.cluster
? $data.rule.cluster
: env}</a
>
is missing outbound rule for
<a href="/team/{team}/{env}/job/{job}">{job}.{team}.{env}</a>.
<br />
{#if $data.rule.mutualExplanation === 'APP_NOT_FOUND'}
Verify outbound rules for
<a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
? $data.rule.cluster
: env}/app/{$data.rule.application}/yaml">manifest</a
>. Are namespace or cluster missing from rule?
{:else if $data.rule.mutualExplanation === 'RULE_NOT_FOUND'}
Please add outbound rule for {job}.{team}.{env} to
<a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
? $data.rule.cluster
: env}/app/{$data.rule.application}/yaml">manifest</a
>.
{:else}
<!--Please verify outbound rule for {app}. Check rule in
<a href="/team/{team}/{env}/app/{app}/yaml">manifest</a>.-->
{$data.rule.mutualExplanation}
{/if}
<br />
Consult
<a href="https://docs.nais.io/nais-application/application/?h=#accesspolicy"
>Nais Application reference - accessPolicy</a
>.</Alert
>
{/if}
{:else if $data.__typename === 'OutboundAccessError'}
<Alert variant="warning"
><a
href="/team/{$data.rule.namespace || team}/{$data.rule.cluster
? $data.rule.cluster
: env}/app/{$data.rule.application}"
>{$data.rule.application}.{$data.rule.namespace || team}.{$data.rule.cluster
? $data.rule.cluster
: env}</a
>
is missing inbound rule for
<a href="/team/{team}/{env}/job/{job}">{job}.{team}.{env}</a>.
<br />
{#if $data.rule.mutualExplanation == 'APP_NOT_FOUND'}
Please verify inbound rule for {job}. Check rule in
<a href="/team/{team}/{env}/app/{job}/yaml">manifest</a>. Are namespace or cluster missing
from rule?
{:else if $data.rule.mutualExplanation === 'RULE_NOT_FOUND'}
Fant ikke
{:else}
{$data.rule.mutualExplanation}
{/if}
<br />Consult
<a href="https://docs.nais.io/nais-application/application/?h=#accesspolicy"
>Nais Application reference - accessPolicy</a
>.</Alert
>
{:else if $data.__typename === 'FailedRunError'}
<Alert variant="error">
{$data.runName} failed. {$data.runMessage}. Please consult the
<a href="/team/{team}/{env}/job/{job}/logs?{$data.runName}">logs</a> if still available.
</Alert>
{:else}
<Alert variant="error">Unkown error</Alert>
{/if}
</div>

<style>
.wrapper :global(.navds-alert__wrapper) {
max-width: none;
}
.wrapper {
padding-bottom: 1rem;
}
</style>
33 changes: 33 additions & 0 deletions src/lib/Status.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script lang="ts">
import Nais from './icons/Nais.svelte';
import UnknownIcon from './icons/UnknownIcon.svelte';
import WarningIcon from './icons/WarningIcon.svelte';
export let state: string;
export let size: string;
</script>

{#if state === 'NAIS'}
<Nais {size} style="color: var(--a-icon-success)" aria-label="Application is nais" role="image" />
{:else if state === 'FAILING'}
<WarningIcon
{size}
style="color: var(--a-icon-danger)"
aria-label="Application is failing"
role="image"
/>
{:else if state === 'NOTNAIS'}
<Nais
{size}
style="color: var(--a-icon-warning)"
aria-label="Application is not nais"
role="image"
/>
{:else if state === 'UNKNOWN'}
<UnknownIcon
{size}
style="color: var(--a-icon-warning)"
aria-label="Unknown application status"
role="image"
/>
{/if}
3 changes: 1 addition & 2 deletions src/routes/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
color: var(--a-text-on-inverted);
height: 3rem;
display: flex;
align-items: center;
padding: 0 2rem;
margin-bottom: 2rem;
min-width: 1000px;
Expand All @@ -186,12 +185,12 @@
width: 100%;
min-width: 1000px;
max-width: 1432px;
align-items: center;
}
.logo {
color: var(--a-text-on-inverted);
text-decoration: none;
display: flex;
align-items: center;
gap: 1rem;
font-size: 1.5rem;
font-weight: bold;
Expand Down
4 changes: 4 additions & 0 deletions src/routes/team/[team]/(teamTabs)/+page.gql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ query Workloads($team: String!) @loading(count: 5, cascade: true) {
name
}

appState {
state
}

instances {
state
}
Expand Down
Loading

0 comments on commit 8223800

Please sign in to comment.