Skip to content

Commit

Permalink
Merge pull request #1486 from kubeshop/andreiv1992/fix/cluster-change…
Browse files Browse the repository at this point in the history
…-loading-error

Andreiv1992/fix/cluster change loading error
  • Loading branch information
andreivinaga authored Mar 18, 2022
2 parents 6b9f8e0 + ea1ec35 commit 8b8255d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/organisms/PageHeader/ClusterSelectionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,18 @@ export const ClusterSelectionTable: FC<CLusterSelectionTableProps> = ({setIsClus
runCommandInMainThread({
cmd: `kubectl`,
args: ['config', 'use-context', clusterName],
}).then(() => {
dispatch(setCurrentContext(clusterName));
}).then(arg => {
if (arg?.exitCode === 0) {
dispatch(setCurrentContext(clusterName));
} else {
dispatch(
setAlert({
title: 'Error changing cluster context',
message: arg.stderr as string,
type: AlertEnum.Error,
})
);
}
});
};

Expand Down
2 changes: 2 additions & 0 deletions src/utils/kubeclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export async function getKubeAccess(namespaces: string[], currentContext: string
const results = await Promise.all(promises);
const hasErrors = results.length && results.every(result => result.exitCode !== 0);
if (hasErrors) {
const errors = results.map(res => res.stderr).join(',');
log.error(`get cluster access errors ${errors}`);
throw new Error("Couldn't get cluster access for namespaces");
}

Expand Down

0 comments on commit 8b8255d

Please sign in to comment.