Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit 85425cf

Browse files
authored
[Rest Server] Decompress large framework (#3771)
* Decompress large framework Decompress possible fields for large framework. Reference: microsoft/frameworkcontroller#44 * Fix lint Fix lint. * Remove task status in framework summary Remove task status in framework summary.
1 parent 569397a commit 85425cf

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

  • src/rest-server/src/models/v2/job

src/rest-server/src/models/v2/job/k8s.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
// module dependencies
2020
const {Agent} = require('https');
21+
const zlib = require('zlib');
2122
const axios = require('axios');
2223
const yaml = require('js-yaml');
2324
const base32 = require('base32');
@@ -76,6 +77,14 @@ const decodeName = (name, labels) => {
7677
}
7778
};
7879

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+
7988
const convertState = (state, exitCode, retryDelaySec) => {
8089
switch (state) {
8190
case 'AttemptCreationPending':
@@ -131,9 +140,9 @@ const convertFrameworkSummary = (framework) => {
131140
appExitCode: completionStatus ? completionStatus.code : null,
132141
virtualCluster: framework.metadata.labels ? framework.metadata.labels.virtualCluster : 'unknown',
133142
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,
137146
};
138147
};
139148

@@ -184,6 +193,11 @@ const convertTaskDetail = async (taskStatus, ports, userName, jobName, taskRoleN
184193
};
185194

186195
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+
187201
const completionStatus = framework.status.attemptStatus.completionStatus;
188202
const diagnostics = completionStatus ? completionStatus.diagnostics : null;
189203
const exitDiagnostics = generateExitDiagnostics(diagnostics);

0 commit comments

Comments
 (0)