CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/compute/cloud/hyperstack/disk.tsx
Views: 687
1
import DiskGeneric from "@cocalc/frontend/compute/cloud/common/disk";
2
import { getMinDiskSizeGb } from "@cocalc/util/db-schema/compute-servers";
3
import { commas, currency, plural } from "@cocalc/util/misc";
4
import { computeDiskCost } from "@cocalc/util/compute/cloud/hyperstack/compute-cost";
5
import {
6
markup,
7
optionKey,
8
} from "@cocalc/util/compute/cloud/hyperstack/pricing";
9
import { Alert } from "antd";
10
11
export default function Disk(props) {
12
if (props.priceData == null || props.IMAGES == null) {
13
return null;
14
}
15
const cost_per_hour_data = markup({
16
cost: computeDiskCost(props),
17
priceData: props.priceData,
18
});
19
// this data can be null -- I saw this when a bunch of machine types ("flavors") disappeared...
20
const data = props.priceData.options[optionKey(props.configuration)];
21
const numTimes =
22
props.data?.disks == null ? 0 : Math.max(props.data?.disks.length, 1) - 1;
23
return (
24
<div>
25
<DiskGeneric
26
{...props}
27
disabled={numTimes >= 25}
28
noType
29
minSizeGb={getMinDiskSizeGb(props)}
30
maxSizeGb={1048576}
31
computeDiskCost={computeDiskCost}
32
extraHelp={
33
<>
34
<p>
35
This persistent disk is used to create a ZFS pool, with lz4
36
compression enabled, which stores your data and any Docker images.
37
Hyperstack does not support enlarging volumes, so when you enlarge
38
this disk later, we instead add a new volume to this ZFS pool (up
39
to a total of 26).
40
</p>
41
{(data?.ephemeral ?? 0) > 0 && (
42
<p>
43
Moreover, some of your{" "}
44
{data.ephemeral ? `${data.ephemeral} GB` : ""} local SSD will be
45
used for ZFS caching to make the persistent disk much faster.
46
This dramatically increases iops and makes reading data
47
repeatedly much more efficient.
48
</p>
49
)}
50
</>
51
}
52
rate={
53
<>{currency(props.priceData.ssd_cost_per_hour * 730)}/GB per month</>
54
}
55
beforeBody={
56
numTimes >= 1 && props.state != "deprovisioned" ? (
57
<Alert
58
showIcon
59
type="warning"
60
style={{ float: "right", width: "400px" }}
61
description={
62
<>
63
You can enlarge your disk <b>at most 25 times</b>. You have
64
enlarged this disk {numTimes} {plural(numTimes, "time")}.
65
</>
66
}
67
/>
68
) : undefined
69
}
70
/>
71
{cost_per_hour_data != null && (
72
<div>
73
<b>
74
Cost for{" "}
75
{commas(props.configuration.diskSizeGb ?? getMinDiskSizeGb(props))}
76
GB:
77
</b>{" "}
78
{currency(cost_per_hour_data)}/hour or{" "}
79
{currency(cost_per_hour_data * 730)}
80
/month when the server is provisioned.
81
</div>
82
)}
83
{(data?.ephemeral ?? 0) > 0 && (
84
<div>
85
<b>Caching:</b> Some of your {data?.ephemeral} GB local SSD is used for
86
caching to make the data disk much faster.
87
</div>
88
)}
89
</div>
90
);
91
}
92
93