Skip to content

Commit

Permalink
external IPs endpoint returns ResultsPage instead of Vec (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo authored Jul 26, 2022
1 parent 5110250 commit 6d8d6a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ async fn instance_network_interface_update(
async fn instance_external_ip_list(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
path_params: Path<InstancePathParam>,
) -> Result<HttpResponseOk<Vec<views::ExternalIp>>, HttpError> {
) -> Result<HttpResponseOk<ResultsPage<views::ExternalIp>>, HttpError> {
let apictx = rqctx.context();
let nexus = &apictx.nexus;
let path = path_params.into_inner();
Expand All @@ -2517,7 +2517,7 @@ async fn instance_external_ip_list(
instance_name,
)
.await?;
Ok(HttpResponseOk(ips))
Ok(HttpResponseOk(ResultsPage { items: ips, next_page: None }))
};
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
}
Expand Down
14 changes: 7 additions & 7 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use omicron_common::api::external::NetworkInterface;
use omicron_nexus::external_api::shared::IpKind;
use omicron_nexus::external_api::shared::IpRange;
use omicron_nexus::external_api::shared::Ipv4Range;
use omicron_nexus::external_api::views::ExternalIp;
use omicron_nexus::external_api::views;
use omicron_nexus::TestInterfaces as _;
use omicron_nexus::{external_api::params, Nexus};
use sled_agent_client::TestInterfaces as _;
Expand All @@ -36,7 +36,7 @@ use std::sync::Arc;
use uuid::Uuid;

use dropshot::test_util::ClientTestContext;
use dropshot::HttpErrorResponseBody;
use dropshot::{HttpErrorResponseBody, ResultsPage};

use nexus_test_utils::identity_eq;
use nexus_test_utils::resource_helpers::{
Expand Down Expand Up @@ -2500,13 +2500,13 @@ async fn test_instance_ephemeral_ip_from_correct_project(
.execute()
.await
.expect("Failed to fetch external IPs")
.parsed_body::<Vec<ExternalIp>>()
.parsed_body::<ResultsPage<views::ExternalIp>>()
.expect("Failed to parse external IPs");
assert_eq!(ips.len(), 1);
assert_eq!(ips[0].kind, IpKind::Ephemeral);
assert_eq!(ips.items.len(), 1);
assert_eq!(ips.items[0].kind, IpKind::Ephemeral);
assert!(
ips[0].ip >= second_range.first_address()
&& ips[0].ip <= second_range.last_address(),
ips.items[0].ip >= second_range.first_address()
&& ips.items[0].ip <= second_range.last_address(),
"Expected the Ephemeral IP to come from the second address \
range, since the first is reserved for a project different from \
the instance's project."
Expand Down
27 changes: 22 additions & 5 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2972,11 +2972,7 @@
"content": {
"application/json": {
"schema": {
"title": "Array_of_ExternalIp",
"type": "array",
"items": {
"$ref": "#/components/schemas/ExternalIp"
}
"$ref": "#/components/schemas/ExternalIpResultsPage"
}
}
}
Expand Down Expand Up @@ -7261,6 +7257,27 @@
}
]
},
"ExternalIpResultsPage": {
"description": "A single page of results",
"type": "object",
"properties": {
"items": {
"description": "list of items on this page of results",
"type": "array",
"items": {
"$ref": "#/components/schemas/ExternalIp"
}
},
"next_page": {
"nullable": true,
"description": "token used to fetch the next page of results (if any)",
"type": "string"
}
},
"required": [
"items"
]
},
"FieldSchema": {
"description": "The name and type information for a field of a timeseries schema.",
"type": "object",
Expand Down

0 comments on commit 6d8d6a4

Please sign in to comment.