Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ssh_keys to ssh_public_keys in instance create #4941

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/queries/external_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ mod tests {
ncpus: InstanceCpuCount(omicron_common::api::external::InstanceCpuCount(1)).into(),
memory: ByteCount(omicron_common::api::external::ByteCount::from_gibibytes_u32(1)).into(),
hostname: "test".into(),
ssh_keys: None,
ssh_public_keys: None,
user_data: vec![],
network_interfaces: Default::default(),
external_ips: vec![],
Expand Down
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![],
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces: InstanceNetworkInterfaceAttachment::None,
external_ips: vec![],
disks: vec![],
Expand Down
4 changes: 2 additions & 2 deletions nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl super::Nexus {
.lookup_for(authz::Action::ListChildren)
.await?;

let ssh_keys = match &params.ssh_keys {
let ssh_keys = match &params.ssh_public_keys {
Some(keys) => Some(
self.db_datastore
.ssh_keys_batch_lookup(opctx, &authz_user, keys)
Expand All @@ -354,7 +354,7 @@ impl super::Nexus {
serialized_authn: authn::saga::Serialized::for_opctx(opctx),
project_id: authz_project.id(),
create_params: params::InstanceCreate {
ssh_keys,
ssh_public_keys: ssh_keys,
..params.clone()
},
boundary_switches: self
Expand Down
4 changes: 2 additions & 2 deletions nexus/src/app/sagas/instance_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ async fn sic_associate_ssh_keys(
&opctx,
&authz_user,
instance_id,
&saga_params.create_params.ssh_keys.map(|k| {
&saga_params.create_params.ssh_public_keys.map(|k| {
// Before the instance_create saga is kicked off all entries
// in `ssh_keys` are validated and converted to `Uuids`.
k.iter()
Expand Down Expand Up @@ -1104,7 +1104,7 @@ pub mod test {
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("inst"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![params::ExternalIpCreate::Ephemeral {
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/instance_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ mod test {
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("inst"),
user_data: vec![],
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![params::ExternalIpCreate::Ephemeral {
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/instance_migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ mod tests {
memory: ByteCount::from_gibibytes_u32(2),
hostname: String::from(INSTANCE_NAME),
user_data: b"#cloud-config".to_vec(),
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces:
params::InstanceNetworkInterfaceAttachment::None,
external_ips: vec![],
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/instance_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ mod test {
memory: ByteCount::from_gibibytes_u32(2),
hostname: String::from(INSTANCE_NAME),
user_data: b"#cloud-config".to_vec(),
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces:
params::InstanceNetworkInterfaceAttachment::None,
external_ips: vec![],
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/snapshot_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ mod test {
user_data:
b"#cloud-config\nsystem_info:\n default_user:\n name: oxide"
.to_vec(),
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces:
params::InstanceNetworkInterfaceAttachment::None,
disks: disks_to_attach,
Expand Down
2 changes: 1 addition & 1 deletion nexus/test-utils/src/resource_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ pub async fn create_instance_with(
user_data:
b"#cloud-config\nsystem_info:\n default_user:\n name: oxide"
.to_vec(),
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces: nics.clone(),
external_ips,
disks,
Expand Down
2 changes: 1 addition & 1 deletion nexus/tests/integration_tests/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ pub static DEMO_INSTANCE_CREATE: Lazy<params::InstanceCreate> =
memory: ByteCount::from_gibibytes_u32(16),
hostname: String::from("demo-instance"),
user_data: vec![],
ssh_keys: Some(Vec::new()),
ssh_public_keys: Some(Vec::new()),
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![params::ExternalIpCreate::Ephemeral {
pool: Some(DEMO_IP_POOL_NAME.clone().into()),
Expand Down
64 changes: 32 additions & 32 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ async fn test_instances_create_reboot_halt(
memory: instance.memory,
hostname: instance.hostname.clone(),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
Expand Down Expand Up @@ -1222,7 +1222,7 @@ async fn test_instances_create_stopped_start(
memory: ByteCount::from_gibibytes_u32(1),
hostname: String::from("the_host"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
Expand Down Expand Up @@ -1390,7 +1390,7 @@ async fn test_instance_using_image_from_other_project_fails(
memory: ByteCount::from_gibibytes_u32(1),
hostname: "stolen".into(),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
Expand Down Expand Up @@ -1465,7 +1465,7 @@ async fn test_instance_create_saga_removes_instance_database_record(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("inst"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: interface_params.clone(),
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -1493,7 +1493,7 @@ async fn test_instance_create_saga_removes_instance_database_record(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("inst2"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: interface_params,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -1582,7 +1582,7 @@ async fn test_instance_with_single_explicit_ip_address(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nic-test"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: interface_params,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -1696,7 +1696,7 @@ async fn test_instance_with_new_custom_network_interfaces(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nic-test"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: interface_params,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -1810,7 +1810,7 @@ async fn test_instance_create_delete_network_interface(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nic-test"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::None,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -2051,7 +2051,7 @@ async fn test_instance_update_network_interfaces(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nic-test"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::None,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -2444,7 +2444,7 @@ async fn test_instance_with_multiple_nics_unwinds_completely(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nic-test"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: interface_params,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -2510,7 +2510,7 @@ async fn test_attach_one_disk_to_instance(cptestctx: &ControlPlaneTestContext) {
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![params::InstanceDiskAttachment::Attach(
Expand Down Expand Up @@ -2570,7 +2570,7 @@ async fn test_instance_create_attach_disks(
memory: ByteCount::from_gibibytes_u32(3),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![
Expand Down Expand Up @@ -2667,7 +2667,7 @@ async fn test_instance_create_attach_disks_undo(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![
Expand Down Expand Up @@ -2752,7 +2752,7 @@ async fn test_attach_eight_disks_to_instance(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: (0..8)
Expand Down Expand Up @@ -2833,7 +2833,7 @@ async fn test_cannot_attach_nine_disks_to_instance(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: (0..9)
Expand Down Expand Up @@ -2928,7 +2928,7 @@ async fn test_cannot_attach_faulted_disks(cptestctx: &ControlPlaneTestContext) {
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: (0..8)
Expand Down Expand Up @@ -3012,7 +3012,7 @@ async fn test_disks_detached_when_instance_destroyed(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfs"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: (0..8)
Expand Down Expand Up @@ -3103,7 +3103,7 @@ async fn test_disks_detached_when_instance_destroyed(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("nfsv2"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: (0..8)
Expand Down Expand Up @@ -3165,7 +3165,7 @@ async fn test_instances_memory_rejected_less_than_min_memory_size(
user_data:
b"#cloud-config\nsystem_info:\n default_user:\n name: oxide"
.to_vec(),
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -3215,7 +3215,7 @@ async fn test_instances_memory_not_divisible_by_min_memory_size(
user_data:
b"#cloud-config\nsystem_info:\n default_user:\n name: oxide"
.to_vec(),
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -3265,7 +3265,7 @@ async fn test_instances_memory_greater_than_max_size(
user_data:
b"#cloud-config\nsystem_info:\n default_user:\n name: oxide"
.to_vec(),
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -3345,7 +3345,7 @@ async fn test_instance_create_with_ssh_keys(
ncpus: InstanceCpuCount::try_from(2).unwrap(),
memory: ByteCount::from_gibibytes_u32(4),
// By default should transfer all profile keys
ssh_keys: None,
ssh_public_keys: None,
start: false,
hostname: instance_name.to_string(),
user_data: vec![],
Expand Down Expand Up @@ -3391,7 +3391,7 @@ async fn test_instance_create_with_ssh_keys(
ncpus: InstanceCpuCount::try_from(2).unwrap(),
memory: ByteCount::from_gibibytes_u32(4),
// Should only transfer the first key
ssh_keys: Some(vec![user_keys[0].identity.name.clone().into()]),
ssh_public_keys: Some(vec![user_keys[0].identity.name.clone().into()]),
start: false,
hostname: instance_name.to_string(),
user_data: vec![],
Expand Down Expand Up @@ -3436,7 +3436,7 @@ async fn test_instance_create_with_ssh_keys(
ncpus: InstanceCpuCount::try_from(2).unwrap(),
memory: ByteCount::from_gibibytes_u32(4),
// Should transfer no keys
ssh_keys: Some(vec![]),
ssh_public_keys: Some(vec![]),
start: false,
hostname: instance_name.to_string(),
user_data: vec![],
Expand Down Expand Up @@ -3558,7 +3558,7 @@ async fn test_cannot_provision_instance_beyond_cpu_capacity(
memory: ByteCount::from_gibibytes_u32(1),
hostname: config.0.to_string(),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
Expand Down Expand Up @@ -3612,7 +3612,7 @@ async fn test_cannot_provision_instance_beyond_cpu_limit(
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("test"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
disks: vec![],
Expand Down Expand Up @@ -3664,7 +3664,7 @@ async fn test_cannot_provision_instance_beyond_ram_capacity(
memory: ByteCount::try_from(config.1).unwrap(),
hostname: config.0.to_string(),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces:
params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![],
Expand Down Expand Up @@ -3919,7 +3919,7 @@ async fn test_instance_ephemeral_ip_from_correct_pool(
external_ips: vec![params::ExternalIpCreate::Ephemeral {
pool: Some("pool1".parse::<Name>().unwrap().into()),
}],
ssh_keys: None,
ssh_public_keys: None,
disks: vec![],
start: true,
};
Expand Down Expand Up @@ -3984,7 +3984,7 @@ async fn test_instance_ephemeral_ip_from_orphan_pool(
external_ips: vec![params::ExternalIpCreate::Ephemeral {
pool: Some("orphan-pool".parse::<Name>().unwrap().into()),
}],
ssh_keys: None,
ssh_public_keys: None,
disks: vec![],
start: true,
};
Expand Down Expand Up @@ -4045,7 +4045,7 @@ async fn test_instance_ephemeral_ip_no_default_pool_error(
external_ips: vec![params::ExternalIpCreate::Ephemeral {
pool: None, // <--- the only important thing here
}],
ssh_keys: None,
ssh_public_keys: None,
disks: vec![],
start: true,
};
Expand Down Expand Up @@ -4176,7 +4176,7 @@ async fn test_instance_allow_only_one_ephemeral_ip(
user_data:
b"#cloud-config\nsystem_info:\n default_user:\n name: oxide"
.to_vec(),
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![ephemeral_create.clone(), ephemeral_create],
disks: vec![],
Expand Down Expand Up @@ -4302,7 +4302,7 @@ async fn test_instance_create_in_silo(cptestctx: &ControlPlaneTestContext) {
memory: ByteCount::from_gibibytes_u32(4),
hostname: String::from("inst"),
user_data: vec![],
ssh_keys: None,
ssh_public_keys: None,
network_interfaces: params::InstanceNetworkInterfaceAttachment::Default,
external_ips: vec![params::ExternalIpCreate::Ephemeral {
pool: Some("default".parse::<Name>().unwrap().into()),
Expand Down
Loading
Loading