fix: resolve eslint errors and apply formatting to match shared config

Auto-fix import ordering, quote style, and indentation via eslint --fix
and prettier --write. Remove unused variable in NodesPage and PodsPage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
DevContainer User
2026-03-04 11:50:29 +00:00
parent 034e0b9db8
commit 488bf90abc
14 changed files with 288 additions and 210 deletions
+7 -3
View File
@@ -116,9 +116,11 @@ export function IntelGpuDataProvider({ children }: { children: React.ReactNode }
// Intel device plugins operator deployment
`/api/v1/pods?labelSelector=${encodeURIComponent('app=intel-gpu-plugin')}`,
// Alternative: by component label
`/api/v1/pods?labelSelector=${encodeURIComponent('app.kubernetes.io/name=intel-gpu-plugin')}`,
`/api/v1/pods?labelSelector=${encodeURIComponent(
'app.kubernetes.io/name=intel-gpu-plugin'
)}`,
// Intel device plugins from inteldeviceplugins-system namespace
`/api/v1/namespaces/inteldeviceplugins-system/pods`,
'/api/v1/namespaces/inteldeviceplugins-system/pods',
];
const foundPluginPods: IntelGpuPod[] = [];
@@ -155,7 +157,9 @@ export function IntelGpuDataProvider({ children }: { children: React.ReactNode }
}
void fetchAsync();
return () => { cancelled = true; };
return () => {
cancelled = true;
};
}, [refreshKey]);
// ---------------------------------------------------------------------------
+4 -8
View File
@@ -12,18 +12,18 @@ import {
getNodeGpuCount,
getNodeGpuType,
getPodGpuRequests,
type GpuDevicePlugin,
INTEL_GPU_NODE_LABEL,
INTEL_GPU_RESOURCE,
INTEL_GPU_XE_RESOURCE,
type IntelGpuNode,
type IntelGpuPod,
isGpuRequestingPod,
isIntelGpuNode,
isKubeList,
isNodeReady,
pluginStatusText,
pluginStatusToStatus,
type GpuDevicePlugin,
type IntelGpuNode,
type IntelGpuPod,
} from './k8s';
// ---------------------------------------------------------------------------
@@ -413,11 +413,7 @@ describe('formatGpuType', () => {
// ---------------------------------------------------------------------------
describe('pluginStatusToStatus', () => {
function makePlugin(
desired: number,
ready: number,
unavailable = 0
): GpuDevicePlugin {
function makePlugin(desired: number, ready: number, unavailable = 0): GpuDevicePlugin {
return {
apiVersion: 'deviceplugin.intel.com/v1',
kind: 'GpuDevicePlugin',
+21 -28
View File
@@ -28,8 +28,7 @@ export const INTEL_DISCRETE_GPU_NODE_ROLE = 'node-role.kubernetes.io/gpu';
export const INTEL_INTEGRATED_GPU_NODE_ROLE = 'node-role.kubernetes.io/igpu';
/** Label selector for Intel GPU device plugin DaemonSet pods */
export const INTEL_GPU_PLUGIN_LABEL_SELECTOR =
'app=intel-gpu-plugin';
export const INTEL_GPU_PLUGIN_LABEL_SELECTOR = 'app=intel-gpu-plugin';
// ---------------------------------------------------------------------------
// Generic Kubernetes object base shapes
@@ -194,9 +193,12 @@ export function getNodeGpuType(node: IntelGpuNode): GpuType {
export function formatGpuType(type: GpuType): string {
switch (type) {
case 'discrete': return 'Discrete';
case 'integrated': return 'Integrated';
default: return 'Unknown';
case 'discrete':
return 'Discrete';
case 'integrated':
return 'Integrated';
default:
return 'Unknown';
}
}
@@ -272,9 +274,11 @@ export function isIntelGpuPluginPod(pod: unknown): pod is IntelGpuPod {
const meta = obj['metadata'] as Record<string, unknown> | undefined;
const labels = meta?.['labels'] as Record<string, string> | undefined;
if (!labels) return false;
return labels['app'] === 'intel-gpu-plugin' ||
(labels['app.kubernetes.io/name'] === 'intel-gpu-plugin') ||
(labels['component'] === 'intel-gpu-plugin');
return (
labels['app'] === 'intel-gpu-plugin' ||
labels['app.kubernetes.io/name'] === 'intel-gpu-plugin' ||
labels['component'] === 'intel-gpu-plugin'
);
}
export function filterIntelGpuPluginPods(items: unknown[]): IntelGpuPod[] {
@@ -284,10 +288,7 @@ export function filterIntelGpuPluginPods(items: unknown[]): IntelGpuPod[] {
/** Get total GPU requests from a pod's containers */
export function getPodGpuRequests(pod: IntelGpuPod): Record<string, string> {
const totals: Record<string, number> = {};
const allContainers = [
...(pod.spec?.containers ?? []),
...(pod.spec?.initContainers ?? []),
];
const allContainers = [...(pod.spec?.containers ?? []), ...(pod.spec?.initContainers ?? [])];
for (const c of allContainers) {
const requests = c.resources?.requests ?? {};
for (const [key, value] of Object.entries(requests)) {
@@ -300,15 +301,11 @@ export function getPodGpuRequests(pod: IntelGpuPod): Record<string, string> {
}
export function isPodReady(pod: IntelGpuPod): boolean {
return (
pod.status?.conditions?.some(c => c.type === 'Ready' && c.status === 'True') ?? false
);
return pod.status?.conditions?.some(c => c.type === 'Ready' && c.status === 'True') ?? false;
}
export function getPodRestarts(pod: IntelGpuPod): number {
return (
pod.status?.containerStatuses?.reduce((sum, c) => sum + c.restartCount, 0) ?? 0
);
return pod.status?.containerStatuses?.reduce((sum, c) => sum + c.restartCount, 0) ?? 0;
}
// ---------------------------------------------------------------------------
@@ -330,9 +327,7 @@ export function isKubeList(value: unknown): value is KubeList<unknown> {
// ---------------------------------------------------------------------------
export function isNodeReady(node: IntelGpuNode): boolean {
return (
node.status?.conditions?.some(c => c.type === 'Ready' && c.status === 'True') ?? false
);
return node.status?.conditions?.some(c => c.type === 'Ready' && c.status === 'True') ?? false;
}
// ---------------------------------------------------------------------------
@@ -359,11 +354,11 @@ export function formatAge(timestamp: string | undefined): string {
export function formatGpuResourceName(resourceKey: string): string {
const name = resourceKey.replace(INTEL_GPU_RESOURCE_PREFIX, '');
const map: Record<string, string> = {
'i915': 'GPU (i915)',
'xe': 'GPU (Xe)',
'millicores': 'GPU Millicores',
i915: 'GPU (i915)',
xe: 'GPU (Xe)',
millicores: 'GPU Millicores',
'memory.max': 'GPU Memory (max)',
'tiles': 'GPU Tiles',
tiles: 'GPU Tiles',
};
return map[name] ?? name;
}
@@ -372,9 +367,7 @@ export function formatGpuResourceName(resourceKey: string): string {
// Status helpers
// ---------------------------------------------------------------------------
export function pluginStatusToStatus(
plugin: GpuDevicePlugin
): 'success' | 'warning' | 'error' {
export function pluginStatusToStatus(plugin: GpuDevicePlugin): 'success' | 'warning' | 'error' {
const desired = plugin.status?.desiredNumberScheduled ?? 0;
const ready = plugin.status?.numberReady ?? 0;
const unavailable = plugin.status?.numberUnavailable ?? 0;
+5 -6
View File
@@ -64,14 +64,11 @@ const PROMETHEUS_SERVICES = [
{ namespace: 'monitoring', service: 'prometheus', port: '9090' },
];
async function queryPrometheus(
query: string,
prometheusPath: string
): Promise<PrometheusResult[]> {
async function queryPrometheus(query: string, prometheusPath: string): Promise<PrometheusResult[]> {
const encoded = encodeURIComponent(query);
const path = `${prometheusPath}/api/v1/query?query=${encoded}`;
const raw = await ApiProxy.request(path, { method: 'GET' }) as PrometheusResponse;
const raw = (await ApiProxy.request(path, { method: 'GET' })) as PrometheusResponse;
if (raw?.status !== 'success') return [];
return raw.data?.result ?? [];
@@ -81,7 +78,9 @@ async function findPrometheusPath(): Promise<string | null> {
for (const { namespace, service, port } of PROMETHEUS_SERVICES) {
const basePath = `/api/v1/namespaces/${namespace}/services/${service}:${port}/proxy`;
try {
const raw = await ApiProxy.request(`${basePath}/api/v1/query?query=1`, { method: 'GET' }) as PrometheusResponse;
const raw = (await ApiProxy.request(`${basePath}/api/v1/query?query=1`, {
method: 'GET',
})) as PrometheusResponse;
if (raw?.status === 'success') return basePath;
} catch {
// try next