Skip to content

Commit

Permalink
Add a limit, rename stray public_key reference
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Jan 22, 2024
1 parent da2936d commit 7cd2b1b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/queries/network_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ mod tests {
memory: ByteCount::from_gibibytes_u32(4),
hostname: "inst".to_string(),
user_data: vec![],
public_keys: Some(Vec::new()),
ssh_keys: Some(Vec::new()),
network_interfaces: InstanceNetworkInterfaceAttachment::None,
external_ips: vec![],
disks: vec![],
Expand Down
9 changes: 9 additions & 0 deletions nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::MAX_EPHEMERAL_IPS_PER_INSTANCE;
use super::MAX_EXTERNAL_IPS_PER_INSTANCE;
use super::MAX_MEMORY_BYTES_PER_INSTANCE;
use super::MAX_NICS_PER_INSTANCE;
use super::MAX_SSH_KEYS_PER_INSTANCE;
use super::MAX_VCPU_PER_INSTANCE;
use super::MIN_MEMORY_BYTES_PER_INSTANCE;
use crate::app::sagas;
Expand Down Expand Up @@ -339,6 +340,14 @@ impl super::Nexus {
),
None => None,
};
if let Some(ssh_keys) = &ssh_keys {
if ssh_keys.len() > MAX_SSH_KEYS_PER_INSTANCE {
return Err(Error::invalid_request(format!(
"cannot attach more than {} ssh keys to the instance",
MAX_SSH_KEYS_PER_INSTANCE
)));
}
}

let saga_params = sagas::instance_create::Params {
serialized_authn: authn::saga::Serialized::for_opctx(opctx),
Expand Down
2 changes: 2 additions & 0 deletions nexus/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pub const MAX_MEMORY_BYTES_PER_INSTANCE: u64 = 256 * (1 << 30); // 256 GiB
pub const MIN_DISK_SIZE_BYTES: u32 = 1 << 30; // 1 GiB
pub const MAX_DISK_SIZE_BYTES: u64 = 1023 * (1 << 30); // 1023 GiB

pub const MAX_SSH_KEYS_PER_INSTANCE: usize = 10;

/// Manages an Oxide fleet -- the heart of the control plane
pub struct Nexus {
/// uuid for this nexus instance.
Expand Down

0 comments on commit 7cd2b1b

Please sign in to comment.