mirror of https://github.com/rancher/dashboard.git
HARVESTER:Fix storage used
This commit is contained in:
parent
f3d74eb7c2
commit
098b7f639d
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import ConsumptionGauge from '@/components/ConsumptionGauge';
|
||||
import { METRIC } from '@/config/types';
|
||||
import { METRIC, LONGHORN } from '@/config/types';
|
||||
import { formatSi, exponentNeeded, UNITS } from '@/utils/units';
|
||||
|
||||
export default {
|
||||
|
|
@ -29,21 +29,33 @@ export default {
|
|||
},
|
||||
|
||||
storageUsage() {
|
||||
const inStore = this.$store.getters['currentProduct'].inStore;
|
||||
const longhornNode = this.$store.getters[`${ inStore }/byId`](LONGHORN.NODES, `longhorn-system/${ this.row.id }`);
|
||||
let out = 0;
|
||||
|
||||
if (this.metrics) {
|
||||
out = this.metrics.storageUsage;
|
||||
const diskStatus = longhornNode?.status?.diskStatus || {};
|
||||
|
||||
Object.values(diskStatus).map((disk) => {
|
||||
if (disk?.storageAvailable && disk?.storageMaximum) {
|
||||
out += disk.storageMaximum - disk.storageAvailable;
|
||||
}
|
||||
});
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
storageTotal() {
|
||||
const inStore = this.$store.getters['currentProduct'].inStore;
|
||||
const longhornNode = this.$store.getters[`${ inStore }/byId`](LONGHORN.NODES, `longhorn-system/${ this.row.id }`);
|
||||
let out = 0;
|
||||
|
||||
if (this.metrics) {
|
||||
out = this.metrics.storageTotal;
|
||||
const diskStatus = longhornNode?.status?.diskStatus || {};
|
||||
|
||||
Object.values(diskStatus).map((disk) => {
|
||||
if (disk?.storageMaximum) {
|
||||
out += disk.storageMaximum;
|
||||
}
|
||||
});
|
||||
|
||||
return out;
|
||||
},
|
||||
|
|
@ -56,11 +68,12 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
memoryFormatter(value, exponent) {
|
||||
memoryFormatter(value) {
|
||||
const minExponent = exponentNeeded(this.storageTotal, 1024);
|
||||
const formatOptions = {
|
||||
addSuffix: false,
|
||||
increment: 1024,
|
||||
minExponent: exponent
|
||||
minExponent,
|
||||
};
|
||||
|
||||
return formatSi(value, formatOptions);
|
||||
|
|
|
|||
|
|
@ -127,11 +127,17 @@ export default {
|
|||
},
|
||||
|
||||
storageTotal() {
|
||||
const inStore = this.$store.getters['currentProduct'].inStore;
|
||||
const longhornNode = this.$store.getters[`${ inStore }/byId`](LONGHORN.NODES, `longhorn-system/${ this.row.id }`);
|
||||
let out = 0;
|
||||
|
||||
if (this.metrics) {
|
||||
out = this.metrics.storageTotal;
|
||||
const diskStatus = longhornNode?.status?.diskStatus || {};
|
||||
|
||||
Object.values(diskStatus).map((disk) => {
|
||||
if (disk?.storageMaximum) {
|
||||
out += disk.storageMaximum;
|
||||
}
|
||||
});
|
||||
|
||||
return out;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -255,12 +255,12 @@ export default {
|
|||
storageUsage() {
|
||||
let out = 0;
|
||||
|
||||
this.longhornNode.filter(n => n.spec.allowScheduling).forEach((node) => {
|
||||
this.longhornNode.forEach((node) => {
|
||||
const diskStatus = node?.status?.diskStatus || {};
|
||||
|
||||
Object.values(diskStatus).map((disk) => {
|
||||
if (disk?.storageAvailable && disk?.storageMaximum) {
|
||||
out += disk.storageMaximum - disk.storageAvailable;
|
||||
if (disk?.conditions?.Schedulable?.status === 'True' && disk?.storageAvailable && disk?.storageMaximum) {
|
||||
out += (disk.storageMaximum - disk.storageAvailable);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -271,8 +271,14 @@ export default {
|
|||
storageTotal() {
|
||||
let out = 0;
|
||||
|
||||
this.metricNodes.forEach((node) => {
|
||||
out += node.storageTotal;
|
||||
this.longhornNode.forEach((node) => {
|
||||
const diskStatus = node?.status?.diskStatus || {};
|
||||
|
||||
Object.values(diskStatus).map((disk) => {
|
||||
if (disk?.storageMaximum) {
|
||||
out += disk.storageMaximum;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return out;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
import ResourceTable from '@/components/ResourceTable';
|
||||
import Loading from '@/components/Loading';
|
||||
import { STATE, NAME, AGE } from '@/config/table-headers';
|
||||
import { METRIC, NODE, SCHEMA, HCI } from '@/config/types';
|
||||
import {
|
||||
METRIC, NODE, SCHEMA, HCI, LONGHORN
|
||||
} from '@/config/types';
|
||||
import { allHash } from '@/utils/promise';
|
||||
import metricPoller from '@/mixins/metric-poller';
|
||||
import CopyToClipboard from '@/components/CopyToClipboard';
|
||||
|
|
@ -25,7 +27,10 @@ export default {
|
|||
mixins: [metricPoller],
|
||||
|
||||
async fetch() {
|
||||
const _hash = { nodes: this.$store.dispatch('harvester/findAll', { type: NODE }) };
|
||||
const _hash = {
|
||||
nodes: this.$store.dispatch('harvester/findAll', { type: NODE }),
|
||||
longhornNodes: this.$store.dispatch('harvester/findAll', { type: LONGHORN.NODES }),
|
||||
};
|
||||
|
||||
if (this.$store.getters['harvester/schemaFor'](METRIC.NODE)) {
|
||||
_hash.metric = this.$store.dispatch('harvester/findAll', { type: METRIC.NODE });
|
||||
|
|
|
|||
Loading…
Reference in New Issue