|
18 | 18 |
|
19 | 19 | // module dependencies |
20 | 20 | const {Agent} = require('https'); |
| 21 | +const zlib = require('zlib'); |
21 | 22 | const axios = require('axios'); |
22 | 23 | const yaml = require('js-yaml'); |
23 | 24 | const base32 = require('base32'); |
@@ -76,6 +77,14 @@ const decodeName = (name, labels) => { |
76 | 77 | } |
77 | 78 | }; |
78 | 79 |
|
| 80 | +const decompressField = (val) => { |
| 81 | + if (val == null) { |
| 82 | + return null; |
| 83 | + } else { |
| 84 | + return JSON.parse(zlib.gunzipSync(Buffer.from(val, 'base64')).toString()); |
| 85 | + } |
| 86 | +}; |
| 87 | + |
79 | 88 | const convertState = (state, exitCode, retryDelaySec) => { |
80 | 89 | switch (state) { |
81 | 90 | case 'AttemptCreationPending': |
@@ -131,9 +140,9 @@ const convertFrameworkSummary = (framework) => { |
131 | 140 | appExitCode: completionStatus ? completionStatus.code : null, |
132 | 141 | virtualCluster: framework.metadata.labels ? framework.metadata.labels.virtualCluster : 'unknown', |
133 | 142 | totalGpuNumber: framework.metadata.annotations ? framework.metadata.annotations.totalGpuNumber : 0, |
134 | | - totalTaskNumber: framework.status.attemptStatus.taskRoleStatuses.reduce( |
135 | | - (num, statuses) => num + statuses.taskStatuses.length, 0), |
136 | | - totalTaskRoleNumber: framework.status.attemptStatus.taskRoleStatuses.length, |
| 143 | + totalTaskNumber: framework.spec.taskRoles.reduce( |
| 144 | + (num, spec) => num + spec.taskNumber, 0), |
| 145 | + totalTaskRoleNumber: framework.spec.taskRoles.length, |
137 | 146 | }; |
138 | 147 | }; |
139 | 148 |
|
@@ -184,6 +193,11 @@ const convertTaskDetail = async (taskStatus, ports, userName, jobName, taskRoleN |
184 | 193 | }; |
185 | 194 |
|
186 | 195 | const convertFrameworkDetail = async (framework) => { |
| 196 | + // check fields which may be compressed |
| 197 | + if (framework.status.attemptStatus.taskRoleStatuses == null) { |
| 198 | + framework.status.attemptStatus.taskRoleStatuses = decompressField(framework.status.attemptStatus.taskRoleStatusesCompressed); |
| 199 | + } |
| 200 | + |
187 | 201 | const completionStatus = framework.status.attemptStatus.completionStatus; |
188 | 202 | const diagnostics = completionStatus ? completionStatus.diagnostics : null; |
189 | 203 | const exitDiagnostics = generateExitDiagnostics(diagnostics); |
|
0 commit comments