mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleaning up
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
6c09bae93e
commit
524635c329
@ -26,8 +26,9 @@ import { KubeApi } from "../kube-api";
|
|||||||
export class ClusterApi extends KubeApi<Cluster> {
|
export class ClusterApi extends KubeApi<Cluster> {
|
||||||
static kind = "Cluster";
|
static kind = "Cluster";
|
||||||
static namespaced = true;
|
static namespaced = true;
|
||||||
|
}
|
||||||
|
|
||||||
async getMetrics(nodeNames: string[], params?: IMetricsReqParams): Promise<IClusterMetrics> {
|
export function getMetricsByNodeNames(nodeNames: string[], params?: IMetricsReqParams): Promise<IClusterMetrics> {
|
||||||
const nodes = nodeNames.join("|");
|
const nodes = nodeNames.join("|");
|
||||||
const opts = { category: "cluster", nodes };
|
const opts = { category: "cluster", nodes };
|
||||||
|
|
||||||
@ -50,27 +51,6 @@ export class ClusterApi extends KubeApi<Cluster> {
|
|||||||
fsUsage: opts
|
fsUsage: opts
|
||||||
}, params);
|
}, params);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export function getMetricsByNodeNames(nodeNames: string[], params?: IMetricsReqParams): Promise<IClusterMetrics> {
|
|
||||||
const nodes = nodeNames.join("|");
|
|
||||||
const opts = { category: "cluster", nodes };
|
|
||||||
|
|
||||||
return metricsApi.getMetrics({
|
|
||||||
memoryUsage: opts,
|
|
||||||
memoryRequests: opts,
|
|
||||||
memoryLimits: opts,
|
|
||||||
memoryCapacity: opts,
|
|
||||||
cpuUsage: opts,
|
|
||||||
cpuRequests: opts,
|
|
||||||
cpuLimits: opts,
|
|
||||||
cpuCapacity: opts,
|
|
||||||
podUsage: opts,
|
|
||||||
podCapacity: opts,
|
|
||||||
fsSize: opts,
|
|
||||||
fsUsage: opts
|
|
||||||
}, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ClusterStatus {
|
export enum ClusterStatus {
|
||||||
ACTIVE = "Active",
|
ACTIVE = "Active",
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
import { action, observable, reaction, when, makeObservable } from "mobx";
|
import { action, observable, reaction, when, makeObservable } from "mobx";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { Cluster, clusterApi, IClusterMetrics } from "../../api/endpoints";
|
import { Cluster, clusterApi, getMetricsByNodeNames, IClusterMetrics } from "../../api/endpoints";
|
||||||
import { autoBind, createStorage } from "../../utils";
|
import { autoBind, createStorage } from "../../utils";
|
||||||
import { IMetricsReqParams, normalizeMetrics } from "../../api/endpoints/metrics.api";
|
import { IMetricsReqParams, normalizeMetrics } from "../../api/endpoints/metrics.api";
|
||||||
import { nodesStore } from "../+nodes/nodes.store";
|
import { nodesStore } from "../+nodes/nodes.store";
|
||||||
@ -101,7 +101,7 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements Cl
|
|||||||
const { masterNodes, workerNodes } = nodesStore;
|
const { masterNodes, workerNodes } = nodesStore;
|
||||||
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
||||||
|
|
||||||
this.metrics = await clusterApi.getMetrics(nodes.map(node => node.getName()), params);
|
this.metrics = await getMetricsByNodeNames(nodes.map(node => node.getName()), params);
|
||||||
this.metricsLoaded = true;
|
this.metricsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,13 +32,14 @@ import { podsStore } from "../+workloads-pods/pods.store";
|
|||||||
import type { KubeObjectDetailsProps } from "../kube-object";
|
import type { KubeObjectDetailsProps } from "../kube-object";
|
||||||
import { getMetricsByNodeNames, IClusterMetrics, Node } from "../../api/endpoints";
|
import { getMetricsByNodeNames, IClusterMetrics, Node } from "../../api/endpoints";
|
||||||
import { NodeCharts } from "./node-charts";
|
import { NodeCharts } from "./node-charts";
|
||||||
import { action, observable, reaction } from "mobx";
|
import { observable, reaction } from "mobx";
|
||||||
import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
||||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
||||||
import { NodeDetailsResources } from "./node-details-resources";
|
import { NodeDetailsResources } from "./node-details-resources";
|
||||||
import { DrawerTitle } from "../drawer/drawer-title";
|
import { DrawerTitle } from "../drawer/drawer-title";
|
||||||
|
import { boundMethod } from "../../utils";
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<Node> {
|
interface Props extends KubeObjectDetailsProps<Node> {
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ export class NodeDetails extends React.Component<Props> {
|
|||||||
podsStore.reloadAll();
|
podsStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@boundMethod
|
||||||
async loadMetrics() {
|
async loadMetrics() {
|
||||||
const { object: node } = this.props;
|
const { object: node } = this.props;
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,7 @@ interface Props extends RouteComponentProps<NodesRouteParams> {
|
|||||||
@observer
|
@observer
|
||||||
export class Nodes extends React.Component<Props> {
|
export class Nodes extends React.Component<Props> {
|
||||||
@observable metrics: Partial<INodeMetrics> = {};
|
@observable metrics: Partial<INodeMetrics> = {};
|
||||||
private metricsWatcher = interval(30, async () => await getMetricsForAllNodes());
|
private metricsWatcher = interval(30, async () => this.metrics = await getMetricsForAllNodes());
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.metricsWatcher.start(true);
|
this.metricsWatcher.start(true);
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
|||||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
||||||
|
import { boundMethod } from "../../utils";
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<DaemonSet> {
|
interface Props extends KubeObjectDetailsProps<DaemonSet> {
|
||||||
}
|
}
|
||||||
@ -56,6 +57,7 @@ export class DaemonSetDetails extends React.Component<Props> {
|
|||||||
podsStore.reloadAll();
|
podsStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@boundMethod
|
||||||
async loadMetrics() {
|
async loadMetrics() {
|
||||||
const { object: daemonSet } = this.props;
|
const { object: daemonSet } = this.props;
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
|||||||
import { DeploymentReplicaSets } from "./deployment-replicasets";
|
import { DeploymentReplicaSets } from "./deployment-replicasets";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
||||||
|
import { boundMethod } from "../../utils";
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<Deployment> {
|
interface Props extends KubeObjectDetailsProps<Deployment> {
|
||||||
}
|
}
|
||||||
@ -59,6 +60,7 @@ export class DeploymentDetails extends React.Component<Props> {
|
|||||||
replicaSetStore.reloadAll();
|
replicaSetStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@boundMethod
|
||||||
async loadMetrics() {
|
async loadMetrics() {
|
||||||
const { object: deployment } = this.props;
|
const { object: deployment } = this.props;
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@ import { podMetricTabs, PodCharts } from "../+workloads-pods/pod-charts";
|
|||||||
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ResourceMetrics } from "../resource-metrics";
|
import { ResourceMetrics } from "../resource-metrics";
|
||||||
|
import { boundMethod } from "autobind-decorator";
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<Job> {
|
interface Props extends KubeObjectDetailsProps<Job> {
|
||||||
}
|
}
|
||||||
@ -54,6 +55,7 @@ export class JobDetails extends React.Component<Props> {
|
|||||||
podsStore.reloadAll();
|
podsStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@boundMethod
|
||||||
async loadMetrics() {
|
async loadMetrics() {
|
||||||
const { object: job } = this.props;
|
const { object: job } = this.props;
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
|||||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
||||||
|
import { boundMethod } from "../../utils";
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<ReplicaSet> {
|
interface Props extends KubeObjectDetailsProps<ReplicaSet> {
|
||||||
}
|
}
|
||||||
@ -55,6 +56,7 @@ export class ReplicaSetDetails extends React.Component<Props> {
|
|||||||
podsStore.reloadAll();
|
podsStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@boundMethod
|
||||||
async loadMetrics() {
|
async loadMetrics() {
|
||||||
const { object: replicaSet } = this.props;
|
const { object: replicaSet } = this.props;
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
|||||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
import { ClusterMetricsResourceType } from "../../../main/cluster";
|
||||||
|
import { boundMethod } from "../../utils";
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<StatefulSet> {
|
interface Props extends KubeObjectDetailsProps<StatefulSet> {
|
||||||
}
|
}
|
||||||
@ -56,6 +57,7 @@ export class StatefulSetDetails extends React.Component<Props> {
|
|||||||
podsStore.reloadAll();
|
podsStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@boundMethod
|
||||||
async loadMetrics() {
|
async loadMetrics() {
|
||||||
const { object: statefulSet } = this.props;
|
const { object: statefulSet } = this.props;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user