Skip to content

Commit 8d75b60

Browse files
authored
remove bgtask_activate from nexus-internal (#9159)
This was intended to be moved to nexus-lockstep in #9037 but the probe manager uses it. This replaces the API call with a more specific doorbell to prevent arbitrary background task names from being part of nexus-internal's API. Related to #9157 and #8902.
1 parent 47dac8d commit 8d75b60

File tree

5 files changed

+56
-86
lines changed

5 files changed

+56
-86
lines changed

nexus/internal-api/src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,6 @@ pub trait NexusInternalApi {
225225
downstairs_client_stopped: TypedBody<DownstairsClientStopped>,
226226
) -> Result<HttpResponseUpdatedNoContent, HttpError>;
227227

228-
/// **Do not use in new code!**
229-
///
230-
/// Callers to this API should either be capable of using the nexus-lockstep
231-
/// API or should be rewritten to use a doorbell API to activate a specific
232-
/// task. Task names are internal to Nexus.
233-
#[endpoint {
234-
method = POST,
235-
path = "/bgtasks/activate",
236-
}]
237-
async fn bgtask_activate(
238-
rqctx: RequestContext<Self::Context>,
239-
body: TypedBody<BackgroundTasksActivateRequest>,
240-
) -> Result<HttpResponseUpdatedNoContent, HttpError>;
241-
242228
// NAT RPW internal APIs
243229

244230
/// Fetch NAT ChangeSet
@@ -259,6 +245,9 @@ pub trait NexusInternalApi {
259245
) -> Result<HttpResponseOk<Vec<NatEntryView>>, HttpError>;
260246

261247
/// Get all the probes associated with a given sled.
248+
///
249+
/// This should not be used in new code, and abandoned if a change is
250+
/// required. See #9157.
262251
#[endpoint {
263252
method = GET,
264253
path = "/probes/{sled}"
@@ -268,6 +257,18 @@ pub trait NexusInternalApi {
268257
path_params: Path<ProbePathParam>,
269258
query_params: Query<PaginatedById>,
270259
) -> Result<HttpResponseOk<Vec<ProbeInfo>>, HttpError>;
260+
261+
/// Request that Nexus refreshes VPC routes.
262+
///
263+
/// This should not be used in new code, and abandoned if a change is
264+
/// required. See #9157.
265+
#[endpoint {
266+
method = POST,
267+
path = "/refresh-vpc-routes"
268+
}]
269+
async fn refresh_vpc_routes(
270+
rqctx: RequestContext<Self::Context>,
271+
) -> Result<HttpResponseUpdatedNoContent, HttpError>;
271272
}
272273

273274
/// Path parameters for Sled Agent requests (internal API)

nexus/src/app/probe.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,10 @@ impl super::Nexus {
131131
project_lookup.lookup_for(authz::Action::CreateChild).await?;
132132
self.db_datastore.probe_delete(opctx, &authz_project, &name_or_id).await
133133
}
134+
135+
/// Activate the VPC route manager background task by request of a sled
136+
/// agent's probe manager.
137+
pub(crate) fn refresh_vpc_routes(&self) {
138+
self.background_tasks.task_vpc_route_manager.activate();
139+
}
134140
}

nexus/src/internal_api/http_entrypoints.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -410,25 +410,6 @@ impl NexusInternalApi for NexusInternalApiImpl {
410410
.await
411411
}
412412

413-
async fn bgtask_activate(
414-
rqctx: RequestContext<Self::Context>,
415-
body: TypedBody<BackgroundTasksActivateRequest>,
416-
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
417-
let apictx = &rqctx.context().context;
418-
let handler = async {
419-
let opctx =
420-
crate::context::op_context_for_internal_api(&rqctx).await;
421-
let nexus = &apictx.nexus;
422-
let body = body.into_inner();
423-
nexus.bgtask_activate(&opctx, body.bgtask_names).await?;
424-
Ok(HttpResponseUpdatedNoContent())
425-
};
426-
apictx
427-
.internal_latencies
428-
.instrument_dropshot_handler(&rqctx, handler)
429-
.await
430-
}
431-
432413
// NAT RPW internal APIs
433414

434415
async fn ipv4_nat_changeset(
@@ -480,4 +461,18 @@ impl NexusInternalApi for NexusInternalApiImpl {
480461
.instrument_dropshot_handler(&rqctx, handler)
481462
.await
482463
}
464+
465+
async fn refresh_vpc_routes(
466+
rqctx: RequestContext<Self::Context>,
467+
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
468+
let apictx = &rqctx.context().context;
469+
let handler = async {
470+
apictx.nexus.refresh_vpc_routes();
471+
Ok(HttpResponseUpdatedNoContent())
472+
};
473+
apictx
474+
.internal_latencies
475+
.instrument_dropshot_handler(&rqctx, handler)
476+
.await
477+
}
483478
}

openapi/nexus-internal.json

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,6 @@
1010
"version": "0.0.1"
1111
},
1212
"paths": {
13-
"/bgtasks/activate": {
14-
"post": {
15-
"summary": "**Do not use in new code!**",
16-
"description": "Callers to this API should either be capable of using the nexus-lockstep API or should be rewritten to use a doorbell API to activate a specific task. Task names are internal to Nexus.",
17-
"operationId": "bgtask_activate",
18-
"requestBody": {
19-
"content": {
20-
"application/json": {
21-
"schema": {
22-
"$ref": "#/components/schemas/BackgroundTasksActivateRequest"
23-
}
24-
}
25-
},
26-
"required": true
27-
},
28-
"responses": {
29-
"204": {
30-
"description": "resource updated"
31-
},
32-
"4XX": {
33-
"$ref": "#/components/responses/Error"
34-
},
35-
"5XX": {
36-
"$ref": "#/components/responses/Error"
37-
}
38-
}
39-
}
40-
},
4113
"/crucible/0/upstairs/{upstairs_id}/downstairs/{downstairs_id}/stop-request": {
4214
"post": {
4315
"summary": "An Upstairs will update this endpoint if a Downstairs client task is",
@@ -497,6 +469,7 @@
497469
"/probes/{sled}": {
498470
"get": {
499471
"summary": "Get all the probes associated with a given sled.",
472+
"description": "This should not be used in new code, and abandoned if a change is required. See #9157.",
500473
"operationId": "probes_get",
501474
"parameters": [
502475
{
@@ -563,6 +536,24 @@
563536
}
564537
}
565538
},
539+
"/refresh-vpc-routes": {
540+
"post": {
541+
"summary": "Request that Nexus refreshes VPC routes.",
542+
"description": "This should not be used in new code, and abandoned if a change is required. See #9157.",
543+
"operationId": "refresh_vpc_routes",
544+
"responses": {
545+
"204": {
546+
"description": "resource updated"
547+
},
548+
"4XX": {
549+
"$ref": "#/components/responses/Error"
550+
},
551+
"5XX": {
552+
"$ref": "#/components/responses/Error"
553+
}
554+
}
555+
}
556+
},
566557
"/sled-agents/{sled_id}": {
567558
"get": {
568559
"summary": "Return information about the given sled agent",
@@ -769,22 +760,6 @@
769760
},
770761
"components": {
771762
"schemas": {
772-
"BackgroundTasksActivateRequest": {
773-
"description": "Query parameters for Background Task activation requests.",
774-
"type": "object",
775-
"properties": {
776-
"bgtask_names": {
777-
"type": "array",
778-
"items": {
779-
"type": "string"
780-
},
781-
"uniqueItems": true
782-
}
783-
},
784-
"required": [
785-
"bgtask_names"
786-
]
787-
},
788763
"Baseboard": {
789764
"description": "Properties that uniquely identify an Oxide hardware component",
790765
"type": "object",

sled-agent/src/probe_manager.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use illumos_utils::link::VnicAllocator;
66
use illumos_utils::opte::{DhcpCfg, PortCreateParams, PortManager};
77
use illumos_utils::running_zone::{RunningZone, ZoneBuilderFactory};
88
use illumos_utils::zpool::ZpoolOrRamdisk;
9-
use nexus_client::types::{
10-
BackgroundTasksActivateRequest, ProbeExternalIp, ProbeInfo,
11-
};
9+
use nexus_client::types::{ProbeExternalIp, ProbeInfo};
1210
use omicron_common::api::external::{
1311
VpcFirewallRuleAction, VpcFirewallRuleDirection, VpcFirewallRulePriority,
1412
VpcFirewallRuleStatus,
@@ -247,12 +245,7 @@ impl ProbeManagerInner {
247245
// If we have created some new probes, we may need the control plane
248246
// to provide us with valid routes for the VPC the probe belongs to.
249247
if n_added > 0 {
250-
if let Err(e) = self
251-
.nexus_client
252-
.bgtask_activate(&BackgroundTasksActivateRequest {
253-
bgtask_names: vec!["vpc_route_manager".into()],
254-
})
255-
.await
248+
if let Err(e) = self.nexus_client.refresh_vpc_routes().await
256249
{
257250
error!(self.log, "get routes for probe: {e}");
258251
}

0 commit comments

Comments
 (0)