From d514878f417a94247791bd5564fbaafa9b4170a0 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Mon, 26 Feb 2024 14:32:16 -0800 Subject: [PATCH] Update Floating IP field name from address to ip (#5144) Fixes #5046 Our API for Floating IPs currently has an `address` field, though in a few other places we use `ip`. This PR just makes the API more consistent across the API (and DB). --- nexus/db-queries/src/db/datastore/external_ip.rs | 2 +- nexus/test-utils/src/resource_helpers.rs | 4 ++-- nexus/tests/integration_tests/endpoints.rs | 2 +- nexus/tests/integration_tests/external_ips.rs | 8 ++++---- nexus/types/src/external_api/params.rs | 2 +- openapi/nexus.json | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nexus/db-queries/src/db/datastore/external_ip.rs b/nexus/db-queries/src/db/datastore/external_ip.rs index 24439aa3a0..d15e1b7ca8 100644 --- a/nexus/db-queries/src/db/datastore/external_ip.rs +++ b/nexus/db-queries/src/db/datastore/external_ip.rs @@ -256,7 +256,7 @@ impl DataStore { let pool_id = pool.id(); - let data = if let Some(ip) = params.address { + let data = if let Some(ip) = params.ip { IncompleteExternalIp::for_floating_explicit( ip_id, &Name(params.identity.name), diff --git a/nexus/test-utils/src/resource_helpers.rs b/nexus/test-utils/src/resource_helpers.rs index 764332c5bc..25e58d093d 100644 --- a/nexus/test-utils/src/resource_helpers.rs +++ b/nexus/test-utils/src/resource_helpers.rs @@ -267,7 +267,7 @@ pub async fn create_floating_ip( client: &ClientTestContext, fip_name: &str, project: &str, - address: Option, + ip: Option, parent_pool_name: Option<&str>, ) -> FloatingIp { object_create( @@ -278,7 +278,7 @@ pub async fn create_floating_ip( name: fip_name.parse().unwrap(), description: String::from("a floating ip"), }, - address, + ip, pool: parent_pool_name.map(|v| NameOrId::Name(v.parse().unwrap())), }, ) diff --git a/nexus/tests/integration_tests/endpoints.rs b/nexus/tests/integration_tests/endpoints.rs index 81f2a02b31..c5c69df232 100644 --- a/nexus/tests/integration_tests/endpoints.rs +++ b/nexus/tests/integration_tests/endpoints.rs @@ -768,7 +768,7 @@ pub static DEMO_FLOAT_IP_CREATE: Lazy = name: DEMO_FLOAT_IP_NAME.clone(), description: String::from("a new IP pool"), }, - address: Some(std::net::Ipv4Addr::new(10, 0, 0, 141).into()), + ip: Some(std::net::Ipv4Addr::new(10, 0, 0, 141).into()), pool: None, }); diff --git a/nexus/tests/integration_tests/external_ips.rs b/nexus/tests/integration_tests/external_ips.rs index 57f813d505..ee59c6a034 100644 --- a/nexus/tests/integration_tests/external_ips.rs +++ b/nexus/tests/integration_tests/external_ips.rs @@ -189,7 +189,7 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) { name: fip_name.parse().unwrap(), description: String::from("a floating ip"), }, - address: None, + ip: None, pool: Some(NameOrId::Name("other-pool".parse().unwrap())), }; let url = format!("/v1/floating-ips?project={}", project.identity.name); @@ -259,7 +259,7 @@ async fn test_floating_ip_create_fails_in_other_silo_pool( name: fip_name.parse().unwrap(), description: String::from("a floating ip"), }, - address: None, + ip: None, pool: Some(NameOrId::Name("external-silo-pool".parse().unwrap())), }; @@ -316,7 +316,7 @@ async fn test_floating_ip_create_ip_in_use( name: FIP_NAMES[1].parse().unwrap(), description: "another fip".into(), }, - address: Some(contested_ip), + ip: Some(contested_ip), pool: None, })) .expect_status(Some(StatusCode::BAD_REQUEST)), @@ -364,7 +364,7 @@ async fn test_floating_ip_create_name_in_use( name: contested_name.parse().unwrap(), description: "another fip".into(), }, - address: None, + ip: None, pool: None, })) .expect_status(Some(StatusCode::BAD_REQUEST)), diff --git a/nexus/types/src/external_api/params.rs b/nexus/types/src/external_api/params.rs index 07eeb9b679..567b1ff4ad 100644 --- a/nexus/types/src/external_api/params.rs +++ b/nexus/types/src/external_api/params.rs @@ -883,7 +883,7 @@ pub struct FloatingIpCreate { /// An IP address to reserve for use as a floating IP. This field is /// optional: when not set, an address will be automatically chosen from /// `pool`. If set, then the IP must be available in the resolved `pool`. - pub address: Option, + pub ip: Option, /// The parent IP pool that a floating IP is pulled from. If unset, the /// default pool is selected. diff --git a/openapi/nexus.json b/openapi/nexus.json index cc8edec51d..b0aa84d67a 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -11864,15 +11864,15 @@ "description": "Parameters for creating a new floating IP address for instances.", "type": "object", "properties": { - "address": { + "description": { + "type": "string" + }, + "ip": { "nullable": true, "description": "An IP address to reserve for use as a floating IP. This field is optional: when not set, an address will be automatically chosen from `pool`. If set, then the IP must be available in the resolved `pool`.", "type": "string", "format": "ip" }, - "description": { - "type": "string" - }, "name": { "$ref": "#/components/schemas/Name" },