Skip to content

Commit

Permalink
feat(kiali): changes to Kiali 1.86 (janus-idp#1839)
Browse files Browse the repository at this point in the history
* feat(kiali): adapt to 1.86

* feat(kiali): Update workloads api

* feat(kiali): per cluster apps and services

* feat(kiali): add istio config list

* feat(kiali): add changes to dev

* feat(kiali): Remove test file

* feat(kiali): Fix yarn tests

* feat(kiali): fix lint issues

* feat(kiali): Fix context load issue

* feat(kiali): Fix context load issue

* feat(kiali): Add dev data

* feat(kiali): Update mocks

* feat(kiali): fix health

* feat(kiali): update fixture data
  • Loading branch information
josunect committed Jun 27, 2024
1 parent 66051e3 commit ab1f6bc
Show file tree
Hide file tree
Showing 30 changed files with 4,441 additions and 972 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const kialiApi = new KialiApiImpl({
describe('kiali Api Connector', () => {
describe('Validate suported version', () => {
it('Plugin support the version', () => {
const versionsToTest = ['v1.73', 'v1.73.6'];
const versionsToTest = ['v1.86', 'v1.86.0'];
versionsToTest.forEach(version => {
const support = kialiApi.supportedVersion(version);
expect(support).toBeUndefined();
Expand Down
2 changes: 1 addition & 1 deletion plugins/kiali-backend/src/kiali_supported.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"Kiali version": "v1.73"
"Kiali version": "v1.86"
}
38 changes: 5 additions & 33 deletions plugins/kiali-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,11 @@ describe('createRouter', () => {
const result = await request(app).post('/status');
expect(result.status).toBe(200);
expect(result.body).toEqual({
status: {
'Kiali commit hash': '72a2496cb4ed1545457a68e34fe3e81409b1611d',
'Kiali container version': 'v1.73.0-SNAPSHOT',
'Kiali state': 'running',
'Kiali version': 'v1.73.0-SNAPSHOT',
'Mesh name': 'Istio',
'Mesh version': '1.17.1',
},
externalServices: [
{
name: 'Istio',
version: '1.17.1',
},
{
name: 'Prometheus',
version: '2.34.0',
},
{
name: 'Kubernetes',
version: 'v1.26.3+b404935',
},
{
name: 'Grafana',
},
{
name: 'Jaeger',
},
],
warningMessages: [],
istioEnvironment: {
isMaistra: false,
istioAPIEnabled: true,
},
category: 'versionSupported',
message:
'Kiali version supported is v1.86, we found version v1.73.0-SNAPSHOT',
title: 'kiali version not supported',
verify: false,
});
});
});
Expand Down
246 changes: 127 additions & 119 deletions plugins/kiali/dev/MockProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
WorkloadHealth,
} from '../src/types/Health';
import { IstioConfigDetails } from '../src/types/IstioConfigDetails';
import { IstioConfigList, IstioConfigsMap } from '../src/types/IstioConfigList';
import { IstioConfigList } from '../src/types/IstioConfigList';
import {
CanaryUpgradeStatus,
OutboundTrafficPolicy,
Expand All @@ -56,10 +56,8 @@ import { StatusState } from '../src/types/StatusState';
import { TLSStatus } from '../src/types/TLSStatus';
import { Span, TracingQuery } from '../src/types/Tracing';
import {
ClusterWorkloadsResponse,
Workload,
WorkloadListItem,
WorkloadNamespaceResponse,
WorkloadOverview,
WorkloadQuery,
} from '../src/types/Workload';
import { filterNsByAnnotation } from '../src/utils/entityFilter';
Expand Down Expand Up @@ -95,35 +93,12 @@ export class MockKialiClient implements KialiApi {
);
}

async getWorkloads(
namespace: string,
duration: number,
): Promise<WorkloadListItem[]> {
const nsl = kialiData.workloads as WorkloadNamespaceResponse[];
// @ts-ignore
return nsl[namespace].workloads.map(
(w: WorkloadOverview): WorkloadListItem => {
return {
name: w.name,
namespace: namespace,
cluster: w.cluster,
type: w.type,
istioSidecar: w.istioSidecar,
istioAmbient: w.istioAmbient,
additionalDetailSample: undefined,
appLabel: w.appLabel,
versionLabel: w.versionLabel,
labels: w.labels,
istioReferences: w.istioReferences,
notCoveredAuthPolicy: w.notCoveredAuthPolicy,
health: WorkloadHealth.fromJson(namespace, w.name, w.health, {
rateInterval: duration,
hasSidecar: w.istioSidecar,
hasAmbient: w.istioAmbient,
}),
};
},
);
async getClustersWorkloads(
_namespaces: string,
_: AppListQuery,
_cluster?: string,
): Promise<ClusterWorkloadsResponse> {
return kialiData.clusters.kubernetes.workloads;
}

async getWorkload(
Expand Down Expand Up @@ -151,78 +126,6 @@ export class MockKialiClient implements KialiApi {
return kialiData.config;
}

async getNamespaceAppHealth(
namespace: string,
duration: DurationInSeconds,
cluster?: string,
queryTime?: TimeInSeconds,
): Promise<NamespaceAppHealth> {
const ret: NamespaceAppHealth = {};
const params: any = {
type: 'app',
rateInterval: `${String(duration)}s`,
queryTime: String(queryTime),
clusterName: cluster,
};
const data = kialiData.namespacesData[namespace].health[params.type];
Object.keys(data).forEach(k => {
ret[k] = AppHealth.fromJson(namespace, k, data[k], {
rateInterval: duration,
hasSidecar: true,
hasAmbient: false,
});
});
return ret;
}

async getNamespaceServiceHealth(
namespace: string,
duration: DurationInSeconds,
cluster?: string,
queryTime?: TimeInSeconds,
): Promise<NamespaceServiceHealth> {
const ret: NamespaceServiceHealth = {};
const params: any = {
type: 'service',
rateInterval: `${String(duration)}s`,
queryTime: String(queryTime),
clusterName: cluster,
};
const data = kialiData.namespacesData[namespace].health[params.type];
Object.keys(data).forEach(k => {
ret[k] = ServiceHealth.fromJson(namespace, k, data[k], {
rateInterval: duration,
hasSidecar: true,
hasAmbient: false,
});
});
return ret;
}

async getNamespaceWorkloadHealth(
namespace: string,
duration: DurationInSeconds,
cluster?: string,
queryTime?: TimeInSeconds,
): Promise<NamespaceWorkloadHealth> {
const ret: NamespaceWorkloadHealth = {};
const params: any = {
type: 'workload',
rateInterval: `${String(duration)}s`,
queryTime: String(queryTime),
clusterName: cluster,
};
const data = kialiData.namespacesData[namespace].health[params.type];
Object.keys(data).forEach(k => {
ret[k] = WorkloadHealth.fromJson(namespace, k, data[k], {
rateInterval: duration,
hasSidecar: true,
hasAmbient: false,
});
});
return ret;
}

async getNamespaceTls(
namespace: string,
cluster?: string,
Expand Down Expand Up @@ -263,17 +166,13 @@ export class MockKialiClient implements KialiApi {
}

async getAllIstioConfigs(
namespaces: string[],
objects: string[],
validate: boolean,
labelSelector: string,
workloadSelector: string,
cluster?: string,
): Promise<IstioConfigsMap> {
const params: any =
namespaces && namespaces.length > 0
? { namespaces: namespaces.join(',') }
: {};
): Promise<IstioConfigList> {
const params: any = {};
if (objects && objects.length > 0) {
params.objects = objects.join(',');
}
Expand Down Expand Up @@ -350,11 +249,119 @@ export class MockKialiClient implements KialiApi {
return kialiData.spanLogs;
}

async getServices(
namespace: string,
_?: ServiceListQuery,
async getClustersServices(
_namespaces: string,
_: ServiceListQuery,
__?: string,
): Promise<ServiceList> {
return kialiData.services[namespace];
return kialiData.clusters.kubernetes.services;
}

async getClustersAppHealth(
namespaces: string,
_: DurationInSeconds,
__?: string,
___?: TimeInSeconds,
): Promise<Map<string, NamespaceAppHealth>> {
const namespaceAppHealth =
kialiData.clusters.kubernetes.appsHealth.namespaceAppHealth;

const ret = new Map<string, NamespaceAppHealth>();
if (namespaceAppHealth) {
Object.keys(namespaceAppHealth).forEach(ns => {
if (!ret.get(ns)) {
ret.set(ns, {});
}
Object.keys(namespaceAppHealth[ns]).forEach(k => {
// @ts-ignore
if (namespaceAppHealth[ns][k]) {
// @ts-ignore
const conv = namespaceAppHealth[ns][k];
// @ts-ignore
const ah = AppHealth.fromJson(namespaces, k, conv, {
rateInterval: 60,
hasSidecar: true,
hasAmbient: false,
});
const nsAppHealth = ret.get(ns) || {};
nsAppHealth[k] = ah;
ret.set(ns, nsAppHealth);
}
});
});
}
return ret;
}

async getClustersServiceHealth(
namespaces: string,
_: DurationInSeconds,
__?: string,
___?: TimeInSeconds,
): Promise<Map<string, NamespaceServiceHealth>> {
const namespaceServiceHealth =
kialiData.clusters.kubernetes.servicesHealth.namespaceServiceHealth;
const ret = new Map<string, NamespaceServiceHealth>();
if (namespaceServiceHealth) {
Object.keys(namespaceServiceHealth).forEach(ns => {
if (!ret.get(ns)) {
ret.set(ns, {});
}
Object.keys(namespaceServiceHealth[ns]).forEach(k => {
// @ts-ignore
if (namespaceServiceHealth[ns][k]) {
// @ts-ignore
const conv = namespaceServiceHealth[ns][k];
// @ts-ignore
const sh = ServiceHealth.fromJson(namespaces, k, conv, {
rateInterval: 60,
hasSidecar: true,
hasAmbient: false,
});
// @ts-ignore
const nsSvcHealth = ret.get(ns) || {};
nsSvcHealth[k] = sh;
ret.set(ns, nsSvcHealth);
}
});
});
}
return ret;
}

async getClustersWorkloadHealth(
namespaces: string,
_: DurationInSeconds,
__?: string,
___?: TimeInSeconds,
): Promise<Map<string, NamespaceWorkloadHealth>> {
const namespaceWorkloadHealth =
kialiData.clusters.kubernetes.workloadsHealth.namespaceWorkloadHealth;
const ret = new Map<string, NamespaceWorkloadHealth>();
if (namespaceWorkloadHealth) {
Object.keys(namespaceWorkloadHealth).forEach(ns => {
if (!ret.get(ns)) {
ret.set(ns, {});
}
Object.keys(namespaceWorkloadHealth[ns]).forEach(k => {
// @ts-ignore
if (namespaceWorkloadHealth[ns][k]) {
// @ts-ignore
const conv = namespaceWorkloadHealth[ns][k];
// @ts-ignore
const wh = WorkloadHealth.fromJson(namespaces, k, conv, {
rateInterval: 60,
hasSidecar: true,
hasAmbient: false,
});
const nsWkHealth = ret.get(ns) || {};
nsWkHealth[k] = wh;
ret.set(ns, nsWkHealth);
}
});
});
}
return ret;
}

async getIstioConfigDetail(
Expand Down Expand Up @@ -391,11 +398,12 @@ export class MockKialiClient implements KialiApi {
return info;
}

getApps = async (
namespace: string,
_params: AppListQuery,
getClustersApps = async (
_namespaces: string,
_: AppListQuery,
__?: string,
): Promise<AppList> => {
return kialiData.apps[namespace];
return kialiData.clusters.kubernetes.apps;
};

getApp = async (
Expand Down
Loading

0 comments on commit ab1f6bc

Please sign in to comment.