mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix node shell secret pulling (#3668)
- On some KE errors are thrown if trying to get a secret with an empty name, instead of just ignoring the entry - Clean up the node shell settings Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
36b64f73bc
commit
d132a4c7e7
3 files changed
+50
-52
No files matched your search
+3
-3
@@ -706,10 +706,10 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
}
|
||||
|
||||
get nodeShellImage(): string {
|
||||
return this.preferences.nodeShellImage || initialNodeShellImage;
|
||||
return this.preferences?.nodeShellImage || initialNodeShellImage;
|
||||
}
|
||||
|
||||
get imagePullSecret(): string {
|
||||
return this.preferences.imagePullSecret || "";
|
||||
get imagePullSecret(): string | undefined {
|
||||
return this.preferences?.imagePullSecret;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import * as k8s from "@kubernetes/client-node";
|
||||
import type { KubeConfig } from "@kubernetes/client-node";
|
||||
import type { Cluster } from "../cluster";
|
||||
import { ShellOpenError, ShellSession } from "./shell-session";
|
||||
import { get } from "lodash";
|
||||
|
||||
export class NodeShellSession extends ShellSession {
|
||||
ShellType = "node-shell";
|
||||
@@ -49,7 +50,7 @@ export class NodeShellSession extends ShellSession {
|
||||
await this.waitForRunningPod();
|
||||
} catch (error) {
|
||||
this.deleteNodeShellPod();
|
||||
this.sendResponse("Error occurred. ");
|
||||
this.sendResponse(`Error occurred: ${get(error, "response.body.message", error?.toString() || "unknown error")}`);
|
||||
|
||||
throw new ShellOpenError("failed to create node pod", error);
|
||||
}
|
||||
@@ -57,10 +58,16 @@ export class NodeShellSession extends ShellSession {
|
||||
const args = ["exec", "-i", "-t", "-n", "kube-system", this.podId, "--", "sh", "-c", "((clear && bash) || (clear && ash) || (clear && sh))"];
|
||||
const env = await this.getCachedShellEnv();
|
||||
|
||||
super.open(shell, args, env);
|
||||
await super.open(shell, args, env);
|
||||
}
|
||||
|
||||
protected createNodeShellPod() {
|
||||
const imagePullSecrets = this.cluster.imagePullSecret
|
||||
? [{
|
||||
name: this.cluster.imagePullSecret,
|
||||
}]
|
||||
: undefined;
|
||||
|
||||
return this
|
||||
.kc
|
||||
.makeApiClient(k8s.CoreV1Api)
|
||||
@@ -88,9 +95,7 @@ export class NodeShellSession extends ShellSession {
|
||||
command: ["nsenter"],
|
||||
args: ["-t", "1", "-m", "-u", "-i", "-n", "sleep", "14000"]
|
||||
}],
|
||||
imagePullSecrets: [{
|
||||
name: this.cluster.imagePullSecret,
|
||||
}]
|
||||
imagePullSecrets,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user