@hpcc-js/comms 3.5.2 → 3.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/comms",
3
- "version": "3.5.2",
3
+ "version": "3.6.1",
4
4
  "description": "hpcc-js - Communications",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.cjs",
@@ -84,6 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@hpcc-js/ddl-shim": "^3.0.0",
86
86
  "@hpcc-js/esbuild-plugins": "^1.4.1",
87
+ "@kubernetes/client-node": "1.0.0",
87
88
  "@types/d3-request": "1.0.9",
88
89
  "@types/d3-time-format": "2.3.4",
89
90
  "@types/node": "^18",
@@ -111,5 +112,5 @@
111
112
  "esp",
112
113
  "HPCC-Platform"
113
114
  ],
114
- "gitHead": "c93b72a99c4a1f6db5d08a6c17b85d436c68da55"
115
+ "gitHead": "75ee30be2da61c7fb5281d4b1d7f99f7016a4314"
115
116
  }
@@ -1,3 +1,3 @@
1
1
  export const PKG_NAME = "@hpcc-js/comms";
2
- export const PKG_VERSION = "3.5.2";
3
- export const BUILD_VERSION = "3.6.2";
2
+ export const PKG_VERSION = "3.6.1";
3
+ export const BUILD_VERSION = "3.7.1";
@@ -714,9 +714,13 @@ export class Workunit extends StateObject<UWorkunitState, IWorkunitState> implem
714
714
  case "cost":
715
715
  props[scopeProperty.Name] = +scopeProperty.RawValue / 1000000;
716
716
  break;
717
- case "cpu":
718
- case "skw":
719
717
  case "node":
718
+ props[scopeProperty.Name] = +scopeProperty.RawValue;
719
+ break;
720
+ case "skw":
721
+ props[scopeProperty.Name] = +scopeProperty.RawValue;
722
+ break;
723
+ case "cpu":
720
724
  case "ppm":
721
725
  case "ip":
722
726
  case "cy":
@@ -1,18 +1,71 @@
1
- import { CloudServiceBase, WsCloud } from "./wsdl/WsCloud/v1/WsCloud.ts";
1
+ import { scopedLogger } from "@hpcc-js/util";
2
+ import type { V1Pod } from "@kubernetes/client-node";
3
+ import type { WsCloud as WsCloudV1 } from "./wsdl/WsCloud/v1/WsCloud.ts";
4
+ import { CloudServiceBase, WsCloud } from "./wsdl/WsCloud/v1.02/WsCloud.ts";
5
+
6
+ const logger = scopedLogger("@hpcc-js/comms/services/wsCloud.ts");
2
7
 
3
8
  export {
4
9
  type WsCloud
5
10
  };
6
11
 
12
+ function isGetPODsResponse_v1_02(response: any): response is WsCloud.GetPODsResponse {
13
+ return response?.Pods !== undefined;
14
+ }
15
+
16
+ function mapPorts(pod: V1Pod): WsCloud.Port[] {
17
+ return pod.spec?.containers?.reduce((prev, curr) => {
18
+ curr.ports?.forEach(p => {
19
+ prev.push({
20
+ ContainerPort: p.containerPort,
21
+ Name: p.name,
22
+ Protocol: p.protocol
23
+ });
24
+ });
25
+ return prev;
26
+ }, [] as WsCloud.Port[]) ?? [];
27
+ }
28
+
29
+ function mapPods(pods: V1Pod[]): WsCloud.Pod[] {
30
+ return pods
31
+ .filter(pod => {
32
+ const labels = pod?.metadata?.labels ?? {};
33
+ return labels.hasOwnProperty("app.kubernetes.io/part-of") && labels["app.kubernetes.io/part-of"] === "HPCC-Platform";
34
+ })
35
+ .map((pod: V1Pod): WsCloud.Pod => {
36
+ const started = new Date(pod.metadata?.creationTimestamp);
37
+ return {
38
+ Name: pod.metadata.name,
39
+ Status: pod.status?.phase,
40
+ CreationTimestamp: started.toISOString(),
41
+ ContainerName: pod.status?.containerStatuses?.reduce((prev, curr) => {
42
+ if (curr.name) {
43
+ prev.push(curr.name);
44
+ } return prev;
45
+ }, [] as string[]).join(", ") ?? "",
46
+ ContainerCount: pod.spec?.containers?.length ?? 0,
47
+ ContainerReadyCount: pod.status?.containerStatuses?.reduce((prev, curr) => prev + (curr.ready ? 1 : 0), 0),
48
+ ContainerRestartCount: pod.status?.containerStatuses?.reduce((prev, curr) => prev + curr.restartCount, 0),
49
+ Ports: {
50
+ Port: mapPorts(pod)
51
+ },
52
+ };
53
+ })
54
+ ;
55
+ }
56
+
7
57
  export class CloudService extends CloudServiceBase {
8
58
 
9
- getPODs(): Promise<object[]> {
10
- return super.GetPODs({}).then((response) => {
59
+ getPODs(): Promise<WsCloud.Pod[]> {
60
+ return super.GetPODs({}).then((response: WsCloud.GetPODsResponse | WsCloudV1.GetPODsResponse) => {
61
+ if (isGetPODsResponse_v1_02(response)) {
62
+ return response.Pods?.Pod ?? [];
63
+ }
11
64
  try {
12
65
  const obj = typeof response.Result === "string" ? JSON.parse(response.Result) : response.Result;
13
- return obj?.items ?? [];
14
-
66
+ return mapPods(obj?.items ?? []);
15
67
  } catch (error) {
68
+ logger.error(`Error parsing V1Pods json '${(error instanceof Error ? error.message : String(error))}'`);
16
69
  return [];
17
70
  }
18
71
  });
@@ -1,5 +1,5 @@
1
1
  import { scopedLogger } from "@hpcc-js/util";
2
- import { LogaccessServiceBase, WsLogaccess } from "./wsdl/ws_logaccess/v1.05/ws_logaccess.ts";
2
+ import { LogaccessServiceBase, WsLogaccess } from "./wsdl/ws_logaccess/v1.08/ws_logaccess.ts";
3
3
 
4
4
  const logger = scopedLogger("@hpcc-js/comms/services/wsLogaccess.ts");
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { deepMixin, xml2json, XMLNode } from "@hpcc-js/util";
2
- import { WsWorkunits, WorkunitsServiceBase } from "./wsdl/WsWorkunits/v2/WsWorkunits.ts";
2
+ import { WsWorkunits, WorkunitsServiceBase } from "./wsdl/WsWorkunits/v2.02/WsWorkunits.ts";
3
3
  import { IConnection, IOptions } from "../connection.ts";
4
4
  import { ESPConnection } from "../espConnection.ts";
5
5
 
@@ -0,0 +1,77 @@
1
+ import { IConnection, IOptions } from "../../../../connection.ts";
2
+ import { Service } from "../../../../espConnection.ts";
3
+
4
+ export namespace WsCloud {
5
+
6
+ export type int = number;
7
+
8
+ export interface GetPODsRequest {
9
+
10
+ }
11
+
12
+ export interface Port {
13
+ ContainerPort: int;
14
+ Name: string;
15
+ Protocol: string;
16
+ }
17
+
18
+ export interface Ports {
19
+ Port: Port[];
20
+ }
21
+
22
+ export interface Pod {
23
+ Name: string;
24
+ Status: string;
25
+ CreationTimestamp: string;
26
+ ContainerName: string;
27
+ ContainerCount: int;
28
+ ContainerReadyCount: int;
29
+ ContainerRestartCount: int;
30
+ Ports: Ports;
31
+ }
32
+
33
+ export interface Pods {
34
+ Pod: Pod[];
35
+ }
36
+
37
+ export interface GetPODsResponse {
38
+ Pods: Pods;
39
+ }
40
+
41
+ export interface GetServicesRequest {
42
+
43
+ }
44
+
45
+ export interface GetServicesResponse {
46
+ Result: string;
47
+ }
48
+
49
+ export interface WsCloudPingRequest {
50
+
51
+ }
52
+
53
+ export interface WsCloudPingResponse {
54
+
55
+ }
56
+
57
+ }
58
+
59
+ export class CloudServiceBase extends Service {
60
+
61
+ constructor(optsConnection: IOptions | IConnection) {
62
+ super(optsConnection, "WsCloud", "1.02");
63
+ }
64
+
65
+ GetPODs(request: Partial<WsCloud.GetPODsRequest>): Promise<WsCloud.GetPODsResponse> {
66
+ return this._connection.send("GetPODs", request, "json", false, undefined, "GetPODsResponse");
67
+ }
68
+
69
+ GetServices(request: Partial<WsCloud.GetServicesRequest>): Promise<WsCloud.GetServicesResponse> {
70
+ return this._connection.send("GetServices", request, "json", false, undefined, "GetServicesResponse");
71
+ }
72
+
73
+ Ping(request: Partial<WsCloud.WsCloudPingRequest>): Promise<WsCloud.WsCloudPingResponse> {
74
+ return this._connection.send("Ping", request, "json", false, undefined, "WsCloudPingResponse");
75
+ }
76
+
77
+ }