1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

fix(ui): namespace caching issue EE-5273 (#8709)

* fix namespace caching issue

* fix(apps): add loading state [EE-5273]

* rm endpoint provider

* fix(namespace): remove caching [EE-5273]

* variable typo

---------

Co-authored-by: testa113 <testa113>
This commit is contained in:
Prabhat Khera 2023-03-31 13:24:57 +13:00 committed by GitHub
parent d64e7eacfc
commit fc1aec3bb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 25 additions and 48 deletions

View file

@ -18,7 +18,6 @@ class KubernetesNamespaceService {
this.deleteAsync = this.deleteAsync.bind(this);
this.getJSONAsync = this.getJSONAsync.bind(this);
this.updateFinalizeAsync = this.updateFinalizeAsync.bind(this);
this.refreshCacheAsync = this.refreshCacheAsync.bind(this);
}
/**
@ -81,20 +80,13 @@ class KubernetesNamespaceService {
}
}
async get(name, refreshCache = false) {
async get(name) {
if (name) {
return this.$async(this.getAsync, name);
}
const cachedAllowedNamespaces = this.LocalStorage.getAllowedNamespaces();
if (!cachedAllowedNamespaces || refreshCache) {
const allowedNamespaces = await this.getAllAsync();
this.LocalStorage.storeAllowedNamespaces(allowedNamespaces);
updateNamespaces(allowedNamespaces);
return allowedNamespaces;
} else {
updateNamespaces(cachedAllowedNamespaces);
return cachedAllowedNamespaces;
}
const allowedNamespaces = await this.getAllAsync();
updateNamespaces(allowedNamespaces);
return allowedNamespaces;
}
/**
@ -105,7 +97,6 @@ class KubernetesNamespaceService {
const payload = KubernetesNamespaceConverter.createPayload(namespace);
const params = {};
const data = await this.KubernetesNamespaces().create(params, payload).$promise;
await this.refreshCacheAsync();
return data;
} catch (err) {
throw new PortainerError('Unable to create namespace', err);
@ -116,14 +107,6 @@ class KubernetesNamespaceService {
return this.$async(this.createAsync, namespace);
}
async refreshCacheAsync() {
this.LocalStorage.deleteAllowedNamespaces();
const allowedNamespaces = await this.getAllAsync();
this.LocalStorage.storeAllowedNamespaces(allowedNamespaces);
updateNamespaces(allowedNamespaces);
return allowedNamespaces;
}
/**
* DELETE
*/

View file

@ -36,8 +36,8 @@ export function KubernetesResourcePoolService(
}
// getting the quota for all namespaces is costly by default, so disable getting it by default
async function getAll({ getQuota = false, refreshCache = false }) {
const namespaces = await KubernetesNamespaceService.get('', refreshCache);
async function getAll({ getQuota = false }) {
const namespaces = await KubernetesNamespaceService.get();
const pools = await Promise.all(
_.map(namespaces, async (namespace) => {
const name = namespace.Name;