paginate app operations and refine runtime settings layout
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
+40
-18
@@ -1143,26 +1143,52 @@ export class AppsService {
|
||||
},
|
||||
});
|
||||
|
||||
void this.finalizeMigrationJob(migrationJob.id, {
|
||||
namespace,
|
||||
jobName,
|
||||
image,
|
||||
command,
|
||||
envSecretName,
|
||||
});
|
||||
|
||||
return { migrationJob };
|
||||
}
|
||||
|
||||
private async finalizeMigrationJob(
|
||||
migrationJobId: string,
|
||||
input: {
|
||||
namespace: string;
|
||||
jobName: string;
|
||||
image: string;
|
||||
command: string;
|
||||
envSecretName: string;
|
||||
},
|
||||
) {
|
||||
const migrationJob = await this.prisma.runtimeControlJob.findUnique({
|
||||
where: { id: migrationJobId },
|
||||
});
|
||||
if (!migrationJob) return;
|
||||
|
||||
const logs = splitDeploymentLogs(migrationJob.logs);
|
||||
try {
|
||||
logs.push(`[apply] job/${jobName}`);
|
||||
logs.push(`[apply] job/${input.jobName}`);
|
||||
appendOutput(
|
||||
logs,
|
||||
await this.applyK8sManifest(createMigrationJobManifest({
|
||||
namespace,
|
||||
jobName,
|
||||
image,
|
||||
command,
|
||||
envSecretName,
|
||||
namespace: input.namespace,
|
||||
jobName: input.jobName,
|
||||
image: input.image,
|
||||
command: input.command,
|
||||
envSecretName: input.envSecretName,
|
||||
})),
|
||||
);
|
||||
logs.push(`[wait] job/${jobName}`);
|
||||
await this.waitForJobResult(namespace, jobName, logs);
|
||||
logs.push(`[logs] job/${jobName}`);
|
||||
appendOutput(logs, await this.kubectl(['logs', `job/${jobName}`, '-n', namespace]));
|
||||
logs.push(`[wait] job/${input.jobName}`);
|
||||
await this.waitForJobResult(input.namespace, input.jobName, logs);
|
||||
logs.push(`[logs] job/${input.jobName}`);
|
||||
appendOutput(logs, await this.kubectl(['logs', `job/${input.jobName}`, '-n', input.namespace]));
|
||||
logs.push('[done] migration completed');
|
||||
|
||||
const completed = await this.prisma.runtimeControlJob.update({
|
||||
await this.prisma.runtimeControlJob.update({
|
||||
where: { id: migrationJob.id },
|
||||
data: {
|
||||
status: 'SUCCEEDED',
|
||||
@@ -1170,19 +1196,17 @@ export class AppsService {
|
||||
logs: logs.join('\n'),
|
||||
},
|
||||
});
|
||||
|
||||
return { migrationJob: completed };
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Migration failed';
|
||||
try {
|
||||
logs.push(`[logs] job/${jobName}`);
|
||||
appendOutput(logs, await this.kubectl(['logs', `job/${jobName}`, '-n', namespace]));
|
||||
logs.push(`[logs] job/${input.jobName}`);
|
||||
appendOutput(logs, await this.kubectl(['logs', `job/${input.jobName}`, '-n', input.namespace]));
|
||||
} catch {
|
||||
// 실패한 Job 로그가 아직 없을 수 있습니다.
|
||||
}
|
||||
logs.push(`[failed] ${message}`);
|
||||
|
||||
const failed = await this.prisma.runtimeControlJob.update({
|
||||
await this.prisma.runtimeControlJob.update({
|
||||
where: { id: migrationJob.id },
|
||||
data: {
|
||||
status: 'FAILED',
|
||||
@@ -1190,8 +1214,6 @@ export class AppsService {
|
||||
logs: logs.join('\n'),
|
||||
},
|
||||
});
|
||||
|
||||
return { migrationJob: failed };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user