1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 21:39:40 +02:00

fix(metrics): disable metric server api calls if metric server is disabled on k8s endpoint EE-1273 EE-1274 (#5377)

* - metric server api call disabled on cluster view
- metric server api call disabled on node view
- metric server api call disabled on namespace view

* enforcing resource access to function to ensure similarity to ee implementation
This commit is contained in:
zees-dev 2021-08-13 16:46:18 +12:00 committed by GitHub
parent 7b6a31181e
commit 5fe90db36a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 17 deletions

View file

@ -46,6 +46,7 @@ class KubernetesNodeController {
this.getEndpointsAsync = this.getEndpointsAsync.bind(this);
this.updateNodeAsync = this.updateNodeAsync.bind(this);
this.drainNodeAsync = this.drainNodeAsync.bind(this);
this.hasResourceUsageAccess = this.hasResourceUsageAccess.bind(this);
this.getNodeUsageAsync = this.getNodeUsageAsync.bind(this);
}
@ -332,6 +333,10 @@ class KubernetesNodeController {
return this.$async(this.getNodesAsync);
}
hasResourceUsageAccess() {
return this.state.isAdmin && this.state.useServerMetrics;
}
async getNodeUsageAsync() {
try {
const nodeName = this.$transition$.params().name;
@ -397,7 +402,7 @@ class KubernetesNodeController {
this.memoryLimit = KubernetesResourceReservationHelper.megaBytesValue(this.node.Memory);
this.state.isContainPortainer = _.find(this.applications, { ApplicationName: 'portainer' });
if (this.state.isAdmin) {
if (this.hasResourceUsageAccess()) {
await this.getNodeUsage();
}
} catch (err) {
@ -412,9 +417,11 @@ class KubernetesNodeController {
}
async onInit() {
this.availabilities = KubernetesNodeAvailabilities;
this.state = {
isAdmin: this.Authentication.isAdmin(),
activeTab: 0,
activeTab: this.LocalStorage.getActiveTab('node'),
currentName: this.$state.$current.name,
dataLoading: true,
eventsLoading: true,
@ -428,15 +435,9 @@ class KubernetesNodeController {
hasDuplicateLabelKeys: false,
isDrainOperation: false,
isContainPortainer: false,
useServerMetrics: false,
useServerMetrics: this.endpoint.Kubernetes.Configuration.UseServerMetrics,
};
this.availabilities = KubernetesNodeAvailabilities;
this.state.useServerMetrics = this.endpoint.Kubernetes.Configuration.UseServerMetrics;
this.state.activeTab = this.LocalStorage.getActiveTab('node');
await this.getNodes();
await this.getEvents();
await this.getApplications();