diff --git a/dist/index.js b/dist/index.js index 91dac0b6..d753f86d 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index 46f444e6..028ff7a2 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/src/model/cloud-runner/providers/k8s/index.ts b/src/model/cloud-runner/providers/k8s/index.ts index 5a352798..b5fdb700 100644 --- a/src/model/cloud-runner/providers/k8s/index.ts +++ b/src/model/cloud-runner/providers/k8s/index.ts @@ -42,6 +42,14 @@ class Kubernetes implements ProviderInterface { 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 { const pods = await this.kubeClient.listNamespacedPod(this.namespace); const serviceAccounts = await this.kubeClient.listNamespacedServiceAccount(this.namespace); diff --git a/src/model/cloud-runner/remote-client/index.ts b/src/model/cloud-runner/remote-client/index.ts index 5cff4ef5..cd425c94 100644 --- a/src/model/cloud-runner/remote-client/index.ts +++ b/src/model/cloud-runner/remote-client/index.ts @@ -82,7 +82,7 @@ export class RemoteClient { await RemoteClient.runCustomHookFiles(`after-build`); - RemoteClientLogger.printCollectedLogs(); + await RemoteClientLogger.printCollectedLogs(); return new Promise((result) => result(``)); } diff --git a/src/model/cloud-runner/remote-client/remote-client-logger.ts b/src/model/cloud-runner/remote-client/remote-client-logger.ts index 44d8f251..0085f271 100644 --- a/src/model/cloud-runner/remote-client/remote-client-logger.ts +++ b/src/model/cloud-runner/remote-client/remote-client-logger.ts @@ -2,6 +2,8 @@ import CloudRunnerLogger from '../services/core/cloud-runner-logger'; import fs from 'node:fs'; import path from 'node:path'; import CloudRunner from '../cloud-runner'; +import CloudRunnerOptions from '../options/cloud-runner-options'; +import Kubernetes from '../providers/k8s'; export class RemoteClientLogger { 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(fs.readFileSync(RemoteClientLogger.LogFilePath).toString()); + const logs = fs.readFileSync(RemoteClientLogger.LogFilePath).toString(); + CloudRunnerLogger.log(logs); + await Kubernetes.Instance.PushLogUpdate(logs); } }