Skip to content

Use sled inventory to build sled agent clients - #11197

Merged
internet-diglett merged 3 commits into
mainfrom
bugfix-10958-alternate
Sep 1, 2026
Merged

Use sled inventory to build sled agent clients#11197
internet-diglett merged 3 commits into
mainfrom
bugfix-10958-alternate

Conversation

@internet-diglett

Copy link
Copy Markdown
Contributor

An alternative fix to #10958 (first attempt at a fix is #11172)

Instead of deriving sled agent addresses from switch zone service addresses (which does not work in the test context), pull the sled agent information from the inventory records in the database.

Instead of deriving sled agent addresses from
switch zone service addresses (which does not
work in the test context), pull the sled agent
information from the inventory records in the
database.

@jgallagher jgallagher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think this is a lot better solution generally than 10958.

Just a few nits, mostly about test flakiness.

Comment on lines +101 to +104
let sled_agent_addrs: Vec<_> = sleds.into_iter().map(|s| s.address()).collect();

// TODO https://github.com/oxidecomputer/omicron/issues/5201
// build sled agent clients for sleds that are connected to the switches
let scrimlet_sled_agent_clients = build_sled_agent_clients(&mappings, &log);
let sled_agent_clients = build_sled_agent_clients(&sled_agent_addrs, &log);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicky, but we build two Vec<_>s here (a vec of addresses and then a vec of clients); we can definitely get away with just one, and I think if I'm reading it correctly we could get away with neither. build_sled_agent_clients() isn't buying us much anymore - I think if we inlined client creation we could construct an iterator here and avoid both vecs. Untested but something like

let sled_agent_clients = sleds.into_iter().map(|s| {
    sled_agent_client::Client::new(
        &format!("http://{}", s.address()),
        log.clone(),
    )
}); // no collect()

which is then consumed by the loop below that uses the clients?

// Check the sim sled-agent's in-memory bootstore was actually updated,
// confirming it was successfully contacted.
let bootstore_generation = ctx
.first_sled_agent()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know that in the nexus-test / sim-sled-agent case, the first sled-agent is always going to be updated? This test has two sled-agents (from #[nexus_test(extra_sled_agents = 1)]) - even if the sim-sled-agents do bootstore replication (no idea if they do), this test might be flaky if the task sent the request to the second sled-agent then we look at the first one here before it replicates.

Maybe we should check both sled agents and succeed if either of them have the correct generation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the sim sled-agents are doing bootstore replication (which now that I think of it, this is going to be a problem for JBOR, because we need both scrimlet sled agents to get the updates so we can do proper integration testing)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bringing an out-of-band convo here:

We will update this to fetch all sleds from inventory, filter on is_scrimlet(), and apply the updates to all scrimlets. The test should assert that both scrimlet sled agents have received the update.

This is similar to the current production behavior and will ensure that we can get a reliable test and dev environment working.

.unwrap()
.generation;
assert!(
bootstore_generation > 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for the exact generation the task should have written? Even if sim-sled-agent starts out at generation 0 today (which seems a little weird / surprising), a future change could have it start out at 1, which means this test would always pass even if the task breaks.

@internet-diglett

Copy link
Copy Markdown
Contributor Author

@jgallagher I believe the latest commit hits all of the things you called out, let me know what you think

@jgallagher jgallagher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

// confirming both scrimlets were successfully contacted.
for (i, sled_agent) in ctx.sled_agents.iter().enumerate() {
let sled_agent = sled_agent.sled_agent().clone();
wait_for_condition(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maaaaybe worth pulling this out into a helper function since we have it twice? wait_for_sled_agent_bootstore_generation(&sled_agent, 4).await or something like that? I don't feel strongly though, up to you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do!

@internet-diglett
internet-diglett enabled auto-merge (squash) September 1, 2026 21:08
@internet-diglett
internet-diglett merged commit 7683e26 into main Sep 1, 2026
19 checks passed
@internet-diglett
internet-diglett deleted the bugfix-10958-alternate branch September 1, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants