stream logs through standard input and new remote client cli command
parent
fdde0dec58
commit
88fa5d247c
|
@ -3279,6 +3279,13 @@ class Kubernetes {
|
||||||
this.namespace = 'default';
|
this.namespace = 'default';
|
||||||
cloud_runner_logger_1.default.log('Loaded default Kubernetes configuration for this environment');
|
cloud_runner_logger_1.default.log('Loaded default Kubernetes configuration for this environment');
|
||||||
}
|
}
|
||||||
|
async PushLogUpdate(logs) {
|
||||||
|
const body = new k8s.V1ConfigMap();
|
||||||
|
body.data = {};
|
||||||
|
body.data['logs'] = logs;
|
||||||
|
body.metadata = { name: `${this.jobName}-logs` };
|
||||||
|
await this.kubeClient.createNamespacedConfigMap(this.namespace, body);
|
||||||
|
}
|
||||||
async listResources() {
|
async listResources() {
|
||||||
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
||||||
const serviceAccounts = await this.kubeClient.listNamespacedServiceAccount(this.namespace);
|
const serviceAccounts = await this.kubeClient.listNamespacedServiceAccount(this.namespace);
|
||||||
|
@ -4342,7 +4349,7 @@ class RemoteClient {
|
||||||
await cloud_runner_system_1.CloudRunnerSystem.Run(`rm -r ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}`);
|
await cloud_runner_system_1.CloudRunnerSystem.Run(`rm -r ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}`);
|
||||||
}
|
}
|
||||||
await RemoteClient.runCustomHookFiles(`after-build`);
|
await RemoteClient.runCustomHookFiles(`after-build`);
|
||||||
remote_client_logger_1.RemoteClientLogger.printCollectedLogs();
|
await remote_client_logger_1.RemoteClientLogger.printCollectedLogs();
|
||||||
return new Promise((result) => result(``));
|
return new Promise((result) => result(``));
|
||||||
}
|
}
|
||||||
static async runCustomHookFiles(hookLifecycle) {
|
static async runCustomHookFiles(hookLifecycle) {
|
||||||
|
@ -4492,6 +4499,8 @@ const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(42864));
|
||||||
const node_fs_1 = __importDefault(__nccwpck_require__(87561));
|
const node_fs_1 = __importDefault(__nccwpck_require__(87561));
|
||||||
const node_path_1 = __importDefault(__nccwpck_require__(49411));
|
const node_path_1 = __importDefault(__nccwpck_require__(49411));
|
||||||
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
||||||
|
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(66965));
|
||||||
|
const k8s_1 = __importDefault(__nccwpck_require__(21613));
|
||||||
class RemoteClientLogger {
|
class RemoteClientLogger {
|
||||||
static get LogFilePath() {
|
static get LogFilePath() {
|
||||||
return node_path_1.default.join(`/home`, `job-log.txt`);
|
return node_path_1.default.join(`/home`, `job-log.txt`);
|
||||||
|
@ -4515,9 +4524,14 @@ class RemoteClientLogger {
|
||||||
node_fs_1.default.appendFileSync(RemoteClientLogger.LogFilePath, `${message}\n`);
|
node_fs_1.default.appendFileSync(RemoteClientLogger.LogFilePath, `${message}\n`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static printCollectedLogs() {
|
static async printCollectedLogs() {
|
||||||
|
if (cloud_runner_options_1.default.providerStrategy !== 'k8s') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
cloud_runner_logger_1.default.log(`Collected Logs`);
|
cloud_runner_logger_1.default.log(`Collected Logs`);
|
||||||
cloud_runner_logger_1.default.log(node_fs_1.default.readFileSync(RemoteClientLogger.LogFilePath).toString());
|
const logs = node_fs_1.default.readFileSync(RemoteClientLogger.LogFilePath).toString();
|
||||||
|
cloud_runner_logger_1.default.log(logs);
|
||||||
|
await k8s_1.default.Instance.PushLogUpdate(logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.RemoteClientLogger = RemoteClientLogger;
|
exports.RemoteClientLogger = RemoteClientLogger;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -42,6 +42,14 @@ class Kubernetes implements ProviderInterface {
|
||||||
CloudRunnerLogger.log('Loaded default Kubernetes configuration for this environment');
|
CloudRunnerLogger.log('Loaded default Kubernetes configuration for this environment');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async PushLogUpdate(logs: string) {
|
||||||
|
const body: k8s.V1ConfigMap = new k8s.V1ConfigMap();
|
||||||
|
body.data = {};
|
||||||
|
body.data['logs'] = logs;
|
||||||
|
body.metadata = { name: `${this.jobName}-logs` };
|
||||||
|
await this.kubeClient.createNamespacedConfigMap(this.namespace, body);
|
||||||
|
}
|
||||||
|
|
||||||
async listResources(): Promise<ProviderResource[]> {
|
async listResources(): Promise<ProviderResource[]> {
|
||||||
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
||||||
const serviceAccounts = await this.kubeClient.listNamespacedServiceAccount(this.namespace);
|
const serviceAccounts = await this.kubeClient.listNamespacedServiceAccount(this.namespace);
|
||||||
|
|
|
@ -82,7 +82,7 @@ export class RemoteClient {
|
||||||
|
|
||||||
await RemoteClient.runCustomHookFiles(`after-build`);
|
await RemoteClient.runCustomHookFiles(`after-build`);
|
||||||
|
|
||||||
RemoteClientLogger.printCollectedLogs();
|
await RemoteClientLogger.printCollectedLogs();
|
||||||
|
|
||||||
return new Promise((result) => result(``));
|
return new Promise((result) => result(``));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ import CloudRunnerLogger from '../services/core/cloud-runner-logger';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import CloudRunner from '../cloud-runner';
|
import CloudRunner from '../cloud-runner';
|
||||||
|
import CloudRunnerOptions from '../options/cloud-runner-options';
|
||||||
|
import Kubernetes from '../providers/k8s';
|
||||||
|
|
||||||
export class RemoteClientLogger {
|
export class RemoteClientLogger {
|
||||||
private static get LogFilePath() {
|
private static get LogFilePath() {
|
||||||
|
@ -32,8 +34,13 @@ export class RemoteClientLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static printCollectedLogs() {
|
public static async printCollectedLogs() {
|
||||||
|
if (CloudRunnerOptions.providerStrategy !== 'k8s') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CloudRunnerLogger.log(`Collected Logs`);
|
CloudRunnerLogger.log(`Collected Logs`);
|
||||||
CloudRunnerLogger.log(fs.readFileSync(RemoteClientLogger.LogFilePath).toString());
|
const logs = fs.readFileSync(RemoteClientLogger.LogFilePath).toString();
|
||||||
|
CloudRunnerLogger.log(logs);
|
||||||
|
await Kubernetes.Instance.PushLogUpdate(logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue