Skip to content

Commit 96f555f

Browse files
committed
fix: failures on kind against default namespace
1 parent 84cb1e5 commit 96f555f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Diff for: plugins/plugin-codeflare-dashboard/src/components/Top/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default class Header extends React.PureComponent<Props> {
5050
<Text color="blue" bold>
5151
Namespace{" "}
5252
</Text>
53-
{this.props.namespace}
53+
{this.props.namespace || "default"}
5454
</Text>
5555
</Box>
5656

Diff for: plugins/plugin-codeflare-dashboard/src/controller/dashboard/top/watcher.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export default async function initWatcher(this: TopOptions, { context, cluster,
7676
"bash",
7777
[
7878
"-c",
79-
`"while true; do kubectl get pod --context ${context} -n ${ns} --no-headers -o=custom-columns=NAME:.metadata.name,JOB:'.metadata.labels.app\\.kubernetes\\.io/instance',HOST:.status.hostIP,CPU:'.spec.containers[0].resources.requests.cpu',CPUL:'.spec.containers[0].resources.limits.cpu',MEM:'.spec.containers[0].resources.requests.memory',MEML:'.spec.containers[0].resources.limits.memory',GPU:.spec.containers[0].resources.requests.'nvidia\\.com/gpu',GPUL:.spec.containers[0].resources.limits.'nvidia\\.com/gpu',JOB2:'.metadata.labels.appwrapper\\.mcad\\.ibm\\.com',CTIME:.metadata.creationTimestamp,USER:'.metadata.labels.app\\.kubernetes\\.io/owner'; echo '${recordSeparator}'; sleep 2; done"`,
79+
`"while true; do kubectl get pod --context ${context} ${
80+
ns ? `-n ${ns}` : ""
81+
} --no-headers -o=custom-columns=NAME:.metadata.name,JOB:'.metadata.labels.app\\.kubernetes\\.io/instance',HOST:.status.hostIP,CPU:'.spec.containers[0].resources.requests.cpu',CPUL:'.spec.containers[0].resources.limits.cpu',MEM:'.spec.containers[0].resources.requests.memory',MEML:'.spec.containers[0].resources.limits.memory',GPU:.spec.containers[0].resources.requests.'nvidia\\.com/gpu',GPUL:.spec.containers[0].resources.limits.'nvidia\\.com/gpu',JOB2:'.metadata.labels.appwrapper\\.mcad\\.ibm\\.com',CTIME:.metadata.creationTimestamp,USER:'.metadata.labels.app\\.kubernetes\\.io/owner'; echo '${recordSeparator}'; sleep 2; done"`,
8082
],
8183
{ shell: "/bin/bash", stdio: ["ignore", "pipe", "pipe"] }
8284
)

Diff for: plugins/plugin-codeflare-dashboard/src/controller/kubernetes.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,29 @@ export async function kubectl(argv: string[], kubectl = "kubectl", quiet = false
3737
})
3838
}
3939

40-
export async function getCurrentContext(): Promise<string> {
40+
export function getCurrentContext(): Promise<string> {
4141
return kubectl(["config", "current-context"]).then((_) => _.trim())
4242
}
4343

44-
export async function getCurrentCluster(): Promise<string> {
44+
export function getCurrentCluster(): Promise<string> {
4545
// minify limits the view output to show only the current context
4646
return kubectl(["config", "view", "--minify", "-o=jsonpath={.clusters[0].name}"])
4747
}
4848

49-
export async function getCurrentNamespace(): Promise<string> {
49+
export function getCurrentNamespace(): Promise<string> {
5050
// minify limits the view output to show only the current context
5151
return kubectl(["config", "view", "--minify", "-o=jsonpath={..namespace}"])
5252
}
5353

54-
export async function getCurrentClusterOfContext(context: string): Promise<string> {
54+
export function getCurrentClusterOfContext(context: string): Promise<string> {
5555
return kubectl([
5656
"config",
5757
"view",
5858
`-o=jsonpath={range .contexts[?(@.name=="${context}")]}{.context.cluster}{"\\n"}{end}`,
5959
]).then((_) => _.split(/\n/)[0])
6060
}
6161

62-
export async function getCurrentNamespaceOfContext(context: string): Promise<string> {
62+
export function getCurrentNamespaceOfContext(context: string): Promise<string> {
6363
return kubectl([
6464
"config",
6565
"view",
@@ -76,7 +76,7 @@ function listNamespaces(context: string): Promise<string[]> {
7676
}
7777

7878
/** @return a list of available contexts */
79-
async function listContexts(): Promise<string[]> {
79+
function listContexts(): Promise<string[]> {
8080
return kubectl(["config", "get-contexts", "-o=name"]).then((_) => _.split(/\n/))
8181
}
8282

0 commit comments

Comments
 (0)