From 84134832bc96d41936a6af7e1d1962e7b0dfef97 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Thu, 23 Dec 2021 15:46:46 -0500 Subject: [PATCH 1/4] Gracefully terminate CRDB --- Cargo.lock | 14 ++++++++++++++ test-utils/Cargo.toml | 1 + test-utils/src/dev/db.rs | 9 +++++---- test-utils/src/dev/mod.rs | 14 ++++++++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d0c748d377..8a9526c8241 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1816,6 +1816,19 @@ dependencies = [ "syn", ] +[[package]] +name = "nix" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -2064,6 +2077,7 @@ dependencies = [ "expectorate", "futures", "libc", + "nix", "omicron-common", "postgres-protocol", "signal-hook", diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index 31b9c7466c8..e43ff9bc5d4 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -8,6 +8,7 @@ license = "MPL-2.0" anyhow = "1.0" futures = "0.3.18" libc = "0.2.111" +nix = "0.23" omicron-common = { path = "../common" } postgres-protocol = "0.6.3" signal-hook = "0.3" diff --git a/test-utils/src/dev/db.rs b/test-utils/src/dev/db.rs index 88361210bfa..e9520d6870e 100644 --- a/test-utils/src/dev/db.rs +++ b/test-utils/src/dev/db.rs @@ -8,6 +8,7 @@ use crate::dev::poll; use anyhow::anyhow; use anyhow::bail; use anyhow::Context; +use nix::{sys::signal, unistd::Pid}; use omicron_common::config::PostgresConfigWithUrl; use std::ffi::{OsStr, OsString}; use std::fmt; @@ -527,14 +528,14 @@ impl CockroachInstance { */ pub async fn cleanup(&mut self) -> Result<(), anyhow::Error> { /* - * Kill the process and wait for it to exit so that we can remove the + * SIGTERM the process and wait for it to exit so that we can remove the * temporary directory that we may have used to store its data. We * don't care what the result of the process was. */ if let Some(child_process) = self.child_process.as_mut() { - child_process - .start_kill() - .context("sending SIGKILL to child process")?; + let pid = Pid::from_raw(child_process.id().expect("Missing child PID") as i32); + + signal::kill(pid, signal::SIGTERM).context("Failed to send sigterm to process")?; child_process.wait().await.context("waiting for child process")?; self.child_process = None; } diff --git a/test-utils/src/dev/mod.rs b/test-utils/src/dev/mod.rs index 7749ed1ce70..2ddabe6051a 100644 --- a/test-utils/src/dev/mod.rs +++ b/test-utils/src/dev/mod.rs @@ -102,6 +102,15 @@ pub async fn test_setup_database_seed(log: &Logger) { std::fs::create_dir_all(&dir).unwrap(); let mut db = setup_database(log, Some(&dir), StorageSource::Populate).await; db.cleanup().await.unwrap(); + + // See https://github.com/cockroachdb/cockroach/issues/74231 for context on + // this. We use this assertion to check that our seed directory won't point + // back to itself, even if it is copied elsewhere. + assert_eq!( + 0, + dir.join("temp-dirs-record.txt").metadata().expect("Cannot access metadata").len(), + "Temporary directory record should be empty after graceful shutdown", + ); } /// Set up a [`db::CockroachInstance`] for running tests. @@ -131,11 +140,12 @@ async fn setup_database( // If we're going to copy the storage directory from the seed, // it is critical we do so before starting the DB. if matches!(storage_source, StorageSource::CopyFromSeed) { + let seed = seed_dir(); info!(&log, "cockroach: copying from seed directory ({}) to storage directory ({})", - seed_dir().to_string_lossy(), starter.store_dir().to_string_lossy(), + seed.to_string_lossy(), starter.store_dir().to_string_lossy(), ); - copy_dir(seed_dir(), starter.store_dir()) + copy_dir(seed, starter.store_dir()) .expect("Cannot copy storage from seed directory"); } From 3d266bae8a655293fb5402c5ad5175bf188e2064 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Thu, 23 Dec 2021 15:48:07 -0500 Subject: [PATCH 2/4] fmt --- test-utils/src/dev/db.rs | 7 +++++-- test-utils/src/dev/mod.rs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test-utils/src/dev/db.rs b/test-utils/src/dev/db.rs index e9520d6870e..5069ee1c3a2 100644 --- a/test-utils/src/dev/db.rs +++ b/test-utils/src/dev/db.rs @@ -533,9 +533,12 @@ impl CockroachInstance { * don't care what the result of the process was. */ if let Some(child_process) = self.child_process.as_mut() { - let pid = Pid::from_raw(child_process.id().expect("Missing child PID") as i32); + let pid = Pid::from_raw( + child_process.id().expect("Missing child PID") as i32, + ); - signal::kill(pid, signal::SIGTERM).context("Failed to send sigterm to process")?; + signal::kill(pid, signal::SIGTERM) + .context("Failed to send sigterm to process")?; child_process.wait().await.context("waiting for child process")?; self.child_process = None; } diff --git a/test-utils/src/dev/mod.rs b/test-utils/src/dev/mod.rs index 2ddabe6051a..efb9b7df437 100644 --- a/test-utils/src/dev/mod.rs +++ b/test-utils/src/dev/mod.rs @@ -108,7 +108,10 @@ pub async fn test_setup_database_seed(log: &Logger) { // back to itself, even if it is copied elsewhere. assert_eq!( 0, - dir.join("temp-dirs-record.txt").metadata().expect("Cannot access metadata").len(), + dir.join("temp-dirs-record.txt") + .metadata() + .expect("Cannot access metadata") + .len(), "Temporary directory record should be empty after graceful shutdown", ); } From 42030b67618931b89aab7bde286a68803ae0d8c4 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 27 Dec 2021 10:54:09 -0500 Subject: [PATCH 3/4] Remove nix, use unsafe libc instead --- Cargo.lock | 14 -------------- test-utils/Cargo.toml | 1 - test-utils/src/dev/db.rs | 13 ++++++------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a9526c8241..7d0c748d377 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1816,19 +1816,6 @@ dependencies = [ "syn", ] -[[package]] -name = "nix" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "memoffset", -] - [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -2077,7 +2064,6 @@ dependencies = [ "expectorate", "futures", "libc", - "nix", "omicron-common", "postgres-protocol", "signal-hook", diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index e43ff9bc5d4..31b9c7466c8 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -8,7 +8,6 @@ license = "MPL-2.0" anyhow = "1.0" futures = "0.3.18" libc = "0.2.111" -nix = "0.23" omicron-common = { path = "../common" } postgres-protocol = "0.6.3" signal-hook = "0.3" diff --git a/test-utils/src/dev/db.rs b/test-utils/src/dev/db.rs index 5069ee1c3a2..47291062a31 100644 --- a/test-utils/src/dev/db.rs +++ b/test-utils/src/dev/db.rs @@ -8,7 +8,6 @@ use crate::dev::poll; use anyhow::anyhow; use anyhow::bail; use anyhow::Context; -use nix::{sys::signal, unistd::Pid}; use omicron_common::config::PostgresConfigWithUrl; use std::ffi::{OsStr, OsString}; use std::fmt; @@ -533,12 +532,12 @@ impl CockroachInstance { * don't care what the result of the process was. */ if let Some(child_process) = self.child_process.as_mut() { - let pid = Pid::from_raw( - child_process.id().expect("Missing child PID") as i32, - ); - - signal::kill(pid, signal::SIGTERM) - .context("Failed to send sigterm to process")?; + let pid = child_process.id().expect("Missing child PID") as i32; + let success = + 0 == unsafe { libc::kill(pid as libc::pid_t, libc::SIGTERM) }; + if !success { + anyhow!("Failed to send SIGTERM to DB"); + } child_process.wait().await.context("waiting for child process")?; self.child_process = None; } From 97741030badcb0854a8aefef0429caa57345a17d Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 27 Dec 2021 13:30:05 -0500 Subject: [PATCH 4/4] Generate crdb-base in OUT_DIR, rather than tmp_dir --- nexus/benches/setup_benchmark.rs | 3 ++- nexus/src/authz/context.rs | 5 +++-- nexus/src/context.rs | 5 +++-- nexus/src/db/collection_insert.rs | 5 +++-- nexus/src/db/datastore.rs | 5 +++-- nexus/src/db/pagination.rs | 9 ++++---- nexus/src/db/saga_recovery.rs | 3 ++- nexus/test-utils/build.rs | 7 +++++- nexus/test-utils/src/db.rs | 28 +++++++++++++++++++++++ nexus/test-utils/src/lib.rs | 3 ++- test-utils/src/dev/mod.rs | 37 +++++++++++-------------------- 11 files changed, 70 insertions(+), 40 deletions(-) create mode 100644 nexus/test-utils/src/db.rs diff --git a/nexus/benches/setup_benchmark.rs b/nexus/benches/setup_benchmark.rs index 738c2733109..c4c27bd2a97 100644 --- a/nexus/benches/setup_benchmark.rs +++ b/nexus/benches/setup_benchmark.rs @@ -6,6 +6,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use dropshot::test_util::LogContext; +use nexus_test_utils::db::test_setup_database; use omicron_test_utils::dev; // This is the default wrapper around most Nexus integration tests. @@ -19,7 +20,7 @@ async fn do_full_setup() { async fn do_crdb_setup() { let cfg = nexus_test_utils::load_test_config(); let logctx = LogContext::new("crdb_setup", &cfg.log); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; db.cleanup().await.unwrap(); } diff --git a/nexus/src/authz/context.rs b/nexus/src/authz/context.rs index cfd0fd45740..06cd20cb67b 100644 --- a/nexus/src/authz/context.rs +++ b/nexus/src/authz/context.rs @@ -124,6 +124,7 @@ mod test { use crate::authz::DATABASE; use crate::authz::FLEET; use crate::db::DataStore; + use nexus_test_utils::db::test_setup_database; use omicron_test_utils::dev; use std::sync::Arc; @@ -144,7 +145,7 @@ mod test { #[tokio::test] async fn test_database() { let logctx = dev::test_setup_log("test_database"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let (opctx, datastore) = crate::db::datastore::datastore_test(&logctx, &db).await; let authz_privileged = authz_context_for_actor( @@ -190,7 +191,7 @@ mod test { #[tokio::test] async fn test_organization() { let logctx = dev::test_setup_log("test_database"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let (opctx, datastore) = crate::db::datastore::datastore_test(&logctx, &db).await; diff --git a/nexus/src/context.rs b/nexus/src/context.rs index d98f0c14083..688a48a383b 100644 --- a/nexus/src/context.rs +++ b/nexus/src/context.rs @@ -341,6 +341,7 @@ mod test { use crate::authn; use crate::authz; use authz::Action; + use nexus_test_utils::db::test_setup_database; use omicron_common::api::external::Error; use omicron_test_utils::dev; use std::sync::Arc; @@ -348,7 +349,7 @@ mod test { #[tokio::test] async fn test_background_context() { let logctx = dev::test_setup_log("test_background_context"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let (_, datastore) = crate::db::datastore::datastore_test(&logctx, &db).await; let opctx = OpContext::for_background( @@ -380,7 +381,7 @@ mod test { #[tokio::test] async fn test_test_context() { let logctx = dev::test_setup_log("test_background_context"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let (_, datastore) = crate::db::datastore::datastore_test(&logctx, &db).await; let opctx = OpContext::for_unit_tests(logctx.log.new(o!()), datastore); diff --git a/nexus/src/db/collection_insert.rs b/nexus/src/db/collection_insert.rs index c866dc395fa..89de336a0f5 100644 --- a/nexus/src/db/collection_insert.rs +++ b/nexus/src/db/collection_insert.rs @@ -492,6 +492,7 @@ mod test { use diesel::expression_methods::ExpressionMethods; use diesel::pg::Pg; use diesel::QueryDsl; + use nexus_test_utils::db::test_setup_database; use omicron_test_utils::dev; table! { @@ -634,7 +635,7 @@ mod test { #[tokio::test] async fn test_collection_not_present() { let logctx = dev::test_setup_log("test_collection_not_present"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let cfg = db::Config { url: db.pg_config().clone() }; let pool = db::Pool::new(&cfg); @@ -699,7 +700,7 @@ mod test { #[tokio::test] async fn test_collection_present() { let logctx = dev::test_setup_log("test_collection_present"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let cfg = db::Config { url: db.pg_config().clone() }; let pool = db::Pool::new(&cfg); diff --git a/nexus/src/db/datastore.rs b/nexus/src/db/datastore.rs index 3776691a67c..02a7b010506 100644 --- a/nexus/src/db/datastore.rs +++ b/nexus/src/db/datastore.rs @@ -2353,6 +2353,7 @@ mod test { use crate::db::model::{ConsoleSession, Organization, Project}; use crate::external_api::params; use chrono::{Duration, Utc}; + use nexus_test_utils::db::test_setup_database; use omicron_common::api::external::{Error, IdentityMetadataCreateParams}; use omicron_test_utils::dev; use uuid::Uuid; @@ -2360,7 +2361,7 @@ mod test { #[tokio::test] async fn test_project_creation() { let logctx = dev::test_setup_log("test_project_creation"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let (opctx, datastore) = datastore_test(&logctx, &db).await; let organization = Organization::new(params::OrganizationCreate { identity: IdentityMetadataCreateParams { @@ -2393,7 +2394,7 @@ mod test { #[tokio::test] async fn test_session_methods() { let logctx = dev::test_setup_log("test_session_methods"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let (_, datastore) = datastore_test(&logctx, &db).await; let token = "a_token".to_string(); let session = ConsoleSession { diff --git a/nexus/src/db/pagination.rs b/nexus/src/db/pagination.rs index 3cb85fb3047..0c66a00a273 100644 --- a/nexus/src/db/pagination.rs +++ b/nexus/src/db/pagination.rs @@ -163,6 +163,7 @@ mod test { use async_bb8_diesel::{AsyncRunQueryDsl, AsyncSimpleConnection}; use diesel::SelectableHelper; use dropshot::PaginationOrder; + use nexus_test_utils::db::test_setup_database; use omicron_common::api::external::DataPageParams; use omicron_test_utils::dev; use std::num::NonZeroU32; @@ -241,7 +242,7 @@ mod test { async fn test_paginated_single_column_ascending() { let logctx = dev::test_setup_log("test_paginated_single_column_ascending"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let cfg = db::Config { url: db.pg_config().clone() }; let pool = db::Pool::new(&cfg); @@ -276,7 +277,7 @@ mod test { async fn test_paginated_single_column_descending() { let logctx = dev::test_setup_log("test_paginated_single_column_descending"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let cfg = db::Config { url: db.pg_config().clone() }; let pool = db::Pool::new(&cfg); @@ -311,7 +312,7 @@ mod test { async fn test_paginated_multicolumn_ascending() { let logctx = dev::test_setup_log("test_paginated_multicolumn_ascending"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let cfg = db::Config { url: db.pg_config().clone() }; let pool = db::Pool::new(&cfg); @@ -365,7 +366,7 @@ mod test { async fn test_paginated_multicolumn_descending() { let logctx = dev::test_setup_log("test_paginated_multicolumn_descending"); - let mut db = dev::test_setup_database(&logctx.log).await; + let mut db = test_setup_database(&logctx.log).await; let cfg = db::Config { url: db.pg_config().clone() }; let pool = db::Pool::new(&cfg); diff --git a/nexus/src/db/saga_recovery.rs b/nexus/src/db/saga_recovery.rs index a668b29b47a..37193199c4d 100644 --- a/nexus/src/db/saga_recovery.rs +++ b/nexus/src/db/saga_recovery.rs @@ -333,6 +333,7 @@ mod test { use crate::context::OpContext; use crate::db::test_utils::UnpluggableCockroachDbSecStore; use lazy_static::lazy_static; + use nexus_test_utils::db::test_setup_database; use omicron_test_utils::dev; use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use steno::{ @@ -372,7 +373,7 @@ mod test { async fn new_db( log: &slog::Logger, ) -> (dev::db::CockroachInstance, Arc) { - let db = dev::test_setup_database(&log).await; + let db = test_setup_database(&log).await; let cfg = crate::db::Config { url: db.pg_config().clone() }; let pool = Arc::new(db::Pool::new(&cfg)); let db_datastore = Arc::new(db::DataStore::new(Arc::clone(&pool))); diff --git a/nexus/test-utils/build.rs b/nexus/test-utils/build.rs index 3d7306bf87c..1cde7403d11 100644 --- a/nexus/test-utils/build.rs +++ b/nexus/test-utils/build.rs @@ -4,6 +4,8 @@ use dropshot::{test_util::LogContext, ConfigLogging, ConfigLoggingLevel}; use omicron_test_utils::dev::test_setup_database_seed; +use std::env; +use std::path::Path; // Creates a "pre-populated" CockroachDB storage directory, which // subsequent tests can copy instead of creating themselves. @@ -27,6 +29,9 @@ async fn main() { &ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }, ); - test_setup_database_seed(&logctx.log).await; + let seed = + Path::new(&env::var("OUT_DIR").expect("Missing output directory")) + .join("crdb-base"); + test_setup_database_seed(&logctx.log, &seed).await; logctx.cleanup_successful(); } diff --git a/nexus/test-utils/src/db.rs b/nexus/test-utils/src/db.rs new file mode 100644 index 00000000000..9b15569059f --- /dev/null +++ b/nexus/test-utils/src/db.rs @@ -0,0 +1,28 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +//! Database testing facilities. + +use omicron_test_utils::dev; +use slog::Logger; +use std::path::PathBuf; + +/// Path to the "seed" CockroachDB directory. +/// +/// Populating CockroachDB unfortunately isn't free - creation of +/// tables, indices, and users takes several seconds to complete. +/// +/// By creating a "seed" version of the database, we can cut down +/// on the time spent performing this operation. Instead, we opt +/// to copy the database from this seed location. +fn seed_dir() -> PathBuf { + PathBuf::from(concat!(env!("OUT_DIR"), "/crdb-base")) +} + +/// Wrapper around [`dev::test_setup_database`] which uses a a +/// seed directory provided at build-time. +pub async fn test_setup_database(log: &Logger) -> dev::db::CockroachInstance { + let dir = seed_dir(); + dev::test_setup_database(log, &dir).await +} diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index bb33fe24122..0788fab1054 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -21,6 +21,7 @@ use std::path::Path; use std::time::Duration; use uuid::Uuid; +pub mod db; pub mod http_testing; pub mod resource_helpers; @@ -93,7 +94,7 @@ pub async fn test_setup_with_config( let log = &logctx.log; /* Start up CockroachDB. */ - let database = dev::test_setup_database(log).await; + let database = db::test_setup_database(log).await; /* Start ClickHouse database server. */ let clickhouse = dev::clickhouse::ClickHouseInstance::new(0).await.unwrap(); diff --git a/test-utils/src/dev/mod.rs b/test-utils/src/dev/mod.rs index efb9b7df437..3a08caad44a 100644 --- a/test-utils/src/dev/mod.rs +++ b/test-utils/src/dev/mod.rs @@ -18,19 +18,7 @@ use dropshot::ConfigLogging; use dropshot::ConfigLoggingIfExists; use dropshot::ConfigLoggingLevel; use slog::Logger; -use std::path::{Path, PathBuf}; - -/// Path to the "seed" CockroachDB directory. -/// -/// Populating CockroachDB unfortunately isn't free - creation of -/// tables, indices, and users takes several seconds to complete. -/// -/// By creating a "seed" version of the database, we can cut down -/// on the time spent performing this operation. Instead, we opt -/// to copy the database from this seed location. -fn seed_dir() -> PathBuf { - std::env::temp_dir().join("crdb-base") -} +use std::path::Path; // Helper for copying all the files in one directory to another. fn copy_dir( @@ -96,11 +84,10 @@ enum StorageSource { /// /// This is intended to optimize subsequent calls to [`test_setup_database`] /// by reducing the latency of populating the storage directory. -pub async fn test_setup_database_seed(log: &Logger) { - let dir = seed_dir(); +pub async fn test_setup_database_seed(log: &Logger, dir: &Path) { let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); - let mut db = setup_database(log, Some(&dir), StorageSource::Populate).await; + let mut db = setup_database(log, dir, StorageSource::Populate).await; db.cleanup().await.unwrap(); // See https://github.com/cockroachdb/cockroach/issues/74231 for context on @@ -117,18 +104,21 @@ pub async fn test_setup_database_seed(log: &Logger) { } /// Set up a [`db::CockroachInstance`] for running tests. -pub async fn test_setup_database(log: &Logger) -> db::CockroachInstance { - setup_database(log, None, StorageSource::CopyFromSeed).await +pub async fn test_setup_database( + log: &Logger, + dir: &Path, +) -> db::CockroachInstance { + setup_database(log, dir, StorageSource::CopyFromSeed).await } async fn setup_database( log: &Logger, - store_dir: Option<&Path>, + seed_dir: &Path, storage_source: StorageSource, ) -> db::CockroachInstance { let builder = db::CockroachStarterBuilder::new(); - let mut builder = if let Some(store_dir) = store_dir { - builder.store_dir(store_dir) + let mut builder = if matches!(storage_source, StorageSource::Populate) { + builder.store_dir(seed_dir) } else { builder }; @@ -143,12 +133,11 @@ async fn setup_database( // If we're going to copy the storage directory from the seed, // it is critical we do so before starting the DB. if matches!(storage_source, StorageSource::CopyFromSeed) { - let seed = seed_dir(); info!(&log, "cockroach: copying from seed directory ({}) to storage directory ({})", - seed.to_string_lossy(), starter.store_dir().to_string_lossy(), + seed_dir.to_string_lossy(), starter.store_dir().to_string_lossy(), ); - copy_dir(seed, starter.store_dir()) + copy_dir(seed_dir, starter.store_dir()) .expect("Cannot copy storage from seed directory"); }