From 46ffca92fd8eaa0d9f8d62e2c18b099a2760fc7c Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Tue, 28 Sep 2021 13:48:06 +1300 Subject: [PATCH] feat(k8s): remove cluster status panel (#5570) --- app/kubernetes/component-status/converter.js | 21 ------------ app/kubernetes/component-status/models.js | 14 -------- app/kubernetes/component-status/rest.js | 23 ------------- app/kubernetes/component-status/service.js | 34 ------------------- app/kubernetes/views/cluster/cluster.html | 28 --------------- .../views/cluster/clusterController.js | 19 ----------- 6 files changed, 139 deletions(-) delete mode 100644 app/kubernetes/component-status/converter.js delete mode 100644 app/kubernetes/component-status/models.js delete mode 100644 app/kubernetes/component-status/rest.js delete mode 100644 app/kubernetes/component-status/service.js diff --git a/app/kubernetes/component-status/converter.js b/app/kubernetes/component-status/converter.js deleted file mode 100644 index 730cf60b7..000000000 --- a/app/kubernetes/component-status/converter.js +++ /dev/null @@ -1,21 +0,0 @@ -import _ from 'lodash-es'; -import { KubernetesComponentStatus } from './models'; - -export class KubernetesComponentStatusConverter { - /** - * Convert API data to KubernetesComponentStatus model - */ - static apiToModel(data) { - const res = new KubernetesComponentStatus(); - res.ComponentName = data.metadata.name; - - const healthyCondition = _.find(data.conditions, { type: 'Healthy' }); - if (healthyCondition && healthyCondition.status === 'True') { - res.Healthy = true; - } else if (healthyCondition && healthyCondition.status === 'False') { - res.ErrorMessage = healthyCondition.message; - } - - return res; - } -} diff --git a/app/kubernetes/component-status/models.js b/app/kubernetes/component-status/models.js deleted file mode 100644 index a73862c08..000000000 --- a/app/kubernetes/component-status/models.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * KubernetesComponentStatus Model - */ -const _KubernetesComponentStatus = Object.freeze({ - ComponentName: '', - Healthy: false, - ErrorMessage: '', -}); - -export class KubernetesComponentStatus { - constructor() { - Object.assign(this, JSON.parse(JSON.stringify(_KubernetesComponentStatus))); - } -} diff --git a/app/kubernetes/component-status/rest.js b/app/kubernetes/component-status/rest.js deleted file mode 100644 index 1e27343ed..000000000 --- a/app/kubernetes/component-status/rest.js +++ /dev/null @@ -1,23 +0,0 @@ -angular.module('portainer.kubernetes').factory('KubernetesComponentStatus', [ - '$resource', - 'API_ENDPOINT_ENDPOINTS', - 'EndpointProvider', - function KubernetesComponentStatusFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) { - 'use strict'; - return function () { - const url = API_ENDPOINT_ENDPOINTS + '/:endpointId/kubernetes/api/v1' + '/componentstatuses/:id'; - return $resource( - url, - { - endpointId: EndpointProvider.endpointID, - }, - { - get: { - method: 'GET', - ignoreLoadingBar: true, - }, - } - ); - }; - }, -]); diff --git a/app/kubernetes/component-status/service.js b/app/kubernetes/component-status/service.js deleted file mode 100644 index 1b5d4efe2..000000000 --- a/app/kubernetes/component-status/service.js +++ /dev/null @@ -1,34 +0,0 @@ -import angular from 'angular'; -import PortainerError from 'Portainer/error'; -import _ from 'lodash-es'; -import { KubernetesComponentStatusConverter } from './converter'; - -class KubernetesComponentStatusService { - /* @ngInject */ - constructor($async, KubernetesComponentStatus) { - this.$async = $async; - this.KubernetesComponentStatus = KubernetesComponentStatus; - - this.getAsync = this.getAsync.bind(this); - } - - /** - * GET - */ - async getAsync() { - try { - const data = await this.KubernetesComponentStatus().get().$promise; - const res = _.map(data.items, (item) => KubernetesComponentStatusConverter.apiToModel(item)); - return res; - } catch (err) { - throw new PortainerError('Unable to retrieve cluster status', err); - } - } - - get() { - return this.$async(this.getAsync); - } -} - -export default KubernetesComponentStatusService; -angular.module('portainer.kubernetes').service('KubernetesComponentStatusService', KubernetesComponentStatusService); diff --git a/app/kubernetes/views/cluster/cluster.html b/app/kubernetes/views/cluster/cluster.html index a970a29b9..c8c230e47 100644 --- a/app/kubernetes/views/cluster/cluster.html +++ b/app/kubernetes/views/cluster/cluster.html @@ -25,34 +25,6 @@ - -
- Cluster status -
- - - - - - - - - - - - - - -
ComponentStatusError
- {{ cs.ComponentName }} - - healthy - unhealthy - - {{ cs.ErrorMessage !== '' ? cs.ErrorMessage : '-' }} -
- -
diff --git a/app/kubernetes/views/cluster/clusterController.js b/app/kubernetes/views/cluster/clusterController.js index 2d649df18..bf907faa6 100644 --- a/app/kubernetes/views/cluster/clusterController.js +++ b/app/kubernetes/views/cluster/clusterController.js @@ -15,7 +15,6 @@ class KubernetesClusterController { KubernetesNodeService, KubernetesMetricsService, KubernetesApplicationService, - KubernetesComponentStatusService, KubernetesEndpointService ) { this.$async = $async; @@ -26,32 +25,16 @@ class KubernetesClusterController { this.KubernetesNodeService = KubernetesNodeService; this.KubernetesMetricsService = KubernetesMetricsService; this.KubernetesApplicationService = KubernetesApplicationService; - this.KubernetesComponentStatusService = KubernetesComponentStatusService; this.KubernetesEndpointService = KubernetesEndpointService; this.onInit = this.onInit.bind(this); this.getNodes = this.getNodes.bind(this); this.getNodesAsync = this.getNodesAsync.bind(this); this.getApplicationsAsync = this.getApplicationsAsync.bind(this); - 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() { - try { - this.componentStatuses = await this.KubernetesComponentStatusService.get(); - this.hasUnhealthyComponentStatus = _.find(this.componentStatuses, { Healthy: false }) ? true : false; - } catch (err) { - this.Notifications.error('Failure', err, 'Unable to retrieve cluster component statuses'); - } - } - - getComponentStatus() { - return this.$async(this.getComponentStatusAsync); - } - async getEndpointsAsync() { try { const endpoints = await this.KubernetesEndpointService.get(); @@ -152,14 +135,12 @@ class KubernetesClusterController { this.state = { applicationsLoading: true, viewReady: false, - hasUnhealthyComponentStatus: false, useServerMetrics, }; await this.getNodes(); if (this.isAdmin) { await this.getEndpoints(); - await this.getComponentStatus(); await this.getApplications(); }