mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 06:19:41 +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:
parent
7b6a31181e
commit
5fe90db36a
5 changed files with 29 additions and 17 deletions
|
@ -36,6 +36,7 @@ class KubernetesClusterController {
|
|||
this.getComponentStatus = this.getComponentStatus.bind(this);
|
||||
this.getComponentStatusAsync = this.getComponentStatusAsync.bind(this);
|
||||
this.getEndpointsAsync = this.getEndpointsAsync.bind(this);
|
||||
this.hasResourceUsageAccess = this.hasResourceUsageAccess.bind(this);
|
||||
}
|
||||
|
||||
async getComponentStatusAsync() {
|
||||
|
@ -107,7 +108,7 @@ class KubernetesClusterController {
|
|||
);
|
||||
this.resourceReservation.Memory = KubernetesResourceReservationHelper.megaBytesValue(this.resourceReservation.Memory);
|
||||
|
||||
if (this.isAdmin) {
|
||||
if (this.hasResourceUsageAccess()) {
|
||||
await this.getResourceUsage(this.endpoint.Id);
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -136,17 +137,25 @@ class KubernetesClusterController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if resource usage stats can be displayed
|
||||
* @returns {boolean}
|
||||
*/
|
||||
hasResourceUsageAccess() {
|
||||
return this.isAdmin && this.state.useServerMetrics;
|
||||
}
|
||||
|
||||
async onInit() {
|
||||
this.isAdmin = this.Authentication.isAdmin();
|
||||
const useServerMetrics = this.endpoint.Kubernetes.Configuration.UseServerMetrics;
|
||||
|
||||
this.state = {
|
||||
applicationsLoading: true,
|
||||
viewReady: false,
|
||||
hasUnhealthyComponentStatus: false,
|
||||
useServerMetrics: false,
|
||||
useServerMetrics,
|
||||
};
|
||||
|
||||
this.isAdmin = this.Authentication.isAdmin();
|
||||
this.state.useServerMetrics = this.endpoint.Kubernetes.Configuration.UseServerMetrics;
|
||||
|
||||
await this.getNodes();
|
||||
if (this.isAdmin) {
|
||||
await this.getEndpoints();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue