From c9f481eb6f84d8f5cb93e79a87d17bc58e75bd0c Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Wed, 28 Feb 2024 11:00:32 -0800 Subject: [PATCH 01/10] Add failing test for Floating IP update --- nexus/tests/integration_tests/external_ips.rs | 44 +++++++++++++++++++ nexus/types/src/external_api/params.rs | 6 +++ 2 files changed, 50 insertions(+) diff --git a/nexus/tests/integration_tests/external_ips.rs b/nexus/tests/integration_tests/external_ips.rs index ee59c6a0343..8d44f715f1e 100644 --- a/nexus/tests/integration_tests/external_ips.rs +++ b/nexus/tests/integration_tests/external_ips.rs @@ -37,6 +37,7 @@ use nexus_types::identity::Resource; use omicron_common::address::IpRange; use omicron_common::address::Ipv4Range; use omicron_common::api::external::IdentityMetadataCreateParams; +use omicron_common::api::external::IdentityMetadataUpdateParams; use omicron_common::api::external::Instance; use omicron_common::api::external::Name; use omicron_common::api::external::NameOrId; @@ -381,6 +382,49 @@ async fn test_floating_ip_create_name_in_use( ); } +#[nexus_test] +async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { + let client = &cptestctx.external_client; + + create_default_ip_pool(&client).await; + let project = create_project(client, PROJECT_NAME).await; + + let fip = create_floating_ip( + client, + FIP_NAMES[0], + project.identity.name.as_str(), + None, + None, + ) + .await; + + let floating_ip_url = get_floating_ip_by_id_url(&fip.identity.id); + + let new_fip_name: &str = "updated"; + let new_fip_desc: &str = "updated description"; + + let updates: params::FloatingIpUpdate = params::FloatingIpUpdate { + identity: IdentityMetadataUpdateParams { + name: Some(String::from(new_fip_name).parse().unwrap()), + description: Some(String::from(new_fip_desc).parse().unwrap()), + }, + }; + + let new_fip = NexusRequest::object_put(client, &floating_ip_url, Some(&updates)).authn_as(AuthnMode::PrivilegedUser) + .execute() + .await + .expect("") + .parsed_body::() + .unwrap(); + + assert_eq!(new_fip.identity.name.as_str(), new_fip_name); + assert_eq!(new_fip.identity.description, new_fip_desc); + assert_eq!(new_fip.project_id, project.identity.id); + assert_eq!(new_fip.identity.time_created, fip.identity.time_created); + assert_ne!(new_fip.identity.time_modified, fip.identity.time_modified); + +} + #[nexus_test] async fn test_floating_ip_delete(cptestctx: &ControlPlaneTestContext) { let client = &cptestctx.external_client; diff --git a/nexus/types/src/external_api/params.rs b/nexus/types/src/external_api/params.rs index 567b1ff4ad5..ca7e6d0f897 100644 --- a/nexus/types/src/external_api/params.rs +++ b/nexus/types/src/external_api/params.rs @@ -890,6 +890,12 @@ pub struct FloatingIpCreate { pub pool: Option, } +#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] +pub struct FloatingIpUpdate { + #[serde(flatten)] + pub identity: IdentityMetadataUpdateParams, +} + /// The type of resource that a floating IP is attached to #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "snake_case")] From 3a76c56ef842d248874602591ef1c06504bed895 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Wed, 28 Feb 2024 16:34:06 -0800 Subject: [PATCH 02/10] Updated endpoints to include Floating IP update --- nexus/db-model/src/external_ip.rs | 20 +++++++++++ .../src/db/datastore/external_ip.rs | 27 +++++++++++++++ nexus/src/app/external_ip.rs | 16 +++++++++ nexus/src/external_api/http_entrypoints.rs | 33 ++++++++++++++++++- nexus/tests/output/nexus_tags.txt | 1 + 5 files changed, 96 insertions(+), 1 deletion(-) diff --git a/nexus/db-model/src/external_ip.rs b/nexus/db-model/src/external_ip.rs index b30f91c7c09..a08a2a1e530 100644 --- a/nexus/db-model/src/external_ip.rs +++ b/nexus/db-model/src/external_ip.rs @@ -17,6 +17,7 @@ use diesel::Queryable; use diesel::Selectable; use ipnetwork::IpNetwork; use nexus_types::external_api::shared; +use nexus_types::external_api::params; use nexus_types::external_api::views; use omicron_common::address::NUM_SOURCE_NAT_PORTS; use omicron_common::api::external::Error; @@ -538,6 +539,25 @@ impl From for views::FloatingIp { } } +#[derive(AsChangeset)] +#[diesel(table_name = external_ip)] +pub struct FloatingIpUpdate { + pub name: Option, + pub description: Option, + pub time_modified: DateTime, +} + +impl From for FloatingIpUpdate { + fn from(params: params::FloatingIpUpdate) -> Self { + Self { + name: params.identity.name.map(Name), + description: params.identity.description, + time_modified: Utc::now(), + } + } +} + + impl TryFrom for InstanceExternalIpBody { type Error = Error; diff --git a/nexus/db-queries/src/db/datastore/external_ip.rs b/nexus/db-queries/src/db/datastore/external_ip.rs index d15e1b7ca86..09df1742140 100644 --- a/nexus/db-queries/src/db/datastore/external_ip.rs +++ b/nexus/db-queries/src/db/datastore/external_ip.rs @@ -35,6 +35,7 @@ use crate::db::update_and_check::UpdateStatus; use async_bb8_diesel::AsyncRunQueryDsl; use chrono::Utc; use diesel::prelude::*; +use nexus_db_model::FloatingIpUpdate; use nexus_db_model::Instance; use nexus_db_model::IpAttachState; use nexus_types::external_api::params; @@ -823,6 +824,32 @@ impl DataStore { .map_err(|e| public_error_from_diesel(e, ErrorHandler::Server)) } + /// Update a Floating IP + pub async fn floating_ip_update( + &self, + opctx: &OpContext, + authz_fip: &authz::FloatingIp, + update: FloatingIpUpdate, + ) -> UpdateResult { + use db::schema::external_ip::dsl; + + opctx.authorize(authz::Action::Modify, authz_fip).await?; + + diesel::update(dsl::external_ip) + .filter(dsl::id.eq(authz_fip.id())) + .filter(dsl::time_deleted.is_null()) + .set(update) + .returning(ExternalIp::as_returning()) + .get_result_async(&*self.pool_connection_authorized(opctx).await?) + .await + .map_err(|e| { + public_error_from_diesel( + e, + ErrorHandler::NotFoundByResource(authz_fip), + ) + }) + } + /// Delete a Floating IP, verifying first that it is not in use. pub async fn floating_ip_delete( &self, diff --git a/nexus/src/app/external_ip.rs b/nexus/src/app/external_ip.rs index 45b05fbb0b6..6bf505e1c5b 100644 --- a/nexus/src/app/external_ip.rs +++ b/nexus/src/app/external_ip.rs @@ -127,6 +127,22 @@ impl super::Nexus { .unwrap()) } + pub(crate) async fn floating_ip_update( + &self, + opctx: &OpContext, + ip_lookup: lookup::FloatingIp<'_>, + params: params::FloatingIpUpdate, + ) -> UpdateResult { + let (.., authz_fip) = + ip_lookup.lookup_for(authz::Action::Modify).await?; + Ok(self + .db_datastore + .floating_ip_update(opctx, &authz_fip, params.clone().into()) + .await? + .try_into() + .unwrap()) + } + pub(crate) async fn floating_ip_delete( &self, opctx: &OpContext, diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index b007cc6217a..e5c22d72d64 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -7,7 +7,7 @@ use super::{ console_api, device_auth, params, views::{ - self, Certificate, Group, IdentityProvider, Image, IpPool, IpPoolRange, + self, Certificate, FloatingIp, Group, IdentityProvider, Image, IpPool, IpPoolRange, PhysicalDisk, Project, Rack, Role, Silo, SiloQuotas, SiloUtilization, Sled, Snapshot, SshKey, User, UserBuiltin, Utilization, Vpc, VpcRouter, VpcSubnet, @@ -141,6 +141,7 @@ pub(crate) fn external_api() -> NexusApiDescription { api.register(floating_ip_list)?; api.register(floating_ip_create)?; api.register(floating_ip_view)?; + api.register(floating_ip_update)?; api.register(floating_ip_delete)?; api.register(floating_ip_attach)?; api.register(floating_ip_detach)?; @@ -1921,6 +1922,36 @@ async fn floating_ip_create( apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await } +/// Update a Floating IP +#[endpoint { + method = PUT, + path = "/v1/floating-ips/{floating_ip}", + tags = ["floating-ips"], +}] +async fn floating_ip_update( + rqctx: RequestContext>, + path_params: Path, + query_params: Query, + updated_floating_ip: TypedBody, +) -> Result, HttpError> { + let apictx = rqctx.context(); + let handler = async { + let nexus = &apictx.nexus; + let path = path_params.into_inner(); + let query = query_params.into_inner(); + let updated_floating_ip_params = updated_floating_ip.into_inner(); + let opctx = crate::context::op_context_for_external_api(&rqctx).await?; + let floating_ip_selector = + params::FloatingIpSelector { project: query.project, floating_ip: path.floating_ip }; + let floating_ip_lookup = nexus.floating_ip_lookup(&opctx, floating_ip_selector)?; + let floating_ip = nexus + .floating_ip_update(&opctx, floating_ip_lookup, updated_floating_ip_params) + .await?; + Ok(HttpResponseOk(floating_ip.into())) + }; + apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await +} + /// Delete floating IP #[endpoint { method = DELETE, diff --git a/nexus/tests/output/nexus_tags.txt b/nexus/tests/output/nexus_tags.txt index adb36a24af9..01605a31e7a 100644 --- a/nexus/tests/output/nexus_tags.txt +++ b/nexus/tests/output/nexus_tags.txt @@ -14,6 +14,7 @@ API operations found with tag "floating-ips" OPERATION ID METHOD URL PATH floating_ip_attach POST /v1/floating-ips/{floating_ip}/attach floating_ip_create POST /v1/floating-ips +floating_ip_update PUT /v1/floating-ips/{floating_ip} floating_ip_delete DELETE /v1/floating-ips/{floating_ip} floating_ip_detach POST /v1/floating-ips/{floating_ip}/detach floating_ip_list GET /v1/floating-ips From d980b98d6f4288eac190bcf3a5f304e6de72a3d8 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Thu, 29 Feb 2024 09:08:09 -0800 Subject: [PATCH 03/10] ran cargo fmt --- nexus/db-model/src/external_ip.rs | 3 +-- nexus/src/external_api/http_entrypoints.rs | 23 ++++++++++++------- nexus/tests/integration_tests/external_ips.rs | 15 ++++++------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/nexus/db-model/src/external_ip.rs b/nexus/db-model/src/external_ip.rs index a08a2a1e530..0f484f76106 100644 --- a/nexus/db-model/src/external_ip.rs +++ b/nexus/db-model/src/external_ip.rs @@ -16,8 +16,8 @@ use db_macros::Resource; use diesel::Queryable; use diesel::Selectable; use ipnetwork::IpNetwork; -use nexus_types::external_api::shared; use nexus_types::external_api::params; +use nexus_types::external_api::shared; use nexus_types::external_api::views; use omicron_common::address::NUM_SOURCE_NAT_PORTS; use omicron_common::api::external::Error; @@ -557,7 +557,6 @@ impl From for FloatingIpUpdate { } } - impl TryFrom for InstanceExternalIpBody { type Error = Error; diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index e5c22d72d64..afdf4e0b732 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -7,10 +7,10 @@ use super::{ console_api, device_auth, params, views::{ - self, Certificate, FloatingIp, Group, IdentityProvider, Image, IpPool, IpPoolRange, - PhysicalDisk, Project, Rack, Role, Silo, SiloQuotas, SiloUtilization, - Sled, Snapshot, SshKey, User, UserBuiltin, Utilization, Vpc, VpcRouter, - VpcSubnet, + self, Certificate, FloatingIp, Group, IdentityProvider, Image, IpPool, + IpPoolRange, PhysicalDisk, Project, Rack, Role, Silo, SiloQuotas, + SiloUtilization, Sled, Snapshot, SshKey, User, UserBuiltin, + Utilization, Vpc, VpcRouter, VpcSubnet, }, }; use crate::external_api::shared; @@ -1941,11 +1941,18 @@ async fn floating_ip_update( let query = query_params.into_inner(); let updated_floating_ip_params = updated_floating_ip.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let floating_ip_selector = - params::FloatingIpSelector { project: query.project, floating_ip: path.floating_ip }; - let floating_ip_lookup = nexus.floating_ip_lookup(&opctx, floating_ip_selector)?; + let floating_ip_selector = params::FloatingIpSelector { + project: query.project, + floating_ip: path.floating_ip, + }; + let floating_ip_lookup = + nexus.floating_ip_lookup(&opctx, floating_ip_selector)?; let floating_ip = nexus - .floating_ip_update(&opctx, floating_ip_lookup, updated_floating_ip_params) + .floating_ip_update( + &opctx, + floating_ip_lookup, + updated_floating_ip_params, + ) .await?; Ok(HttpResponseOk(floating_ip.into())) }; diff --git a/nexus/tests/integration_tests/external_ips.rs b/nexus/tests/integration_tests/external_ips.rs index 8d44f715f1e..acfbd7799ca 100644 --- a/nexus/tests/integration_tests/external_ips.rs +++ b/nexus/tests/integration_tests/external_ips.rs @@ -410,19 +410,20 @@ async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { }, }; - let new_fip = NexusRequest::object_put(client, &floating_ip_url, Some(&updates)).authn_as(AuthnMode::PrivilegedUser) - .execute() - .await - .expect("") - .parsed_body::() - .unwrap(); + let new_fip = + NexusRequest::object_put(client, &floating_ip_url, Some(&updates)) + .authn_as(AuthnMode::PrivilegedUser) + .execute() + .await + .expect("") + .parsed_body::() + .unwrap(); assert_eq!(new_fip.identity.name.as_str(), new_fip_name); assert_eq!(new_fip.identity.description, new_fip_desc); assert_eq!(new_fip.project_id, project.identity.id); assert_eq!(new_fip.identity.time_created, fip.identity.time_created); assert_ne!(new_fip.identity.time_modified, fip.identity.time_modified); - } #[nexus_test] From 53e7f4da3227a0a59b0104164c682d174432ecae Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Thu, 29 Feb 2024 09:29:47 -0800 Subject: [PATCH 04/10] Removed into to resolve clippy issue --- nexus/src/external_api/http_entrypoints.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index afdf4e0b732..af4c8537ead 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -1954,7 +1954,7 @@ async fn floating_ip_update( updated_floating_ip_params, ) .await?; - Ok(HttpResponseOk(floating_ip.into())) + Ok(HttpResponseOk(floating_ip)) }; apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await } From c4b439f42a8b7719f89e3a855d3e549b0ce6c4dc Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Thu, 29 Feb 2024 12:26:44 -0800 Subject: [PATCH 05/10] Updated OpenAPI file via expectorate --- nexus/tests/output/nexus_tags.txt | 2 +- openapi/nexus.json | 72 +++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/nexus/tests/output/nexus_tags.txt b/nexus/tests/output/nexus_tags.txt index 01605a31e7a..ecffadcb4d6 100644 --- a/nexus/tests/output/nexus_tags.txt +++ b/nexus/tests/output/nexus_tags.txt @@ -14,10 +14,10 @@ API operations found with tag "floating-ips" OPERATION ID METHOD URL PATH floating_ip_attach POST /v1/floating-ips/{floating_ip}/attach floating_ip_create POST /v1/floating-ips -floating_ip_update PUT /v1/floating-ips/{floating_ip} floating_ip_delete DELETE /v1/floating-ips/{floating_ip} floating_ip_detach POST /v1/floating-ips/{floating_ip}/detach floating_ip_list GET /v1/floating-ips +floating_ip_update PUT /v1/floating-ips/{floating_ip} floating_ip_view GET /v1/floating-ips/{floating_ip} API operations found with tag "hidden" diff --git a/openapi/nexus.json b/openapi/nexus.json index b0aa84d67a1..f76cd7b158e 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -964,6 +964,60 @@ } } }, + "put": { + "tags": [ + "floating-ips" + ], + "summary": "Update a Floating IP", + "operationId": "floating_ip_update", + "parameters": [ + { + "in": "path", + "name": "floating_ip", + "description": "Name or ID of the floating IP", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "description": "Name or ID of the project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FloatingIpUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FloatingIp" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, "delete": { "tags": [ "floating-ips" @@ -11919,6 +11973,24 @@ "items" ] }, + "FloatingIpUpdate": { + "description": "Updateable identity-related parameters", + "type": "object", + "properties": { + "description": { + "nullable": true, + "type": "string" + }, + "name": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/Name" + } + ] + } + } + }, "Group": { "description": "View of a Group", "type": "object", From 31eb133d573242a77f9f811c4530e070083c5c97 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Thu, 29 Feb 2024 15:50:10 -0800 Subject: [PATCH 06/10] Add update to endpoints --- nexus/tests/integration_tests/endpoints.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nexus/tests/integration_tests/endpoints.rs b/nexus/tests/integration_tests/endpoints.rs index c5c69df232f..f18b2d961d2 100644 --- a/nexus/tests/integration_tests/endpoints.rs +++ b/nexus/tests/integration_tests/endpoints.rs @@ -772,6 +772,14 @@ pub static DEMO_FLOAT_IP_CREATE: Lazy = pool: None, }); +pub static DEMO_FLOAT_IP_UPDATE: Lazy = + Lazy::new(|| params::FloatingIpUpdate { + identity: IdentityMetadataUpdateParams { + name: None, + description: Some(String::from("an updated Floating IP")), + }, + }); + pub static DEMO_FLOAT_IP_ATTACH: Lazy = Lazy::new(|| params::FloatingIpAttach { kind: params::FloatingIpParentKind::Instance, @@ -2277,6 +2285,9 @@ pub static VERIFY_ENDPOINTS: Lazy> = Lazy::new(|| { unprivileged_access: UnprivilegedAccess::None, allowed_methods: vec![ AllowedMethod::Get, + AllowedMethod::Put( + serde_json::to_value(&*DEMO_FLOAT_IP_UPDATE).unwrap() + ), AllowedMethod::Delete, ], }, From 938e43141e1f4be55e7bbfee40a6f0ba1badd6b4 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Fri, 1 Mar 2024 11:33:57 -0800 Subject: [PATCH 07/10] Update tests --- nexus/tests/integration_tests/external_ips.rs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/nexus/tests/integration_tests/external_ips.rs b/nexus/tests/integration_tests/external_ips.rs index acfbd7799ca..62fda8cf7b0 100644 --- a/nexus/tests/integration_tests/external_ips.rs +++ b/nexus/tests/integration_tests/external_ips.rs @@ -28,6 +28,8 @@ use nexus_test_utils::resource_helpers::object_create; use nexus_test_utils::resource_helpers::object_create_error; use nexus_test_utils::resource_helpers::object_delete; use nexus_test_utils::resource_helpers::object_delete_error; +use nexus_test_utils::resource_helpers::object_get; +use nexus_test_utils::resource_helpers::object_put; use nexus_test_utils_macros::nexus_test; use nexus_types::external_api::params; use nexus_types::external_api::shared; @@ -389,6 +391,7 @@ async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { create_default_ip_pool(&client).await; let project = create_project(client, PROJECT_NAME).await; + // Create the Floating IP let fip = create_floating_ip( client, FIP_NAMES[0], @@ -400,9 +403,15 @@ async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { let floating_ip_url = get_floating_ip_by_id_url(&fip.identity.id); + // Verify that the Floating IP was created correctly + let fetched_floating_ip: FloatingIp = + object_get(client, &floating_ip_url).await; + + assert_floating_ips_eq(&fip, &fetched_floating_ip); + + // Set up the updated values let new_fip_name: &str = "updated"; let new_fip_desc: &str = "updated description"; - let updates: params::FloatingIpUpdate = params::FloatingIpUpdate { identity: IdentityMetadataUpdateParams { name: Some(String::from(new_fip_name).parse().unwrap()), @@ -410,20 +419,21 @@ async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { }, }; - let new_fip = - NexusRequest::object_put(client, &floating_ip_url, Some(&updates)) - .authn_as(AuthnMode::PrivilegedUser) - .execute() - .await - .expect("") - .parsed_body::() - .unwrap(); + // Update the Floating IP + let new_fip: FloatingIp = + object_put(client, &floating_ip_url, &updates).await; assert_eq!(new_fip.identity.name.as_str(), new_fip_name); assert_eq!(new_fip.identity.description, new_fip_desc); assert_eq!(new_fip.project_id, project.identity.id); assert_eq!(new_fip.identity.time_created, fip.identity.time_created); assert_ne!(new_fip.identity.time_modified, fip.identity.time_modified); + + // Verify that the Floating IP was updated correctly + let fetched_modified_floating_ip: FloatingIp = + object_get(client, &floating_ip_url).await; + + assert_floating_ips_eq(&new_fip, &fetched_modified_floating_ip); } #[nexus_test] @@ -1010,3 +1020,7 @@ async fn floating_ip_detach( .parsed_body() .unwrap() } + +fn assert_floating_ips_eq(first: &FloatingIp, second: &FloatingIp) { + assert_eq!(first.identity, second.identity); +} From 1450f4c88e645173fdfe73542e11b06f262a6bc5 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Fri, 1 Mar 2024 11:44:54 -0800 Subject: [PATCH 08/10] Update nexus/src/external_api/http_entrypoints.rs Co-authored-by: David Crespo --- nexus/src/external_api/http_entrypoints.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index af4c8537ead..405aacbead8 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -1922,7 +1922,7 @@ async fn floating_ip_create( apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await } -/// Update a Floating IP +/// Update floating IP #[endpoint { method = PUT, path = "/v1/floating-ips/{floating_ip}", From aaeef754bd65f02d323e87b7322e3f51598401f8 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Fri, 1 Mar 2024 11:57:44 -0800 Subject: [PATCH 09/10] Refactor test --- nexus/tests/integration_tests/external_ips.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nexus/tests/integration_tests/external_ips.rs b/nexus/tests/integration_tests/external_ips.rs index 0687e1d9ae9..b0950f52f6d 100644 --- a/nexus/tests/integration_tests/external_ips.rs +++ b/nexus/tests/integration_tests/external_ips.rs @@ -407,7 +407,7 @@ async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { let fetched_floating_ip: FloatingIp = object_get(client, &floating_ip_url).await; - assert_floating_ips_eq(&fip, &fetched_floating_ip); + assert_eq!(fip.identity, fetched_floating_ip.identity); // Set up the updated values let new_fip_name: &str = "updated"; @@ -433,7 +433,7 @@ async fn test_floating_ip_update(cptestctx: &ControlPlaneTestContext) { let fetched_modified_floating_ip: FloatingIp = object_get(client, &floating_ip_url).await; - assert_floating_ips_eq(&new_fip, &fetched_modified_floating_ip); + assert_eq!(new_fip.identity, fetched_modified_floating_ip.identity); } #[nexus_test] @@ -1079,7 +1079,3 @@ async fn floating_ip_detach( .parsed_body() .unwrap() } - -fn assert_floating_ips_eq(first: &FloatingIp, second: &FloatingIp) { - assert_eq!(first.identity, second.identity); -} From 0a328fc4c12b57ba5dec5d2757b62d42f5fe4256 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Fri, 1 Mar 2024 12:14:32 -0800 Subject: [PATCH 10/10] Small update to openapi --- openapi/nexus.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi/nexus.json b/openapi/nexus.json index f76cd7b158e..3d31331a903 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -968,7 +968,7 @@ "tags": [ "floating-ips" ], - "summary": "Update a Floating IP", + "summary": "Update floating IP", "operationId": "floating_ip_update", "parameters": [ {