fix(dashboard): use faster proxy request [EE-5160] (#8693)

Co-authored-by: testa113 <testa113>
pull/8716/head
Ali 2023-03-22 15:34:44 +13:00 committed by GitHub
parent f6e8b25cf3
commit 3636ac5c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { EnvironmentStatus } from '@/react/portainer/environments/types';
import { getSelfSubjectAccessReview } from '@/react/kubernetes/namespaces/service';
import { PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
@ -47,7 +48,13 @@ angular.module('portainer.kubernetes', ['portainer.app', registriesModule, custo
throw new Error('Unable to contact Edge agent, please ensure that the agent is properly running on the remote environment.');
}
await KubernetesNamespaceService.get();
// use selfsubject access review to check if we can connect to the kubernetes environment
// because it's gets a fast response, and is accessible to all users
try {
await getSelfSubjectAccessReview(endpoint.Id, 'default');
} catch (e) {
throw new Error('Environment is unreachable.');
}
} catch (e) {
let params = {};

View File

@ -3,6 +3,7 @@ import { EnvironmentId } from '@/react/portainer/environments/types';
import { Namespaces, SelfSubjectAccessReviewResponse } from './types';
// getNamespace is used to retrieve a namespace using the Portainer backend
export async function getNamespace(
environmentId: EnvironmentId,
namespace: string
@ -17,6 +18,7 @@ export async function getNamespace(
}
}
// getNamespaces is used to retrieve namespaces using the Portainer backend with caching
export async function getNamespaces(environmentId: EnvironmentId) {
try {
const { data: namespaces } = await axios.get<Namespaces>(