Skip to content

Commit 0bfd1f5

Browse files
author
Benjamin Perez
committed
cleanup
1 parent 7fbacb7 commit 0bfd1f5

File tree

2 files changed

+0
-123
lines changed

2 files changed

+0
-123
lines changed

web-app/src/common/types.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
export interface IStorageFactors {
18-
erasureCode: string;
19-
storageFactor: number;
20-
maxCapacity: string;
21-
maxFailureTolerations: number;
22-
}
23-
24-
export interface IErasureCodeCalc {
25-
error: number;
26-
maxEC: string;
27-
erasureCodeSet: number;
28-
rawCapacity: string;
29-
defaultEC: string;
30-
storageFactors: IStorageFactors[];
31-
}
32-
3317
export interface ErrorResponseHandler {
3418
errorMessage: string;
3519
detailedError: string;

web-app/src/common/utils.ts

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import storage from "local-storage-fallback";
18-
import { IErasureCodeCalc, IStorageFactors } from "./types";
1918

2019
import get from "lodash/get";
2120

22-
const minMemReq = 2147483648; // Minimal Memory required for MinIO in bytes
23-
2421
const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
2522
const k8sUnits = ["Ki", "Mi", "Gi", "Ti", "Pi", "Ei"];
26-
const k8sCalcUnits = ["B", ...k8sUnits];
2723

2824
export const niceBytes = (x: string, showK8sUnits: boolean = false) => {
2925
let n = parseInt(x, 10) || 0;
@@ -54,109 +50,6 @@ export const clearSession = () => {
5450
deleteCookie("idp-refresh-token");
5551
};
5652

57-
//getBytes, converts from a value and a unit from units array to bytes as a string
58-
const getBytes = (
59-
value: string,
60-
unit: string,
61-
fromk8s: boolean = false,
62-
): string => {
63-
return getBytesNumber(value, unit, fromk8s).toString(10);
64-
};
65-
66-
//getBytesNumber, converts from a value and a unit from units array to bytes
67-
const getBytesNumber = (
68-
value: string,
69-
unit: string,
70-
fromk8s: boolean = false,
71-
): number => {
72-
const vl: number = parseFloat(value);
73-
74-
const unitsTake = fromk8s ? k8sCalcUnits : units;
75-
76-
const powFactor = unitsTake.findIndex((element) => element === unit);
77-
78-
if (powFactor === -1) {
79-
return 0;
80-
}
81-
const factor = Math.pow(1024, powFactor);
82-
const total = vl * factor;
83-
84-
return total;
85-
};
86-
87-
const setMemoryResource = (
88-
memorySize: number,
89-
capacitySize: string,
90-
maxMemorySize: number,
91-
) => {
92-
// value always comes as Gi
93-
const requestedSizeBytes = getBytes(memorySize.toString(10), "Gi", true);
94-
const memReqSize = parseInt(requestedSizeBytes, 10);
95-
if (maxMemorySize === 0) {
96-
return {
97-
error: "There is no memory available for the selected number of nodes",
98-
request: 0,
99-
limit: 0,
100-
};
101-
}
102-
103-
if (maxMemorySize < minMemReq) {
104-
return {
105-
error: "There are not enough memory resources available",
106-
request: 0,
107-
limit: 0,
108-
};
109-
}
110-
111-
if (memReqSize < minMemReq) {
112-
return {
113-
error: "The requested memory size must be greater than 2Gi",
114-
request: 0,
115-
limit: 0,
116-
};
117-
}
118-
if (memReqSize > maxMemorySize) {
119-
return {
120-
error:
121-
"The requested memory is greater than the max available memory for the selected number of nodes",
122-
request: 0,
123-
limit: 0,
124-
};
125-
}
126-
127-
const capSize = parseInt(capacitySize, 10);
128-
let memLimitSize = memReqSize;
129-
// set memory limit based on the capacitySize
130-
// if capacity size is lower than 1TiB we use the limit equal to request
131-
if (capSize >= parseInt(getBytes("1", "Pi", true), 10)) {
132-
memLimitSize = Math.max(
133-
memReqSize,
134-
parseInt(getBytes("64", "Gi", true), 10),
135-
);
136-
} else if (capSize >= parseInt(getBytes("100", "Ti"), 10)) {
137-
memLimitSize = Math.max(
138-
memReqSize,
139-
parseInt(getBytes("32", "Gi", true), 10),
140-
);
141-
} else if (capSize >= parseInt(getBytes("10", "Ti"), 10)) {
142-
memLimitSize = Math.max(
143-
memReqSize,
144-
parseInt(getBytes("16", "Gi", true), 10),
145-
);
146-
} else if (capSize >= parseInt(getBytes("1", "Ti"), 10)) {
147-
memLimitSize = Math.max(
148-
memReqSize,
149-
parseInt(getBytes("8", "Gi", true), 10),
150-
);
151-
}
152-
153-
return {
154-
error: "",
155-
request: memReqSize,
156-
limit: memLimitSize,
157-
};
158-
};
159-
16053
// 92400 seconds -> 1 day, 1 hour, 40 minutes.
16154
export const niceTimeFromSeconds = (seconds: number): string => {
16255
const days = Math.floor(seconds / (3600 * 24));

0 commit comments

Comments
 (0)