Skip to content

Commit

Permalink
fix infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura committed Sep 30, 2024
1 parent 96511a9 commit 1760538
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ ifeq ($(JOB_TYPE), postsubmit)
else
@echo "Image tagging with latest skipped"
endif

run-local-docker:
docker build -t "local-busola" -f Dockerfile.local.kyma .
docker run --rm --interactive --tty --net=host --pid=host --name kyma-dashboard --env ENVIRONMENT="${ENV}" "local-busola"
18 changes: 14 additions & 4 deletions src/state/configuration/configurationAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ const getConfigs = async (fetchFn: FetchFn | undefined) => {
configDir + '/config/config.yaml' + cacheBuster,
);

let envConfig: Config = {};

// When yaml is not available, the busola returns react application which displays not found error.
// Then jsyaml.load raise an exception and NavigationSidebar is not able to render because it's in infinite loop.
if (configResponse.headers.get('Content-Type')?.includes('text/yaml')) {
envConfig = jsyaml.load(await configResponse.text()) as Config;
} else {
console.warn(`Custom Configuration is not available.`);
}

let configMapResponse: ConfigMapResponse;
if (fetchFn) {
try {
Expand All @@ -61,7 +71,6 @@ const getConfigs = async (fetchFn: FetchFn | undefined) => {
}
}

const configParams = jsyaml.load(await configResponse.text()) as Config;
const mapParams = configMapResponse?.data?.config
? (jsyaml.load(configMapResponse.data.config) as Config)
: {};
Expand All @@ -74,13 +83,14 @@ const getConfigs = async (fetchFn: FetchFn | undefined) => {

return mergeWith(
defaultParams?.config,
configParams?.config,
envConfig?.config,
mapParams?.config,
customizer,
) as Configuration;
} catch (e) {
console.warn('Cannot load cluster params: ', e);
return null;
return {
features: {},
} as Configuration;
}
};

Expand Down

0 comments on commit 1760538

Please sign in to comment.