@skyhook-io/radar-app 1.21.7 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/App.tsx +26 -3
- package/src/api/client.ts +16 -3
- package/src/api/radarFeatures.ts +4 -0
- package/src/api/traefik.ts +33 -0
- package/src/api/traffic.ts +1 -0
- package/src/components/CloudFunnelButton.test.tsx +39 -1
- package/src/components/CloudFunnelButton.tsx +10 -3
- package/src/components/NamespaceSwitcher.tsx +6 -2
- package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
- package/src/components/applications/ApplicationsView.tsx +71 -142
- package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
- package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
- package/src/components/cnpg/CNPGOverview.test.tsx +75 -3
- package/src/components/cnpg/CNPGOverview.tsx +62 -4
- package/src/components/home/HomeView.tsx +9 -1
- package/src/components/home/NetworkPolicyCoverageCard.test.tsx +37 -0
- package/src/components/home/NetworkPolicyCoverageCard.tsx +26 -2
- package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
- package/src/components/issues/IssuesPane.render.test.tsx +78 -2
- package/src/components/issues/IssuesPane.tsx +38 -6
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.tsx +29 -0
- package/src/components/settings/FormSaveActions.tsx +6 -2
- package/src/components/settings/MetricsBackendSwitch.tsx +13 -15
- package/src/components/settings/OpenObserveSetup.test.tsx +68 -27
- package/src/components/settings/OpenObserveSetup.tsx +93 -123
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +23 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +5 -4
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +14 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +17 -0
- package/src/components/traffic/TrafficFlowList.tsx +5 -5
- package/src/components/traffic/TrafficGraph.test.tsx +11 -0
- package/src/components/traffic/TrafficGraph.tsx +31 -19
- package/src/components/traffic/TrafficView.tsx +17 -6
- package/src/components/traffic/traffic-export.test.ts +8 -0
- package/src/components/traffic/traffic-export.ts +7 -4
- package/src/components/traffic/trafficFilters.test.ts +51 -1
- package/src/components/traffic/trafficFilters.ts +39 -11
- package/src/components/ui/command-items-crd.test.tsx +23 -8
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.tsx +8 -6
- package/src/components/workspace/WorkspaceConditions.tsx +56 -0
- package/src/components/workspace/layout.test.tsx +20 -0
- package/src/components/workspace/layout.tsx +1 -1
- package/src/contexts/CapabilitiesContext.tsx +2 -0
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +3 -0
- package/src/utils/page-links.ts +15 -1
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
radarUpgradeDetail,
|
|
16
16
|
radarUpgradeHeadline,
|
|
17
17
|
FreshnessControl,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
IssuesView,
|
|
19
|
+
appRelationshipFields,
|
|
20
20
|
useToast,
|
|
21
21
|
orderEnvs,
|
|
22
22
|
matchWorkloadAcrossInstances,
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
eventsForApplication,
|
|
33
33
|
memberRef,
|
|
34
34
|
subjectRef,
|
|
35
|
-
compareIssueSortAnchors,
|
|
36
35
|
canonicalResourceGroup,
|
|
37
36
|
type AppRow,
|
|
38
37
|
type AppWorkload,
|
|
@@ -45,6 +44,7 @@ import {
|
|
|
45
44
|
type SelectedAppWorkload,
|
|
46
45
|
type SelectedResource,
|
|
47
46
|
} from "@skyhook-io/k8s-ui";
|
|
47
|
+
import { buildIssueAppIndex } from "@skyhook-io/k8s-ui/components/issues";
|
|
48
48
|
import { AlertTriangle, Boxes } from "lucide-react";
|
|
49
49
|
import { SEVERITY_TEXT } from "@skyhook-io/k8s-ui/utils/badge-colors";
|
|
50
50
|
import {
|
|
@@ -156,6 +156,7 @@ export function ApplicationsView({
|
|
|
156
156
|
<AppDetailRoute
|
|
157
157
|
app={selected}
|
|
158
158
|
apps={apps}
|
|
159
|
+
completeInventory={namespaces.length === 0 && query.data?.access?.restricted === false}
|
|
159
160
|
onBack={() => selectApp(null)}
|
|
160
161
|
onOpenResource={onOpenResource}
|
|
161
162
|
/>
|
|
@@ -226,11 +227,13 @@ export function ApplicationsView({
|
|
|
226
227
|
function AppDetailRoute({
|
|
227
228
|
app,
|
|
228
229
|
apps,
|
|
230
|
+
completeInventory,
|
|
229
231
|
onBack,
|
|
230
232
|
onOpenResource,
|
|
231
233
|
}: {
|
|
232
234
|
app: AppRow;
|
|
233
235
|
apps: AppRow[];
|
|
236
|
+
completeInventory: boolean;
|
|
234
237
|
onBack: () => void;
|
|
235
238
|
onOpenResource: (resource: SelectedResource) => void;
|
|
236
239
|
}) {
|
|
@@ -257,14 +260,21 @@ function AppDetailRoute({
|
|
|
257
260
|
refetchInterval: 10_000,
|
|
258
261
|
},
|
|
259
262
|
);
|
|
260
|
-
const
|
|
263
|
+
const issueNamespaces = useMemo(() => {
|
|
264
|
+
if (!completeInventory) return appNamespaces;
|
|
265
|
+
const namespaces = new Set(appNamespaces);
|
|
266
|
+
for (const [field] of appRelationshipFields) {
|
|
267
|
+
for (const ref of app.relationships?.[field] ?? []) {
|
|
268
|
+
if (ref.namespace && !ref.state) namespaces.add(ref.namespace);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return [...namespaces].sort();
|
|
272
|
+
}, [appNamespaces, app.relationships, completeInventory]);
|
|
273
|
+
const issuesQuery = useIssues(issueNamespaces);
|
|
274
|
+
const issueData = issuesQuery.data;
|
|
261
275
|
const appIssues = useMemo(
|
|
262
|
-
() =>
|
|
263
|
-
|
|
264
|
-
issuesQuery.data?.issues ?? [],
|
|
265
|
-
app.workloads ?? [],
|
|
266
|
-
),
|
|
267
|
-
[issuesQuery.data?.issues, app.workloads],
|
|
276
|
+
() => appIssuesForApplication(issueData?.issues ?? [], app, apps, completeInventory),
|
|
277
|
+
[issueData?.issues, app, apps, completeInventory],
|
|
268
278
|
);
|
|
269
279
|
|
|
270
280
|
// The selected workload (?workload=<key>) is the scope switch and wins over
|
|
@@ -739,10 +749,13 @@ function AppDetailRoute({
|
|
|
739
749
|
}
|
|
740
750
|
renderOverviewIssues={() => (
|
|
741
751
|
<AppOverviewIssues
|
|
752
|
+
key={app.key}
|
|
753
|
+
application={app}
|
|
742
754
|
issues={appIssues}
|
|
743
755
|
error={issuesQuery.error}
|
|
744
|
-
hasData={Boolean(
|
|
745
|
-
visibility={
|
|
756
|
+
hasData={Boolean(issueData)}
|
|
757
|
+
visibility={issueData?.visibility}
|
|
758
|
+
truncated={!!issueData && (issueData.total_matched ?? issueData.issues.length) > issueData.issues.length}
|
|
746
759
|
onOpenResource={onOpenResource}
|
|
747
760
|
/>
|
|
748
761
|
)}
|
|
@@ -787,28 +800,26 @@ function applicationHistoryRangeOptions(
|
|
|
787
800
|
}
|
|
788
801
|
|
|
789
802
|
function AppOverviewIssues({
|
|
803
|
+
application,
|
|
790
804
|
issues,
|
|
791
805
|
error,
|
|
792
806
|
hasData,
|
|
793
807
|
visibility,
|
|
808
|
+
truncated,
|
|
794
809
|
onOpenResource,
|
|
795
810
|
}: {
|
|
811
|
+
application: Pick<AppRow, "key" | "name">;
|
|
796
812
|
issues: Issue[];
|
|
797
813
|
error: unknown;
|
|
798
814
|
hasData: boolean;
|
|
799
815
|
visibility?: IssuesResponse["visibility"];
|
|
816
|
+
truncated: boolean;
|
|
800
817
|
onOpenResource: (resource: SelectedResource) => void;
|
|
801
818
|
}) {
|
|
802
|
-
const [openId, setOpenId] = useState<string | null>(null);
|
|
803
|
-
const sorted = useMemo(
|
|
804
|
-
() => [...issues].sort(compareAppOverviewIssues),
|
|
805
|
-
[issues],
|
|
806
|
-
);
|
|
807
|
-
|
|
808
819
|
if (error && !hasData) {
|
|
809
820
|
return (
|
|
810
821
|
<AppOverviewIssuesState
|
|
811
|
-
headline="
|
|
822
|
+
headline="Issues unavailable"
|
|
812
823
|
body={
|
|
813
824
|
error instanceof Error
|
|
814
825
|
? error.message
|
|
@@ -818,57 +829,40 @@ function AppOverviewIssues({
|
|
|
818
829
|
);
|
|
819
830
|
}
|
|
820
831
|
|
|
821
|
-
if (error)
|
|
822
|
-
|
|
823
|
-
|
|
832
|
+
if (!error && !visibility?.impact && !truncated && issues.length === 0) return null;
|
|
833
|
+
|
|
834
|
+
const navigate = (ref: IssueResourceRef) => {
|
|
835
|
+
onOpenResource({
|
|
836
|
+
kind: kindToPluralWithGroup(ref.kind, ref.group ?? ""),
|
|
837
|
+
namespace: ref.namespace ?? "",
|
|
838
|
+
name: ref.name,
|
|
839
|
+
group: ref.group ?? "",
|
|
840
|
+
});
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
return (
|
|
844
|
+
<section className="space-y-2">
|
|
845
|
+
{error ? (
|
|
824
846
|
<AppOverviewIssuesState
|
|
825
|
-
headline="
|
|
847
|
+
headline="Issue refresh failed"
|
|
826
848
|
body="Showing the last successful result for this application."
|
|
827
849
|
/>
|
|
828
|
-
|
|
829
|
-
<AppOverviewIssueRows
|
|
830
|
-
issues={sorted}
|
|
831
|
-
openId={openId}
|
|
832
|
-
setOpenId={setOpenId}
|
|
833
|
-
onOpenResource={onOpenResource}
|
|
834
|
-
/>
|
|
835
|
-
)}
|
|
836
|
-
</section>
|
|
837
|
-
);
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
if (visibility?.impact) {
|
|
841
|
-
return (
|
|
842
|
-
<section className="space-y-2">
|
|
850
|
+
) : visibility?.impact && (
|
|
843
851
|
<AppOverviewIssuesState
|
|
844
|
-
headline={
|
|
845
|
-
sorted.length === 0
|
|
846
|
-
? "No visible operational issues"
|
|
847
|
-
: "Operational issue visibility is limited"
|
|
848
|
-
}
|
|
852
|
+
headline={issues.length ? "Issue visibility is limited" : "No visible issues"}
|
|
849
853
|
body={`${visibility.impact} Results may be incomplete.`}
|
|
850
854
|
/>
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
if (sorted.length === 0) return null;
|
|
864
|
-
|
|
865
|
-
return (
|
|
866
|
-
<AppOverviewIssueRows
|
|
867
|
-
issues={sorted}
|
|
868
|
-
openId={openId}
|
|
869
|
-
setOpenId={setOpenId}
|
|
870
|
-
onOpenResource={onOpenResource}
|
|
871
|
-
/>
|
|
855
|
+
)}
|
|
856
|
+
{truncated && (
|
|
857
|
+
<AppOverviewIssuesState
|
|
858
|
+
headline="Issue results are incomplete"
|
|
859
|
+
body="Radar reached the issue limit for these namespaces. Some issues for this application may be missing."
|
|
860
|
+
/>
|
|
861
|
+
)}
|
|
862
|
+
{issues.length > 0 && (
|
|
863
|
+
<IssuesView application={application} anyData issues={issues} onResourceClick={navigate} />
|
|
864
|
+
)}
|
|
865
|
+
</section>
|
|
872
866
|
);
|
|
873
867
|
}
|
|
874
868
|
|
|
@@ -897,90 +891,25 @@ function AppOverviewIssuesState({
|
|
|
897
891
|
);
|
|
898
892
|
}
|
|
899
893
|
|
|
900
|
-
function
|
|
901
|
-
issues: sorted,
|
|
902
|
-
openId,
|
|
903
|
-
setOpenId,
|
|
904
|
-
onOpenResource,
|
|
905
|
-
}: {
|
|
906
|
-
issues: Issue[];
|
|
907
|
-
openId: string | null;
|
|
908
|
-
setOpenId: (value: string | null) => void;
|
|
909
|
-
onOpenResource: (resource: SelectedResource) => void;
|
|
910
|
-
}) {
|
|
911
|
-
const navigate = (ref: IssueResourceRef) => {
|
|
912
|
-
onOpenResource({
|
|
913
|
-
kind: kindToPluralWithGroup(ref.kind, ref.group ?? ""),
|
|
914
|
-
namespace: ref.namespace ?? "",
|
|
915
|
-
name: ref.name,
|
|
916
|
-
group: ref.group ?? "",
|
|
917
|
-
});
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
return (
|
|
921
|
-
<section className="space-y-2">
|
|
922
|
-
<div className="flex items-center justify-between gap-3">
|
|
923
|
-
<div className="flex min-w-0 items-center gap-2 text-sm font-semibold text-theme-text-primary">
|
|
924
|
-
<AlertTriangle
|
|
925
|
-
className="h-4 w-4 shrink-0 text-theme-text-secondary"
|
|
926
|
-
aria-hidden
|
|
927
|
-
/>
|
|
928
|
-
<span>Operational Issues</span>
|
|
929
|
-
<span className="badge-sm text-[10px] text-theme-text-secondary">
|
|
930
|
-
{sorted.length}
|
|
931
|
-
</span>
|
|
932
|
-
</div>
|
|
933
|
-
<span className="text-xs text-theme-text-tertiary">
|
|
934
|
-
Scoped to this application
|
|
935
|
-
</span>
|
|
936
|
-
</div>
|
|
937
|
-
<ol className="flex flex-col gap-1.5">
|
|
938
|
-
{sorted.slice(0, 4).map((issue) => {
|
|
939
|
-
const rowKey = `${issue.cluster_id ?? ""}:${issue.id}`;
|
|
940
|
-
return (
|
|
941
|
-
<IssueRow
|
|
942
|
-
key={rowKey}
|
|
943
|
-
issue={issue}
|
|
944
|
-
open={openId === rowKey}
|
|
945
|
-
onToggle={() => setOpenId(openId === rowKey ? null : rowKey)}
|
|
946
|
-
onResourceClick={navigate}
|
|
947
|
-
/>
|
|
948
|
-
);
|
|
949
|
-
})}
|
|
950
|
-
</ol>
|
|
951
|
-
{sorted.length > 4 ? (
|
|
952
|
-
<div className="text-xs text-theme-text-tertiary">
|
|
953
|
-
Showing 4 of {sorted.length} issues. Open Issues for the full queue.
|
|
954
|
-
</div>
|
|
955
|
-
) : null}
|
|
956
|
-
</section>
|
|
957
|
-
);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
function compareAppOverviewIssues(a: Issue, b: Issue): number {
|
|
961
|
-
const severity =
|
|
962
|
-
ISSUE_SEVERITY_RANK[b.severity] - ISSUE_SEVERITY_RANK[a.severity];
|
|
963
|
-
if (severity !== 0) return severity;
|
|
964
|
-
const onset = compareIssueSortAnchors(a, b);
|
|
965
|
-
if (onset !== 0) return onset;
|
|
966
|
-
const ns = (a.namespace ?? "").localeCompare(b.namespace ?? "");
|
|
967
|
-
if (ns !== 0) return ns;
|
|
968
|
-
const name = a.name.localeCompare(b.name);
|
|
969
|
-
if (name !== 0) return name;
|
|
970
|
-
return a.id.localeCompare(b.id);
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
export function appIssuesForWorkloads(
|
|
894
|
+
export function appIssuesForApplication(
|
|
974
895
|
issues: Issue[],
|
|
975
|
-
|
|
896
|
+
app: Pick<AppRow, "key" | "workloads">,
|
|
897
|
+
inventory: AppRow[],
|
|
898
|
+
completeInventory: boolean,
|
|
976
899
|
): Issue[] {
|
|
977
|
-
if (issues.length === 0
|
|
900
|
+
if (issues.length === 0) return [];
|
|
901
|
+
const ownerForIssue = buildIssueAppIndex(inventory, { complete: completeInventory });
|
|
902
|
+
const workloads = app.workloads;
|
|
978
903
|
const workloadKeys = new Set(workloads.map(workloadIssueKey));
|
|
979
904
|
const out: Issue[] = [];
|
|
980
905
|
const seen = new Set<string>();
|
|
981
906
|
for (const issue of issues) {
|
|
982
|
-
|
|
983
|
-
|
|
907
|
+
// Diagnostic evidence can show that an issue affects this app even when
|
|
908
|
+
// the queue cannot attribute ownership to a single application.
|
|
909
|
+
if (
|
|
910
|
+
ownerForIssue(issue)?.key !== app.key &&
|
|
911
|
+
!issueRefs(issue).some((ref) => workloadKeys.has(issueRefKey(ref)))
|
|
912
|
+
) continue;
|
|
984
913
|
if (seen.has(issue.id)) continue;
|
|
985
914
|
seen.add(issue.id);
|
|
986
915
|
out.push(issue);
|
|
@@ -41,5 +41,8 @@ it('states that conditions have not been reported', () => {
|
|
|
41
41
|
act(() => root.render(<CNPGOperatorConditions conditions={[]} />))
|
|
42
42
|
expect(host.textContent).toContain('No conditions reported')
|
|
43
43
|
expect(host.querySelector('button')!.getAttribute('aria-expanded')).toBe('false')
|
|
44
|
+
act(() => host.querySelector('button')!.click())
|
|
45
|
+
expect(host.textContent).toContain('The operator has not reported status.conditions.')
|
|
46
|
+
expect(host.querySelector('section')!.className.split(' ').sort()).toEqual('mx-4 mb-4 rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm'.split(' ').sort())
|
|
44
47
|
act(() => root.unmount())
|
|
45
48
|
})
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceConditions } from '../workspace/WorkspaceConditions'
|
|
2
|
+
import type { ComponentProps } from 'react'
|
|
2
3
|
|
|
3
|
-
export function CNPGOperatorConditions(
|
|
4
|
-
return
|
|
5
|
-
<section className="mx-4 mb-4 rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm">
|
|
6
|
-
<FoldSection title="Operator conditions" summary={conditions.length > 0 ? `${conditions.length} reported · status.conditions` : 'No conditions reported'} attention={false}>
|
|
7
|
-
<FactGrid>{conditions.map((c) => <FactRow key={c.type} label={<span className="inline-flex flex-wrap items-center gap-2">{c.type}<Badge severity="neutral" size="sm">{c.status}</Badge></span>}>
|
|
8
|
-
<div className="text-xs text-theme-text-secondary">Reason: {c.reason || 'Not reported'}</div>
|
|
9
|
-
<div className="break-words text-xs text-theme-text-secondary">{c.message || 'No message reported'}</div>
|
|
10
|
-
<div className="text-xs text-theme-text-tertiary">Last transition: {c.lastTransitionTime ? <Tooltip content={c.lastTransitionTime}><time dateTime={c.lastTransitionTime}>{formatAge(c.lastTransitionTime)} ago</time></Tooltip> : 'Not reported'}</div>
|
|
11
|
-
</FactRow>)}</FactGrid>
|
|
12
|
-
{conditions.length === 0 && <p className="text-sm text-theme-text-tertiary">The operator has not reported status.conditions.</p>}
|
|
13
|
-
</FoldSection>
|
|
14
|
-
</section>
|
|
15
|
-
)
|
|
4
|
+
export function CNPGOperatorConditions(props: Pick<ComponentProps<typeof WorkspaceConditions>, 'conditions'>) {
|
|
5
|
+
return <WorkspaceConditions {...props} title="Operator conditions" className="mx-4 mb-4" emptyMessage="The operator has not reported status.conditions." />
|
|
16
6
|
}
|
|
@@ -7,7 +7,8 @@ const sidebar = vi.hoisted(() => ({ data: undefined as CNPGWorkspaceResponse | u
|
|
|
7
7
|
vi.mock('../../api/cnpg', () => ({ useCNPGWorkspace: () => ({ data: sidebar.data }) }))
|
|
8
8
|
vi.mock('../../api/cnpg-storage', () => ({ useCNPGFleetDisk: () => ({}) }))
|
|
9
9
|
vi.mock('../../api/cnpg-history', () => ({ useCNPGFleetMetrics: () => ({}) }))
|
|
10
|
-
vi.
|
|
10
|
+
const feature = vi.hoisted(() => ({ value: { support: 'supported', upgrade: null } as { support: string; upgrade: { feature: string; minimumVersion?: string } | null } }))
|
|
11
|
+
vi.mock('../../api/client', () => ({ useRadarFeature: () => feature.value }))
|
|
11
12
|
|
|
12
13
|
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'kind-test' } }) }))
|
|
13
14
|
vi.mock('./CNPGOperatorBanner', () => ({ CNPGOperatorBanner: () => null }))
|
|
@@ -23,8 +24,8 @@ const cluster = (namespace: string, name: string) => ({
|
|
|
23
24
|
status: { phase: 'Cluster in healthy state', readyInstances: 1 },
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
function response(clusters: ReturnType<typeof cluster>[], coverage: CNPGKindCoverage = { state: 'full' }): CNPGWorkspaceResponse {
|
|
27
|
-
return { installed: true, context: 'kind-test', namespaces: null, coverage: { clusters: coverage }, objects: { clusters }, issues: [], audit
|
|
27
|
+
function response(clusters: ReturnType<typeof cluster>[], coverage: CNPGKindCoverage = { state: 'full' }, audit: CNPGWorkspaceResponse['audit'] = []): CNPGWorkspaceResponse {
|
|
28
|
+
return { installed: true, context: 'kind-test', namespaces: null, coverage: { clusters: coverage }, objects: { clusters }, issues: [], audit, backupsOmitted: 0 }
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
function render(resp: CNPGWorkspaceResponse, query = '', opts: { attention?: string[]; onCreate?: () => void; namespaces?: string[] } = {}) {
|
|
@@ -169,3 +170,74 @@ it('uses an unknown sidebar count and tooltip for zero over partial coverage', (
|
|
|
169
170
|
expect(result.value!.CloudNativePG.destinations.find((d) => d.id === 'protection')!.count).toBe(0)
|
|
170
171
|
sidebar.data = undefined
|
|
171
172
|
})
|
|
173
|
+
|
|
174
|
+
describe('CNPGOverview posture summary', () => {
|
|
175
|
+
const withSpec = (name: string, spec: { instances: number } & Record<string, unknown>) => ({ ...cluster('pg', name), spec })
|
|
176
|
+
const finding = (name: string, checkId: string) => ({ checkId, severity: 'warning', kind: 'Cluster', namespace: 'pg', name, message: checkId })
|
|
177
|
+
const count = (html: string, label: string) => html.match(new RegExp(`${label}</span><span[^>]*>([^<]+)<`))?.[1]
|
|
178
|
+
const bareAndIntree = () => response(
|
|
179
|
+
[withSpec('bare', { instances: 1 }), withSpec('intree', { instances: 3, backup: { barmanObjectStore: { destinationPath: 's3://b' } } })],
|
|
180
|
+
{ state: 'full' },
|
|
181
|
+
[finding('bare', 'cnpgNoBackupDestination'), finding('bare', 'cnpgSingleInstance'), finding('intree', 'cnpgInTreeBackupDeprecated')],
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
it("counts the Checks' findings above the table, in neutral text", () => {
|
|
185
|
+
const html = render(bareAndIntree())
|
|
186
|
+
expect(count(html, 'No backup destination')).toBe('1')
|
|
187
|
+
expect(count(html, 'Single instance')).toBe('1')
|
|
188
|
+
expect(count(html, 'In-tree backup')).toBe('1')
|
|
189
|
+
expect(count(html, 'No WAL archiving')).toBe('0')
|
|
190
|
+
expect(html).toMatch(/<div role="group"[^>]*aria-label="Backup and availability configuration"/)
|
|
191
|
+
expect(html).toMatch(/Single instance<\/span><span class="font-mono">1</)
|
|
192
|
+
expect(html).not.toContain('With a destination')
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('does not count a single-instance spec that Checks reports nothing for', () => {
|
|
196
|
+
const html = render(response([withSpec('a', { instances: 1 }), withSpec('b', { instances: 1 })], { state: 'full' }, [finding('a', 'cnpgSingleInstance')]))
|
|
197
|
+
expect(count(html, 'Single instance')).toBe('1')
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('narrows the table to one posture value, with a chip to clear it', () => {
|
|
201
|
+
const html = render(bareAndIntree(), 'protect=none')
|
|
202
|
+
expect(html).toContain('bare')
|
|
203
|
+
expect(html).not.toContain('>intree<')
|
|
204
|
+
expect(html).toContain('Posture: No backup destination')
|
|
205
|
+
expect(html).toMatch(/aria-pressed="true"[^>]*><span>No backup destination/)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('shows counts as lower bounds when Clusters were partly read', () => {
|
|
209
|
+
const html = render(response([withSpec('a', { instances: 1 }), withSpec('b', { instances: 1 })], { state: 'partial', allowedNamespaces: ['pg'] } as CNPGKindCoverage, [finding('a', 'cnpgSingleInstance'), finding('b', 'cnpgSingleInstance')]))
|
|
210
|
+
expect(count(html, 'Single instance')).toBe('≥2')
|
|
211
|
+
expect(count(html, 'No WAL archiving')).toBe('–')
|
|
212
|
+
expect(html).toContain('aria-label="No WAL archiving: unknown"')
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
it('ignores an unknown protect value', () => {
|
|
216
|
+
const html = render(bareAndIntree(), 'protect=bogus')
|
|
217
|
+
expect(html).toContain('bare')
|
|
218
|
+
expect(html).toContain('intree')
|
|
219
|
+
expect(html).not.toContain('Posture:')
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('says the filters, not attention, emptied the table when posture narrows it to nothing', () => {
|
|
223
|
+
const html = render(response([withSpec('a', { instances: 3 })]), 'filter=attention&protect=intree', { attention: ['a'] })
|
|
224
|
+
expect(html).toContain('No clusters match these filters')
|
|
225
|
+
expect(html).not.toContain('No clusters need attention')
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('replaces the counts with an upgrade note on a Radar that predates them, never a zero', () => {
|
|
229
|
+
feature.value = { support: 'unsupported', upgrade: { feature: 'CloudNativePG backup and availability counts', minimumVersion: 'v1.21.0' } }
|
|
230
|
+
try {
|
|
231
|
+
const html = render(bareAndIntree())
|
|
232
|
+
expect(html).toContain('CloudNativePG backup and availability counts')
|
|
233
|
+
expect(html).toContain('need Radar v1.21 or newer')
|
|
234
|
+
expect(html).not.toContain('Backup and availability configuration')
|
|
235
|
+
expect(render(bareAndIntree(), 'protect=none')).toContain('>intree<')
|
|
236
|
+
const loading = (feature.value = { support: 'unknown', upgrade: null }, render(bareAndIntree()))
|
|
237
|
+
expect(loading).not.toContain('Backup and availability configuration')
|
|
238
|
+
expect(loading).not.toContain('need Radar')
|
|
239
|
+
} finally {
|
|
240
|
+
feature.value = { support: 'supported', upgrade: null }
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
})
|
|
@@ -4,19 +4,25 @@ import { ArrowRight, Database, FileText, Plus, Search } from 'lucide-react'
|
|
|
4
4
|
import {
|
|
5
5
|
CNPG_PROBLEM_CATEGORIES,
|
|
6
6
|
CNPG_PROBLEM_TONE,
|
|
7
|
+
CNPG_POSTURE_FILTERS,
|
|
7
8
|
cnpgDimensions,
|
|
9
|
+
cnpgMatchesPostureFilter,
|
|
8
10
|
cnpgReadyInstances,
|
|
9
11
|
FactValue,
|
|
12
|
+
RadarUpgradeNote,
|
|
10
13
|
StatusDot,
|
|
11
14
|
Tooltip,
|
|
12
15
|
toneTextClass,
|
|
13
16
|
usePhoneLayout,
|
|
17
|
+
type CNPGFleetPosture,
|
|
14
18
|
type CNPGFleetRow,
|
|
19
|
+
type CNPGPostureFilter,
|
|
15
20
|
type CNPGProblemCategory,
|
|
16
21
|
} from '@skyhook-io/k8s-ui'
|
|
17
22
|
import type { SelectedResource } from '../../types'
|
|
18
23
|
import { useConnection } from '../../context/ConnectionContext'
|
|
19
24
|
import { getApiBase } from '../../api/config'
|
|
25
|
+
import { useRadarFeature } from '../../api/client'
|
|
20
26
|
import { CNPGWorkspaceHeader, CoverageNotice, coverageEmpty, type CNPGScreenProps } from './shared'
|
|
21
27
|
import { cnpgClusterFullPath, cnpgClusterProblemsPath } from './paths'
|
|
22
28
|
import { currentPageLabel } from '../../utils/page-links'
|
|
@@ -189,6 +195,46 @@ function AttentionCell({ row, onOpenAll }: { row: CNPGFleetRow; onOpenAll: () =>
|
|
|
189
195
|
)
|
|
190
196
|
}
|
|
191
197
|
|
|
198
|
+
const POSTURE_LABELS: Record<CNPGPostureFilter, string> = {
|
|
199
|
+
none: 'No backup destination',
|
|
200
|
+
nowal: 'No WAL archiving',
|
|
201
|
+
single: 'Single instance',
|
|
202
|
+
intree: 'In-tree backup',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Clusters with each posture Check's finding, as Checks reports them. Each count narrows the table.
|
|
206
|
+
function PostureSummary({ posture, lowerBound, active, onToggle }: {
|
|
207
|
+
posture: CNPGFleetPosture
|
|
208
|
+
lowerBound: boolean
|
|
209
|
+
active: CNPGPostureFilter | null
|
|
210
|
+
onToggle: (filter: CNPGPostureFilter) => void
|
|
211
|
+
}) {
|
|
212
|
+
// Posture is stated without a mark, as on every CNPG surface: no tone on the counts.
|
|
213
|
+
return (
|
|
214
|
+
<div role="group" className="flex flex-wrap items-center gap-2 text-xs" aria-label="Backup and availability configuration">
|
|
215
|
+
{CNPG_POSTURE_FILTERS.map((id) => {
|
|
216
|
+
const value = posture[id]
|
|
217
|
+
const text = lowerBound ? value === 0 ? '–' : `≥${value}` : String(value)
|
|
218
|
+
const on = active === id
|
|
219
|
+
return (
|
|
220
|
+
<button
|
|
221
|
+
key={id}
|
|
222
|
+
type="button"
|
|
223
|
+
aria-pressed={on}
|
|
224
|
+
aria-label={`${POSTURE_LABELS[id]}: ${lowerBound && value === 0 ? 'unknown' : text}`}
|
|
225
|
+
disabled={value === 0 && !on}
|
|
226
|
+
onClick={() => onToggle(id)}
|
|
227
|
+
className={clsx(
|
|
228
|
+
'inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 transition-colors',
|
|
229
|
+
on ? 'border-accent bg-accent-muted text-accent-text' : 'border-theme-border text-theme-text-secondary enabled:hover:bg-theme-hover disabled:opacity-60',
|
|
230
|
+
)}
|
|
231
|
+
><span>{POSTURE_LABELS[id]}</span><span className="font-mono">{text}</span></button>
|
|
232
|
+
)
|
|
233
|
+
})}
|
|
234
|
+
</div>
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
|
|
192
238
|
export function CNPGOverview({
|
|
193
239
|
data,
|
|
194
240
|
fleet,
|
|
@@ -209,23 +255,28 @@ export function CNPGOverview({
|
|
|
209
255
|
const rawFilter = searchParams.get('filter') as Filter | null
|
|
210
256
|
// The view is the list of clusters: all of them unless asked for less.
|
|
211
257
|
const filter: Filter = rawFilter === 'attention' ? 'attention' : 'all'
|
|
258
|
+
// An older Radar's findings lack the posture Checks: its counts would read 0.
|
|
259
|
+
const postureFeature = useRadarFeature('cnpgPostureChecks')
|
|
260
|
+
const rawProtect = searchParams.get('protect')
|
|
261
|
+
const protect = postureFeature.support === 'supported' && (CNPG_POSTURE_FILTERS as readonly string[]).includes(rawProtect ?? '') ? rawProtect as CNPGPostureFilter : null
|
|
212
262
|
|
|
213
263
|
const rows = useMemo(() => {
|
|
214
264
|
let list = fleet.rows
|
|
215
265
|
if (filter === 'attention') list = list.filter((r) => r.attention)
|
|
216
266
|
if (cat) list = list.filter((r) => r.categories.has(cat))
|
|
267
|
+
if (protect) list = list.filter((r) => cnpgMatchesPostureFilter(r, protect))
|
|
217
268
|
if (q) {
|
|
218
269
|
const needle = q.toLowerCase()
|
|
219
270
|
list = list.filter((r) => r.name.toLowerCase().includes(needle) || r.namespace.toLowerCase().includes(needle))
|
|
220
271
|
}
|
|
221
272
|
return list
|
|
222
|
-
}, [fleet, filter, cat, q])
|
|
273
|
+
}, [fleet, filter, cat, protect, q])
|
|
223
274
|
|
|
224
275
|
const clustersCov = data.coverage.clusters
|
|
225
276
|
const total = fleet.rows.length
|
|
226
277
|
const context = connection.context || data.context
|
|
227
278
|
// Some namespaces were not read: the count is a floor, not the cluster's total.
|
|
228
|
-
const totalText = `${
|
|
279
|
+
const totalText = `${fleet.incompleteKinds.includes('clusters') ? '≥' : ''}${total}`
|
|
229
280
|
// No cluster authoring on a phone (a YAML editor follows the dialog).
|
|
230
281
|
const isPhone = usePhoneLayout()
|
|
231
282
|
const createAction = onCreate && !isPhone ? (
|
|
@@ -270,6 +321,7 @@ export function CNPGOverview({
|
|
|
270
321
|
|
|
271
322
|
const chips: { label: string; onClear: () => void }[] = []
|
|
272
323
|
if (cat) chips.push({ label: `Problem: ${CNPG_PROBLEM_CATEGORIES.find((c) => c.id === cat)?.label ?? cat}`, onClear: () => onSetParams({ cat: null }) })
|
|
324
|
+
if (protect) chips.push({ label: `Posture: ${POSTURE_LABELS[protect]}`, onClear: () => onSetParams({ protect: null }) })
|
|
273
325
|
if (q) chips.push({ label: `Search: ${q}`, onClear: () => onSetParams({ q: null }) })
|
|
274
326
|
if (namespaces.length > 0) chips.push({ label: `Namespace: ${namespaces.join(', ')}`, onClear: onClearNamespaces })
|
|
275
327
|
|
|
@@ -314,6 +366,12 @@ export function CNPGOverview({
|
|
|
314
366
|
<CoverageNotice fleet={fleet} data={data} kinds={['clusters', 'pods', 'backups', 'scheduledBackups', 'objectStores', 'poolers', 'databases', 'databaseRoles', 'publications', 'subscriptions']} includeJobs />
|
|
315
367
|
<CNPGOperatorBanner namespaces={fleet.rows.map((r) => r.namespace)} className="" />
|
|
316
368
|
|
|
369
|
+
{postureFeature.upgrade ? (
|
|
370
|
+
<RadarUpgradeNote requirement={postureFeature.upgrade} />
|
|
371
|
+
) : postureFeature.support === 'supported' ? (
|
|
372
|
+
<PostureSummary posture={fleet.posture} lowerBound={fleet.incompleteKinds.includes('clusters')} active={protect} onToggle={(f) => onSetParams({ protect: protect === f ? null : f })} />
|
|
373
|
+
) : null}
|
|
374
|
+
|
|
317
375
|
<div className="flex flex-wrap items-center gap-2">
|
|
318
376
|
<div role="tablist" aria-label="Clusters" className="inline-flex rounded-lg bg-theme-elevated p-0.5">
|
|
319
377
|
{segment('all', 'All clusters', totalText)}
|
|
@@ -469,10 +527,10 @@ export function CNPGOverview({
|
|
|
469
527
|
</div>
|
|
470
528
|
{rows.length === 0 && (
|
|
471
529
|
<div className="px-4 py-6 text-sm text-theme-text-tertiary">
|
|
472
|
-
{filter === 'attention' && !cat && !q
|
|
530
|
+
{filter === 'attention' && !cat && !q && !protect
|
|
473
531
|
? lowerBound ? 'No attention findings in the readable data; other data was not read.' : 'No clusters need attention.'
|
|
474
532
|
: 'No clusters match these filters.'}{' '}
|
|
475
|
-
<button type="button" onClick={() => onSetParams({ filter: 'all', cat: null, q: null })} className="font-medium text-accent-text hover:underline">
|
|
533
|
+
<button type="button" onClick={() => onSetParams({ filter: 'all', cat: null, q: null, protect: null })} className="font-medium text-accent-text hover:underline">
|
|
476
534
|
Show all clusters
|
|
477
535
|
</button>
|
|
478
536
|
</div>
|
|
@@ -46,6 +46,7 @@ interface HomeViewProps {
|
|
|
46
46
|
namespaces: string[]
|
|
47
47
|
topology: Topology | null
|
|
48
48
|
onNavigateToView: (view: ExtendedMainView, params?: Record<string, string>) => void
|
|
49
|
+
onNavigateToIssue?: (id: string) => void
|
|
49
50
|
onNavigateToResourceKind: (kind: string, group?: string, filters?: Record<string, string[]>) => void
|
|
50
51
|
onNavigateToResource: (resource: SelectedResource) => void
|
|
51
52
|
fallbackClusterLoadState?: ClusterLoadState
|
|
@@ -62,7 +63,7 @@ interface HomeViewProps {
|
|
|
62
63
|
onNavigateToManagerPath?: (path: string) => void
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
|
|
66
|
+
export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToIssue, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
|
|
66
67
|
// The card itself decides whether the cluster has a capacity story
|
|
67
68
|
// (available, softened-denied, or karpenterless-with-managers/groups) and
|
|
68
69
|
// returns null otherwise — the outer gate only excludes states with nothing
|
|
@@ -290,6 +291,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
290
291
|
error={issuesError}
|
|
291
292
|
totalReturned={issues.length}
|
|
292
293
|
onNavigateToIssues={() => onNavigateToView('issues')}
|
|
294
|
+
onNavigateToIssue={onNavigateToIssue}
|
|
293
295
|
onResourceClick={onNavigateToResource}
|
|
294
296
|
/>
|
|
295
297
|
</div>
|
|
@@ -343,6 +345,7 @@ interface ProblemsPanelProps {
|
|
|
343
345
|
error: unknown
|
|
344
346
|
totalReturned: number
|
|
345
347
|
onNavigateToIssues: () => void
|
|
348
|
+
onNavigateToIssue?: (id: string) => void
|
|
346
349
|
onResourceClick: (resource: SelectedResource) => void
|
|
347
350
|
}
|
|
348
351
|
|
|
@@ -358,6 +361,7 @@ export function ProblemsPanel({
|
|
|
358
361
|
error,
|
|
359
362
|
totalReturned,
|
|
360
363
|
onNavigateToIssues,
|
|
364
|
+
onNavigateToIssue,
|
|
361
365
|
onResourceClick,
|
|
362
366
|
}: ProblemsPanelProps) {
|
|
363
367
|
const unchecked = uncheckedLines.length > 0
|
|
@@ -475,6 +479,10 @@ export function ProblemsPanel({
|
|
|
475
479
|
className="w-full flex items-center gap-2 px-3 py-1.5 group-hover:bg-theme-hover group-has-[:focus-visible]:bg-theme-hover transition-colors text-left"
|
|
476
480
|
onClick={() => {
|
|
477
481
|
recordUsageEvent({ type: 'ui', name: 'issue_action:open' })
|
|
482
|
+
if (onNavigateToIssue) {
|
|
483
|
+
onNavigateToIssue(issue.id)
|
|
484
|
+
return
|
|
485
|
+
}
|
|
478
486
|
onResourceClick({
|
|
479
487
|
kind: ref.kind,
|
|
480
488
|
namespace: ref.namespace ?? '',
|
|
@@ -78,4 +78,41 @@ describe("NetworkPolicyCoverageCard", () => {
|
|
|
78
78
|
expect(html).not.toContain("if staged");
|
|
79
79
|
expect(html).not.toContain("repeating-linear-gradient");
|
|
80
80
|
});
|
|
81
|
+
|
|
82
|
+
it("says which workloads the totals leave out", () => {
|
|
83
|
+
const html = render(
|
|
84
|
+
<NetworkPolicyCoverageCard
|
|
85
|
+
data={{
|
|
86
|
+
totalPolicies: 1,
|
|
87
|
+
coveredWorkloads: 1,
|
|
88
|
+
totalWorkloads: 3,
|
|
89
|
+
ignoredNamespaceWorkloads: 6,
|
|
90
|
+
hostNetworkWorkloads: 1,
|
|
91
|
+
}}
|
|
92
|
+
onNavigate={() => {}}
|
|
93
|
+
/>,
|
|
94
|
+
);
|
|
95
|
+
expect(html).toContain("7 not counted");
|
|
96
|
+
|
|
97
|
+
const none = render(
|
|
98
|
+
<NetworkPolicyCoverageCard
|
|
99
|
+
data={{ totalPolicies: 1, coveredWorkloads: 1, totalWorkloads: 3 }}
|
|
100
|
+
onNavigate={() => {}}
|
|
101
|
+
/>,
|
|
102
|
+
);
|
|
103
|
+
expect(none).not.toContain("not counted");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("does not show 0% coverage when no workloads are counted", () => {
|
|
107
|
+
const html = render(
|
|
108
|
+
<NetworkPolicyCoverageCard
|
|
109
|
+
data={{ totalPolicies: 2, coveredWorkloads: 0, totalWorkloads: 0, ignoredNamespaceWorkloads: 3 }}
|
|
110
|
+
onNavigate={() => {}}
|
|
111
|
+
/>,
|
|
112
|
+
);
|
|
113
|
+
expect(html).toContain("No workloads counted");
|
|
114
|
+
expect(html).toContain("3 not counted");
|
|
115
|
+
expect(html).not.toContain("0%");
|
|
116
|
+
expect(html).not.toContain("text-red-500");
|
|
117
|
+
});
|
|
81
118
|
});
|