Skip to content

Commit

Permalink
Better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Dec 8, 2023
1 parent 501563b commit f15a451
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
2 changes: 2 additions & 0 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ async fn silo_quotas_view(
}

/// Update the resource quotas of a given silo
///
/// If a quota value is not specified, it will remain unchanged.
#[endpoint {
method = PUT,
path = "/v1/system/silos/{silo}/quotas",
Expand Down
15 changes: 14 additions & 1 deletion nexus/types/src/external_api/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ pub struct SiloCreate {
/// endpoints. These should be valid for the Silo's DNS name(s).
pub tls_certificates: Vec<CertificateCreate>,

/// Initial quotas for the new Silo
/// Limits the amount of provisionable CPU, memory, and storage in the Silo.
/// CPU and memory are only consumed by running instances, while storage is
/// consumed by any disk or snapshot. A value of 0 means that resource is
/// *not* provisionable.
pub quotas: SiloQuotasCreate,

/// Mapping of which Fleet roles are conferred by each Silo role
Expand All @@ -291,14 +294,19 @@ pub struct SiloCreate {
BTreeMap<shared::SiloRole, BTreeSet<shared::FleetRole>>,
}

/// The amount of provisionable resources for a Silo
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct SiloQuotasCreate {
/// The amount of virtual CPUs available for running instances in the Silo
pub cpus: i64,
/// The amount of RAM (in bytes) available for running instances in the Silo
pub memory: ByteCount,
/// The amount of storage (in bytes) available for disks or snapshots
pub storage: ByteCount,
}

impl SiloQuotasCreate {
/// All quotas set to 0
pub fn empty() -> Self {
Self {
cpus: 0,
Expand All @@ -318,10 +326,15 @@ impl SiloQuotasCreate {
}
}

/// Updateable properties of a Silo's resource limits.
/// If a value is omitted it will not be updated.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct SiloQuotasUpdate {
/// The amount of virtual CPUs available for running instances in the Silo
pub cpus: Option<i64>,
/// The amount of RAM (in bytes) available for running instances in the Silo
pub memory: Option<ByteCount>,
/// The amount of storage (in bytes) available for disks or snapshots
pub storage: Option<ByteCount>,
}

Expand Down
30 changes: 20 additions & 10 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -6410,6 +6410,7 @@
"system/silos"
],
"summary": "Update the resource quotas of a given silo",
"description": "If a quota value is not specified, it will remain unchanged.",
"operationId": "silo_quotas_update",
"parameters": [
{
Expand Down Expand Up @@ -13142,7 +13143,7 @@
"$ref": "#/components/schemas/Name"
},
"quotas": {
"description": "Initial quotas for the new Silo",
"description": "Limits the amount of provisionable CPU, memory, and storage in the Silo. CPU and memory are only consumed by running instances, while storage is consumed by any disk or snapshot. A value of 0 means that resource is *not* provisionable.",
"allOf": [
{
"$ref": "#/components/schemas/SiloQuotasCreate"
Expand Down Expand Up @@ -13211,17 +13212,29 @@
]
},
"SiloQuotasCreate": {
"description": "The amount of provisionable resources for a Silo",
"type": "object",
"properties": {
"cpus": {
"description": "The amount of virtual CPUs available for running instances in the Silo",
"type": "integer",
"format": "int64"
},
"memory": {
"$ref": "#/components/schemas/ByteCount"
"description": "The amount of RAM (in bytes) available for running instances in the Silo",
"allOf": [
{
"$ref": "#/components/schemas/ByteCount"
}
]
},
"storage": {
"$ref": "#/components/schemas/ByteCount"
"description": "The amount of storage (in bytes) available for disks or snapshots",
"allOf": [
{
"$ref": "#/components/schemas/ByteCount"
}
]
}
},
"required": [
Expand Down Expand Up @@ -13252,15 +13265,18 @@
]
},
"SiloQuotasUpdate": {
"description": "Updateable properties of a Silo's resource limits. If a value is omitted it will not be updated.",
"type": "object",
"properties": {
"cpus": {
"nullable": true,
"description": "The amount of virtual CPUs available for running instances in the Silo",
"type": "integer",
"format": "int64"
},
"memory": {
"nullable": true,
"description": "The amount of RAM (in bytes) available for running instances in the Silo",
"allOf": [
{
"$ref": "#/components/schemas/ByteCount"
Expand All @@ -13269,6 +13285,7 @@
},
"storage": {
"nullable": true,
"description": "The amount of storage (in bytes) available for disks or snapshots",
"allOf": [
{
"$ref": "#/components/schemas/ByteCount"
Expand Down Expand Up @@ -15608,13 +15625,6 @@
"url": "http://docs.oxide.computer/api/system-networking"
}
},
{
"name": "system/quotas",
"description": "Quotas set resource allocation limits for a silo allowing operators to control the amount of resources a silo can consume.",
"externalDocs": {
"url": "http://docs.oxide.computer/api/system-quotas"
}
},
{
"name": "system/silos",
"description": "Silos represent a logical partition of users and resources.",
Expand Down

0 comments on commit f15a451

Please sign in to comment.