Skip to content

Commit

Permalink
Use elevated opcontext for plumbing firewall rules after allowlist up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
bnaecker committed May 3, 2024
1 parent 46c558b commit 8386fb4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dev-tools/xtask/src/virtual_hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ pub struct Pxa {
/// The first IP address your Oxide cluster can use.
///
/// Requires `pxa-end`.
#[clap(long = "pxa-start", requires = "end")]
#[clap(long = "pxa-start", requires = "end", env = "PXA_START")]
start: Option<String>,

/// The last IP address your Oxide cluster can use
///
/// Requires `pxa-start`.
#[clap(long = "pxa-end", requires = "start")]
#[clap(long = "pxa-end", requires = "start", env = "PXA_END")]
end: Option<String>,
}

Expand Down
25 changes: 21 additions & 4 deletions nexus/src/app/allowed_source_ips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,34 @@ impl super::Nexus {

// Actually insert the new allowlist.
self.db_datastore
.allowed_source_ips_upsert(opctx, params.allowed_ips)
.allowed_source_ips_upsert(opctx, params.allowed_ips.clone())
.await
.map(|_| ())?;

// Notify the sled-agents of the updated firewall rules.
//
// Importantly, we need to use a different `opctx` from that we're
// passed in here. This call requires access to Oxide-internal data
// around our VPC, and so we must use a context that's authorized for
// that.
//
// TODO-correctness: It's unfortunate that we're using this new logger,
// since that means we lose things like the original actor and request
// ID. It would be great if we could insert additional key-value pairs
// into the logger itself here, or "merge" the two in some other way.
info!(
opctx.log,
"updated user-facing services allow list, switching to \
internal opcontext to plumb rules to sled-agents";
"new_allowlist" => ?params.allowed_ips,
);
let new_opctx = self.opctx_for_internal_api();
match nexus_networking::plumb_service_firewall_rules(
self.datastore(),
&opctx,
&new_opctx,
&[],
&opctx,
&opctx.log,
&new_opctx,
&new_opctx.log,
)
.await
{
Expand Down

0 comments on commit 8386fb4

Please sign in to comment.