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

Explicitly use the alloc op context for dpd nat updates #4654

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 3 additions & 2 deletions nexus/src/app/instance_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ impl super::Nexus {
pub(crate) async fn instance_delete_dpd_config(
&self,
opctx: &OpContext,
opctx_alloc: &OpContext,
zephraph marked this conversation as resolved.
Show resolved Hide resolved
authz_instance: &authz::Instance,
) -> Result<(), Error> {
let log = &self.log;
Expand All @@ -451,8 +452,6 @@ impl super::Nexus {
.instance_lookup_external_ips(opctx, instance_id)
.await?;

let boundary_switches = self.boundary_switches(opctx).await?;

let mut errors = vec![];
for entry in external_ips {
// Soft delete the NAT entry
Expand All @@ -478,6 +477,8 @@ impl super::Nexus {
}?;
}

let boundary_switches = self.boundary_switches(opctx_alloc).await?;

for switch in &boundary_switches {
debug!(&self.log, "notifying dendrite of updates";
"instance_id" => %authz_instance.id(),
Expand Down
6 changes: 5 additions & 1 deletion nexus/src/app/sagas/instance_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ async fn sid_delete_nat(

osagactx
.nexus()
.instance_delete_dpd_config(&opctx, &authz_instance)
.instance_delete_dpd_config(
&opctx,
&osagactx.nexus().opctx_alloc,
&authz_instance,
)
.await
.map_err(ActionError::action_failed)?;

Expand Down
6 changes: 5 additions & 1 deletion nexus/src/app/sagas/instance_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,11 @@ async fn sis_dpd_ensure_undo(

osagactx
.nexus()
.instance_delete_dpd_config(&opctx, &authz_instance)
.instance_delete_dpd_config(
&opctx,
&osagactx.nexus().opctx_alloc,
&authz_instance,
)
.await?;

Ok(())
Expand Down
24 changes: 24 additions & 0 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3913,6 +3913,30 @@ async fn test_instance_create_in_silo(cptestctx: &ControlPlaneTestContext) {
instance_simulate_with_opctx(nexus, &instance.identity.id, &opctx).await;
let instance = instance_get_as(&client, &instance_url, authn).await;
assert_eq!(instance.runtime.run_state, InstanceState::Running);

// Stop the instance
NexusRequest::new(
RequestBuilder::new(
client,
Method::POST,
&format!("/v1/instances/{}/stop", instance.identity.id),
)
.body(None as Option<&serde_json::Value>)
.expect_status(Some(StatusCode::ACCEPTED)),
)
.authn_as(AuthnMode::SiloUser(user_id))
.execute()
.await
.expect("Failed to stop the instance");

instance_simulate_with_opctx(nexus, &instance.identity.id, &opctx).await;

// Delete the instance
NexusRequest::object_delete(client, &instance_url)
.authn_as(AuthnMode::SiloUser(user_id))
.execute()
.await
.expect("Failed to delete the instance");
}

/// Test that appropriate OPTE V2P mappings are created and deleted.
Expand Down
Loading