Improve k8s logging accuracy
parent
aa18edc853
commit
6c533e123b
|
|
@ -3308,11 +3308,17 @@ class Kubernetes {
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
const existsAlready = yield this.doesJobExist(this.jobName);
|
let existsAlready = false;
|
||||||
const existsFailedAlready = yield this.doesFailedJobExist();
|
try {
|
||||||
cloud_runner_logger_1.default.log(JSON.stringify(yield this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace), undefined, 4));
|
const status = yield this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace);
|
||||||
cloud_runner_logger_1.default.log(JSON.stringify(yield this.kubeClient.readNamespacedPod(this.podName, this.namespace), undefined, 4));
|
cloud_runner_logger_1.default.log(JSON.stringify(status, undefined, 4));
|
||||||
if (!existsAlready || existsFailedAlready) {
|
cloud_runner_logger_1.default.log(JSON.stringify(yield this.kubeClient.readNamespacedPod(this.podName, this.namespace), undefined, 4));
|
||||||
|
existsAlready = true;
|
||||||
|
}
|
||||||
|
catch (_c) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
if (!existsAlready) {
|
||||||
cloud_runner_logger_1.default.log('Job does not exist');
|
cloud_runner_logger_1.default.log('Job does not exist');
|
||||||
yield this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
|
yield this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
|
||||||
const find = yield Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace);
|
const find = yield Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace);
|
||||||
|
|
@ -3337,7 +3343,7 @@ class Kubernetes {
|
||||||
try {
|
try {
|
||||||
errorParsed = JSON.parse(error);
|
errorParsed = JSON.parse(error);
|
||||||
}
|
}
|
||||||
catch (_c) {
|
catch (_d) {
|
||||||
errorParsed = error;
|
errorParsed = error;
|
||||||
}
|
}
|
||||||
const errorMessage = errorParsed.name || errorParsed.reason || ((_b = (_a = errorParsed.response) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.reason) || errorParsed.message;
|
const errorMessage = errorParsed.name || errorParsed.reason || ((_b = (_a = errorParsed.response) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.reason) || errorParsed.message;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -133,15 +133,18 @@ class Kubernetes implements ProviderInterface {
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
const existsAlready = await this.doesJobExist(this.jobName);
|
let existsAlready = false;
|
||||||
const existsFailedAlready = await this.doesFailedJobExist();
|
try {
|
||||||
CloudRunnerLogger.log(
|
const status = await this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace);
|
||||||
JSON.stringify(await this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace), undefined, 4),
|
CloudRunnerLogger.log(JSON.stringify(status, undefined, 4));
|
||||||
);
|
CloudRunnerLogger.log(
|
||||||
CloudRunnerLogger.log(
|
JSON.stringify(await this.kubeClient.readNamespacedPod(this.podName, this.namespace), undefined, 4),
|
||||||
JSON.stringify(await this.kubeClient.readNamespacedPod(this.podName, this.namespace), undefined, 4),
|
);
|
||||||
);
|
existsAlready = true;
|
||||||
if (!existsAlready || existsFailedAlready) {
|
} catch {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
if (!existsAlready) {
|
||||||
CloudRunnerLogger.log('Job does not exist');
|
CloudRunnerLogger.log('Job does not exist');
|
||||||
await this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
|
await this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
|
||||||
const find = await Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace);
|
const find = await Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue