Create a volume
An empty ext4 file system, or one made from a backup (from_backup). A volume is attached with the volumes field of a sandbox. What a volume holds is on the node that made it: a node that copies its sandboxes' disks to an object store copies a volume only as its backups (POST /internal/volumes/{id}/backups, a copy at one instant), and a host that is lost takes its volumes with it, all but their backups, from which a volume is made again on any node that copies to the same store.
Takes write.
https://api.glac.ai/v1/volumesAuthorization
Header parameters
Request bodyJSONoptional
- nameoptionalstring
A name given by the caller to a sandbox, a snapshot, a volume or an SSH key: 1 to 63 lower-case letters, digits and hyphens, not starting or ending with a hyphen, and not starting with an id prefix (
sbx-,exe-,snap-,vol-,evt-,req-; an SSH key's not withsshkey-either). A DNS label that cannot be taken for an id. Unique among sandboxes, among snapshots, among volumes and among SSH keys.pattern: ^[a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?$ - kindoptionaldriveorplainorshared
What kind of volume (
Volume.kind). Default:sharedwheresharedis true; elsedriveon a node whose machines keep Drives (drivesof the node),plainon one whose do not.driveon a node whose machines keep none is 503not_served_here;driveorplainwithsharedtrue, andsharedwithsharedfalse, are 400invalid_field. - from_backupoptionalstring
A backup to make the volume from (
bak-…): it is the backup's volume's size and kind (size_bytesandsharedare that volume's, and the call may give them only as they are), and holds what that volume held at the backup's moment. The volume isrestoringuntil the node's uploader has brought the backup whole from the object store, thenready. A backup of this node's, or one made elsewhere thatfrom_backup_indexnames (what a control plane gives). - placement_refusalsoptionalarray | null
With
from_backup: the nodes that refused to make this volume before this one was asked, as its control plane gives them (a node's report says it takes them:takes_placement_refusals). Kept with the restore, and shown as the volume'splacement_refusals. Withoutfrom_backup: 400invalid_field. - durabilityoptionalstandardorstrict
How a Drive is kept (
Volume.durability):strictonly for a Drive (400invalid_fieldfor another kind), on a node that copies its disks to an object store (else 409strict_unsupported); attached only to a sandbox whose machine's spare disks offer its guest flushes (made from a template built since strict Drives: else 409strict_unsupported).default: "standard" - seed_imageoptionalstring
Of a Drive (400
invalid_fieldfor another kind): an image named by its digest (<repository>@sha256:…) that the node's ready list keeps ready (--ready-images, the platform's own), whose seed the Drive is laid out with: what a control plane asks for a new database's Drive, naming the image the database's instance runs. The image declares the directory of it that is its seed (/usr/local/share/glac/drive-seed); the Drive's file system holds that directory atglac-seed/<its name>from the start, its blocks are the node's seed's (laid out once per image, Drive size and node, and written to the object store once, as the platform's: sealed with the platform's key), and its first version in the store names those, so that nothing of the seed is copied or sent for it. Made empty, as without it, where the image is named by a tag, is no ready image of the list by that digest, declares no seed, or its seed for this size is not in the store yet (it is made then, for the next one), or where the node's uploader is not at work: the answer is the same Drive either way. - regionoptionalnaoreuorapornull
The region to make it in, read by the API and not passed on. Null or left out: the region the API itself runs in. Where no machine of that region can take it, the next region does; what has to go to one machine (made from a snapshot or with volumes, or sent again with the same
Idempotency-Key) goes there, whatever the region. A volume made from a backup is made in the backup's region: another is 400invalid_field. Not a region: 400unknown_region. The answer'sregionsays where it was made.
Returns
201
The volume.
- kinddriveorplainorsharedrequired
Decided at creation.
drive: a disk one sandbox has at a time, kept on the node as a layer over zeros (the blocks written to it, in a sparse file, and a bitmap of them), which a machine's Firecracker keeps as it keeps a root disk in layers; a snapshot of a sandbox carries a copy of each Drive it has, and a sandbox made from the snapshot (or a fork) has a Drive of its own made of it. What a volume that is not shared is made as on a node whose machines keep Drives (drivesof the node).plain: a disk one sandbox has at a time, a file system in a file of its own; what such a volume is made as on a node whose machines keep no Drives, and wherekindasks for it.shared:sharedis true. - used_bytesintegerrequired
What it holds now, in bytes: what its file takes on the node, which is the blocks its file system uses, a few hundred kB for an empty one of 256 MiB and 5 MB for one of 64 GiB. It grows as files are written, and falls again when they are removed: the blocks they took go back to the node when the node next counts what its volumes keep (once a minute), and before that when the sandbox that has the volume sleeps, is started again from its disk or gives the volume up. What stays is the file system's own: its tables, and its journal as far as that has been written (512 MiB at the most on a volume of 64 GiB). A volume that is not shared gives nothing back on a node whose
volume_discardis false, nor while it is with a sandbox that was made from a template or a snapshot of before volumes did this. A node counts a volume as keeping this, moment by moment, for as long as it is there, whether or not a sandbox has it.format: int64 · minimum: 0 - host_failurerequired
What the last hard stop of the node's host left uncertain about the volume's disk. Null for a volume that was whole on the host's disk: one that no sandbox had, one whose sandbox was asleep with everything on the disk, and every shared volume (the node holds its file system itself, and what a sandbox was told is written there is on the disk).
- restore_attemptinteger | nullrequired
Of a volume made from a backup, which attempt to make it this is: 1 where it was placed; 2 where that failed and its control plane made it again from the same backup on another node of the backup's region (under the same id: the second and last attempt,
failedfor good where it fails too). Null for a volume made empty.maximum: 2 · minimum: 1 - placement_refusalsarray | nullrequired
Of a volume made from a backup: the nodes of the backup's region that refused to make it before it was made anywhere (each refused before it made anything: its drive was full, the account had no room left there, it could not be reached), in the order they were asked, as its control plane said them; the node that made it was the next. Null where the first node asked made it.
- backupsobjectrequired
How a volume's backups are taken, by the control plane it belongs to (control/README.md, 「卷的备份」): every day or not (
daily), how many of those daily backups are kept (keep), and for how many days a backup taken by a call or before a version of a stateful service is kept (expires_in_days). Kept by the node with the volume, and gone with it; a node of no control plane keeps the rule and takes no backup by it. - durabilityoptional
How a Drive is kept, decided at creation (
VolumeCreate.durability).standard: a guest's fsync returns at once, and a host that is lost loses at most the last second of writes.strict: a guest's fsync, and every flush of its file system, returns once the object store holds every write before it, at the cost of a request to the store for each. Of a plain volume:strictwhere the node made it for a static instance (mounted in its guest with barriers, so that a guest's fsync returns once the host's disk holds what it wrote), null otherwise; null of a shared one.
400
The request is not one this call takes. invalid_json: the body is not a JSON object; unknown_field: the body has a field this call does not take; unknown_parameter: the query has a parameter this call does not take; invalid_field: a field or query parameter has the wrong type or is out of range; invalid_name: name is not a valid name; invalid_idempotency_key: Idempotency-Key is empty or over 255 characters.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
401
missing_api_key, invalid_api_key, expired_api_key, invalid_token.
403
The credential may not do this. needs_api_key: a sandbox token cannot do this. account_share_reached: its account holds as much of this node's data drive as one account may (drive.accounts of GET /internal/node), and has not the room to write a gigabyte to the volume (its size, where that is less). Nothing was made.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
404
Something the request names does not exist. backup_not_found: from_backup names no backup of the caller's that this call can make a volume from.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
409
The state of something stands in the way. name_taken: a volume has the name; idempotency_key_reused: the key was used with another body; idempotency_in_progress: the first request with the key is still running. backup_not_ready: the backup is still being made; backup_unusable: the backup failed.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
503
Not available. not_served_here: shared was asked for, and this node has no file server for shared volumes; or from_backup, and this node copies nothing to an object store (--upload); or from_backup on a node that is keyed and does not hold the key of whose the volume is, or the platform's: this node is keyed (src/seal.rs) and does not hold the key of the project whose it is, or the platform's (the message says which): the control plane gives it, and the same call is made again (Retry-After).
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
default
Any other failure, in the same shape. internal (500): the node failed; the message says no more, and the node's log has the reason under the request's id. unavailable (503, retryable): no_capacity, every network slot of the node is in use; memory_full, a machine the call has to start (made, woken, booted from its disk, resumed, rolled back, built) does not fit in the host's memory beside what the machines that run on it are promised, and nothing paused or idle could be put to sleep to make room for it (memory of the node); drive_full, the call would have a template built and the node's data drive has no room for one (drive of the node); unavailable, the node is shutting down, the sandbox was still starting after 10 minutes, or it did not answer, or it is being moved to this node (with Retry-After: 1); fenced, the node's lease fences the sandbox (Node.lease). moved (409): the sandbox was moved to another node, which to names.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.