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

[sled-agent] PUT zones doesn't create datasets #7006

Merged
merged 32 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
73bd549
Use local properties when querying oxide values
smklein Nov 5, 2024
2f448f0
Better dataset population during RSS
smklein Nov 5, 2024
a7c6f1b
adding debug, zone datasets too
smklein Nov 5, 2024
a62b283
Merge branch 'main' into rss-datasets
smklein Nov 5, 2024
9a9fe45
Add tests for plan creation, ensuring datasets are populated
smklein Nov 6, 2024
5a92eac
Merge branch 'main' into rss-datasets
smklein Nov 7, 2024
ce7ec38
Stop creating datasets during omicron_zones_ensure
smklein Nov 7, 2024
2aa4a0e
Merge branch 'main' into rss-datasets
smklein Nov 7, 2024
0fb92ed
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 7, 2024
ebdad20
Unused import
smklein Nov 7, 2024
6506ce0
Merge branch 'main' into rss-datasets
smklein Nov 7, 2024
b100385
merge
smklein Nov 7, 2024
9ef56f3
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 7, 2024
2b73938
Checking
smklein Nov 8, 2024
920ecff
Patch comments
smklein Nov 8, 2024
784e377
fmt
smklein Nov 8, 2024
d1a6bd0
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 8, 2024
96bf17f
Merge branch 'main' into rss-datasets
smklein Nov 8, 2024
70040af
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 8, 2024
6f6a87c
Bail on generation number conflict
smklein Nov 8, 2024
9989a4b
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 8, 2024
084d6f8
More consistent usage of Gzip-9 for debug dataset
smklein Nov 8, 2024
03ea021
Merge branch 'main' into rss-datasets
smklein Nov 8, 2024
264afd0
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 8, 2024
1ae6ba7
EXPECTORATE
smklein Nov 8, 2024
afefc2e
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 8, 2024
754eae8
Merge branch 'main' into rss-datasets
smklein Nov 14, 2024
dd73204
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 14, 2024
5514606
Create empty ledger for service tests that want to read it
smklein Nov 14, 2024
aed7cf0
Merge branch 'main' into rss-datasets
smklein Nov 18, 2024
95993ef
Merge branch 'rss-datasets' into put-zones-doesnt-put-datasets
smklein Nov 18, 2024
c3401f2
Review feedback
smklein Nov 18, 2024
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
1 change: 1 addition & 0 deletions common/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl<T: Ledgerable> Ledger<T> {
warn!(self.log, "Failed to write ledger"; "path" => ?path, "err" => ?e);
failed_paths.push((path.to_path_buf(), e));
} else {
info!(self.log, "Successfully wrote to ledger"; "path" => ?path);
one_successful_write = true;
}
}
Expand Down
74 changes: 74 additions & 0 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ pub enum Error {
#[error("Error querying simnet devices")]
Simnet(#[from] GetSimnetError),

#[error("Failed to access storage")]
Storage(#[from] sled_storage::error::Error),

#[error("Missing datasets: {datasets:?}")]
MissingDatasets { datasets: HashSet<DatasetName> },
smklein marked this conversation as resolved.
Show resolved Hide resolved

#[error(
"Requested generation ({requested}) is older than current ({current})"
)]
Expand Down Expand Up @@ -3470,6 +3476,59 @@ impl ServiceManager {
Ok(())
}

// Compares the incoming set of zones with the datasets this sled is
// configured to use.
//
// If the requested zones contain any datasets not configured on this sled,
// an error is returned.
async fn check_requested_zone_datasets_exist(
&self,
request: &OmicronZonesConfig,
) -> Result<(), Error> {
// Before we provision these zones, inspect the request, and
// check all the datasets we're trying to make.
let mut requested_datasets = HashSet::new();
for zone in &request.zones {
if let Some(dataset) = zone.dataset_name() {
requested_datasets.insert(dataset);
}

if let Some(pool) = zone.filesystem_pool.as_ref() {
requested_datasets.insert(DatasetName::new(
smklein marked this conversation as resolved.
Show resolved Hide resolved
pool.clone(),
DatasetKind::TransientZone {
name: illumos_utils::zone::zone_name(
zone.zone_type.kind().zone_prefix(),
Some(zone.id),
),
},
));
}
}

// These datasets are configured to be part of the control plane.
let datasets_config = self.inner.storage.datasets_config_list().await?;
let existing_datasets: HashSet<_> = datasets_config
smklein marked this conversation as resolved.
Show resolved Hide resolved
.datasets
.into_values()
.map(|config| config.name)
.collect();

// Check that the request is no larger than the configured set.
//
// (It's fine to have "existing_datasets" not contained in the
// request set).
let missing_datasets: HashSet<_> = requested_datasets
.difference(&existing_datasets)
.cloned()
.collect();
if !missing_datasets.is_empty() {
warn!(self.inner.log, "Missing datasets: {missing_datasets:?}");
return Err(Error::MissingDatasets { datasets: missing_datasets });
}
Ok(())
}

// Ensures that only the following Omicron zones are running.
//
// This method strives to be idempotent.
Expand All @@ -3493,6 +3552,8 @@ impl ServiceManager {
new_request: OmicronZonesConfig,
fake_install_dir: Option<&String>,
) -> Result<(), Error> {
self.check_requested_zone_datasets_exist(&new_request).await?;

// Do some data-normalization to ensure we can compare the "requested
// set" vs the "existing set" as HashSets.
let old_zone_configs: HashSet<OmicronZoneConfig> = existing_zones
Expand Down Expand Up @@ -4694,6 +4755,7 @@ mod illumos_tests {
zone::MockZones,
};

use omicron_common::disk::DatasetsConfig;
use omicron_uuid_kinds::OmicronZoneUuid;
use sled_storage::manager_test_harness::StorageManagerTestHarness;
use std::os::unix::process::ExitStatusExt;
Expand Down Expand Up @@ -5039,6 +5101,18 @@ mod illumos_tests {
.await
.expect("Failed to ensure disks");
assert!(!result.has_error(), "{:?}", result);
let result = harness
smklein marked this conversation as resolved.
Show resolved Hide resolved
.handle()
.datasets_ensure(DatasetsConfig {
generation: Generation::new(),
datasets: BTreeMap::new(),
})
.await
.unwrap();
assert!(
!result.has_error(),
"Failed to ensure empty dataset ledger: {result:?}"
);
harness
}

Expand Down
19 changes: 0 additions & 19 deletions sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::metrics::MetricsManager;
use crate::nexus::{
NexusClient, NexusNotifierHandle, NexusNotifierInput, NexusNotifierTask,
};
use crate::params::OmicronZoneTypeExt;
use crate::probe_manager::ProbeManager;
use crate::services::{self, ServiceManager};
use crate::storage_monitor::StorageMonitorHandle;
Expand Down Expand Up @@ -943,24 +942,6 @@ impl SledAgent {
&self,
requested_zones: OmicronZonesConfig,
) -> Result<(), Error> {
// TODO(https://github.com/oxidecomputer/omicron/issues/6043):
// - If these are the set of filesystems, we should also consider
// removing the ones which are not listed here.
// - It's probably worth sending a bulk request to the storage system,
// rather than requesting individual datasets.
for zone in &requested_zones.zones {
let Some(dataset_name) = zone.dataset_name() else {
continue;
};

// First, ensure the dataset exists
let dataset_id = zone.id.into_untyped_uuid();
self.inner
.storage
.upsert_filesystem(dataset_id, dataset_name)
.await?;
}
smklein marked this conversation as resolved.
Show resolved Hide resolved

self.inner
.services
.ensure_all_omicron_zones_persistent(requested_zones, None)
Expand Down
10 changes: 8 additions & 2 deletions sled-storage/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ impl StorageManager {
let ledger_paths = self.all_omicron_dataset_ledgers().await;
let maybe_ledger =
Ledger::<DatasetsConfig>::new(&log, ledger_paths.clone()).await;
let had_old_ledger = maybe_ledger.is_some();

let mut ledger = match maybe_ledger {
Some(ledger) => {
Expand Down Expand Up @@ -914,7 +915,11 @@ impl StorageManager {
let result = self.datasets_ensure_internal(&log, &config).await;

let ledger_data = ledger.data_mut();
if *ledger_data == config {
if had_old_ledger && *ledger_data == config {
smklein marked this conversation as resolved.
Show resolved Hide resolved
info!(
log,
"Skipping dataset ledger update because nothing changed"
);
return Ok(result);
}
*ledger_data = config;
Expand Down Expand Up @@ -1142,6 +1147,7 @@ impl StorageManager {
ledger_paths.clone(),
)
.await;
let had_old_ledger = maybe_ledger.is_some();

let mut ledger = match maybe_ledger {
Some(ledger) => {
Expand Down Expand Up @@ -1181,7 +1187,7 @@ impl StorageManager {
self.omicron_physical_disks_ensure_internal(&log, &config).await?;

let ledger_data = ledger.data_mut();
if *ledger_data == config {
if had_old_ledger && *ledger_data == config {
smklein marked this conversation as resolved.
Show resolved Hide resolved
return Ok(result);
}
*ledger_data = config;
Expand Down
Loading