Skip to content

Commit

Permalink
feat(kiali): revert changes to Kiali 1.86 (#1839) (#1876)
Browse files Browse the repository at this point in the history
Revert "feat(kiali): changes to Kiali 1.86 (#1839)"

This reverts commit ab1f6bc.
  • Loading branch information
josunect authored Jul 10, 2024
1 parent 8c327c7 commit c512b29
Show file tree
Hide file tree
Showing 30 changed files with 972 additions and 4,441 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.86', 'v1.86.0'];
const versionsToTest = ['v1.73', 'v1.73.6'];
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.86"
"Kiali version": "v1.73"
}
38 changes: 33 additions & 5 deletions plugins/kiali-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,39 @@ describe('createRouter', () => {
const result = await request(app).post('/status');
expect(result.status).toBe(200);
expect(result.body).toEqual({
category: 'versionSupported',
message:
'Kiali version supported is v1.86, we found version v1.73.0-SNAPSHOT',
title: 'kiali version not supported',
verify: false,
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,
},
});
});
});
Expand Down
246 changes: 119 additions & 127 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 } from '../src/types/IstioConfigList';
import { IstioConfigList, IstioConfigsMap } from '../src/types/IstioConfigList';
import {
CanaryUpgradeStatus,
OutboundTrafficPolicy,
Expand All @@ -56,8 +56,10 @@ 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 @@ -93,12 +95,35 @@ export class MockKialiClient implements KialiApi {
);
}

async getClustersWorkloads(
_namespaces: string,
_: AppListQuery,
_cluster?: string,
): Promise<ClusterWorkloadsResponse> {
return kialiData.clusters.kubernetes.workloads;
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 getWorkload(
Expand Down Expand Up @@ -126,6 +151,78 @@ 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 @@ -166,13 +263,17 @@ export class MockKialiClient implements KialiApi {
}

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

async getClustersServices(
_namespaces: string,
_: ServiceListQuery,
__?: string,
async getServices(
namespace: string,
_?: ServiceListQuery,
): Promise<ServiceList> {
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;
return kialiData.services[namespace];
}

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

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

getApp = async (
Expand Down
Loading

0 comments on commit c512b29

Please sign in to comment.