Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silly-plants-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"observability": patch
---

Fix bug where health state badges show UNKNOWN health state when the extension is not fully configured
19 changes: 15 additions & 4 deletions pkg/observability/components/ComponentHealth.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { mapGetters } from "vuex";
import { loadComponent } from "../modules/suseObservability";
import {ConnectionStatus, FetchError, loadComponent} from "../modules/suseObservability";
import { isCrdLoaded, loadSuseObservabilitySettings } from "../modules/rancher";
import { buildUrn } from "../modules/urn";
import { HEALTH_STATE_TYPES } from "../types/types";
Expand All @@ -17,7 +17,7 @@ export default {
},
data() {
return {
health: HEALTH_STATE_TYPES.UNKNOWN,
health: HEALTH_STATE_TYPES.UNCONFIGURED,
urn: "",
};
},
Expand Down Expand Up @@ -46,8 +46,19 @@ export default {
return;
}

const component = await loadComponent(settings, this.urn);
this.health = component.state.healthState;
try {
const component = await loadComponent(settings, this.urn);
this.health = component.state.healthState;
} catch (error) {
if (error instanceof FetchError) {
if (error.status === ConnectionStatus.Unconfigured) {
this.health = HEALTH_STATE_TYPES.UNCONFIGURED;
return;
}
}

this.health = HEALTH_STATE_TYPES.CONNECTION_ERROR;
}
},
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion pkg/observability/components/Health/HealthDisc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HEALTH_STATE_TYPES } from "../../types/types";

export default {
name: "HealthDisc",
props: { health: { type: String, default: HEALTH_STATE_TYPES.UNKNOWN } },
props: { health: { type: String, default: HEALTH_STATE_TYPES.UNCONFIGURED } },
};
</script>
<template>
Expand Down
2 changes: 1 addition & 1 deletion pkg/observability/components/Health/HealthState.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
case HEALTH_STATE_TYPES.CRITICAL:
return "red";
case HEALTH_STATE_TYPES.UNKNOWN:
case HEALTH_STATE_TYPES.NOT_MONITORED:
case HEALTH_STATE_TYPES.UNCONFIGURED:
return "grey";
default:
return "skeleton";
Expand Down
17 changes: 8 additions & 9 deletions pkg/observability/components/MonitorTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,17 @@ export default {

this.urn = this.componentIdentifier;

const component = await loadComponent(settings, this.urn);
if (!component) {
try {
const component = await loadComponent(settings, this.urn);
this.monitors = component.syncedCheckStates;

this.url = settings.url;
} catch (e) {
this.observationStatus = await loadObservationStatus(
this.clusterId,
settings,
this.clusterId,
settings,
);
return;
}

this.monitors = component.syncedCheckStates;

this.url = settings.url;
},
};
</script>
Expand Down
21 changes: 19 additions & 2 deletions pkg/observability/formatters/ComponentLinkedHealthState.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script>
import { mapGetters } from "vuex";
import HealthState from "../components/Health/HealthState";
import { loadComponent } from "../modules/suseObservability";
import {
ConnectionStatus,
FetchError,
loadComponent,
} from "../modules/suseObservability";
import { loadSuseObservabilitySettings, isCrdLoaded } from "../modules/rancher";
import { buildUrn } from "../modules/urn";
import { HEALTH_STATE_TYPES } from "../types/types";
Expand Down Expand Up @@ -75,6 +79,19 @@ export default {
};
} catch (error) {
this.error = error;

if (error instanceof FetchError) {
if (error.status === ConnectionStatus.Unconfigured) {
this.data = {
health: HEALTH_STATE_TYPES.UNCONFIGURED
}
return;
}
}

this.data = {
health: HEALTH_STATE_TYPES.CONNECTION_ERROR
}
} finally {
this.isLoading = false;
}
Expand All @@ -94,5 +111,5 @@ export default {
<HealthState :health="data.health" :color="color" />
</a>

<HealthState v-else :health="HEALTH_STATE_TYPES.UNKNOWN" :color="color" />
<HealthState v-else :health="HEALTH_STATE_TYPES.UNCONFIGURED" :color="color" />
</template>
2 changes: 1 addition & 1 deletion pkg/observability/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ observability:
noDataPostpend: "the Stackpack or align the agent configuration."
accessDenied: Unable to test if SUSE Observability is installed
connecting: "Connecting to SUSE Observability Plane..."
notConnectedPrepend: "SUSE Observability has not been configured, please go to the"
notConnectedPrepend: "SUSE Observability has not been configured or has a connection error, please go to the"
notConnectedObservability: "SUSE Observability Configuration."
clusterHealth: "Cluster health:"
componentsHealth: "Components health:"
Expand Down
6 changes: 5 additions & 1 deletion pkg/observability/modules/suseObservability.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConnectionInfo } from "types/component";
import { ObservabilitySettings } from "./settings";

class FetchError extends Error {
export class FetchError extends Error {
status: number;

constructor(message: string, status: number) {
Expand All @@ -20,6 +20,7 @@ export enum ConnectionStatus {
Connected = 0,
InvalidToken,
CrossOriginError,
Unconfigured,
}

export async function checkConnection(
Expand Down Expand Up @@ -124,6 +125,9 @@ export async function loadComponent(
spec: ObservabilitySettings,
identifier: string,
) {
if (!spec) {
throw new FetchError("Extension not configured", ConnectionStatus.Unconfigured);
}
const creds = token(spec.serviceToken);
const resp = await fetch(
`${spec.url}/api/components?identifier=${encodeURIComponent(identifier)}`,
Expand Down
2 changes: 1 addition & 1 deletion pkg/observability/types/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TableColumn } from "@rancher/shell/core/types";
export const ObservabilityHealth: TableColumn = {
labelKey: "observability.health",
getValue: (row: any) => {
return "UNKNOWN";
return "UNCONFIGURED";
},
formatter: "ComponentLinkedHealthState",
width: 100,
Expand Down
3 changes: 2 additions & 1 deletion pkg/observability/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,6 @@ export const HEALTH_STATE_TYPES = {
CLEAR: "CLEAR",
DEVIATING: "DEVIATING",
CRITICAL: "CRITICAL",
NOT_MONITORED: "NOT MONITORED",
CONNECTION_ERROR: "CONNECTION_ERROR",
UNCONFIGURED: "UNCONFIGURED",
};
Loading