Blow away snapshots directory on start (#5446)
This commit is contained in:
@ -357,7 +357,6 @@ impl BankForks {
|
||||
snapshot_config: &SnapshotConfig,
|
||||
snapshot_tar: P,
|
||||
) -> Result<Self> {
|
||||
fs::create_dir_all(&snapshot_config.snapshot_path)?;
|
||||
// Untar the snapshot into a temp directory under `snapshot_config.snapshot_path()`
|
||||
let unpack_dir = tempfile::tempdir_in(snapshot_config.snapshot_path())?;
|
||||
untar_snapshot_in(&snapshot_tar, &unpack_dir)?;
|
||||
|
@ -26,6 +26,7 @@ use solana_sdk::poh_config::PohConfig;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::timing::{timestamp, DEFAULT_SLOTS_PER_TURN};
|
||||
use std::fs;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
@ -317,6 +318,11 @@ fn get_bank_forks(
|
||||
if snapshot_config.is_some() {
|
||||
let snapshot_config = snapshot_config.as_ref().unwrap();
|
||||
|
||||
// Blow away any remnants in the snapshots directory
|
||||
let _ = fs::remove_dir_all(snapshot_config.snapshot_path());
|
||||
fs::create_dir_all(&snapshot_config.snapshot_path())
|
||||
.expect("Couldn't create snapshot directory");
|
||||
|
||||
// Get the path to the tar
|
||||
let tar = snapshot_utils::get_snapshot_tar_path(
|
||||
&snapshot_config.snapshot_package_output_path(),
|
||||
|
@ -64,7 +64,6 @@ args+=(
|
||||
--identity "$identity_keypair"
|
||||
--ledger "$ledger_dir"
|
||||
--rpc-port 8899
|
||||
--snapshot-path "$SOLANA_CONFIG_DIR"/bootstrap-leader/snapshots
|
||||
--snapshot-interval-slots 100
|
||||
--storage-keypair "$storage_keypair"
|
||||
--voting-keypair "$vote_keypair"
|
||||
|
@ -195,7 +195,6 @@ default_arg --voting-keypair "$voting_keypair_path"
|
||||
default_arg --storage-keypair "$storage_keypair_path"
|
||||
default_arg --ledger "$ledger_dir"
|
||||
default_arg --accounts "$accounts_dir"
|
||||
#default_arg --snapshot-path "$snapshot_dir"
|
||||
#default_arg --snapshot-interval-slots 100
|
||||
|
||||
if [[ -n $SOLANA_CUDA ]]; then
|
||||
|
@ -10,6 +10,7 @@ use solana::socketaddr;
|
||||
use solana::validator::{Validator, ValidatorConfig};
|
||||
use solana_netutil::parse_port_range;
|
||||
use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::net::SocketAddr;
|
||||
use std::path::PathBuf;
|
||||
@ -156,20 +157,11 @@ fn main() {
|
||||
.validator(port_range_validator)
|
||||
.help("Range to use for dynamically assigned ports"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::with_name("snapshot_path")
|
||||
.long("snapshot-path")
|
||||
.value_name("SNAPSHOT_PATHS")
|
||||
.takes_value(true)
|
||||
.requires("snapshot_interval_slots")
|
||||
.help("Snapshot path"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::with_name("snapshot_interval_slots")
|
||||
.long("snapshot-interval-slots")
|
||||
.value_name("SNAPSHOT_INTERVAL_SLOTS")
|
||||
.takes_value(true)
|
||||
.requires("snapshot_path")
|
||||
.help("Number of slots between generating snapshots"),
|
||||
)
|
||||
.arg(
|
||||
@ -246,16 +238,22 @@ fn main() {
|
||||
if let Some(paths) = matches.value_of("accounts") {
|
||||
validator_config.account_paths = Some(paths.to_string());
|
||||
}
|
||||
if let Some(snapshot_path) = matches.value_of("snapshot_path").map(PathBuf::from) {
|
||||
let snapshot_interval = matches.value_of("snapshot_interval_slots").unwrap();
|
||||
validator_config.snapshot_config = Some(SnapshotConfig::new(
|
||||
snapshot_path,
|
||||
ledger_path.clone(),
|
||||
snapshot_interval.parse::<usize>().unwrap(),
|
||||
));
|
||||
} else {
|
||||
validator_config.snapshot_config = None;
|
||||
}
|
||||
|
||||
validator_config.snapshot_config = matches.value_of("snapshot_interval_slots").map(|s| {
|
||||
let snapshots_dir = ledger_path.clone().join("snapshot");
|
||||
let snapshots_bank_state_dir = snapshots_dir.join("bank_states");
|
||||
let snapshots_tar_dir = snapshots_dir.join("tar");
|
||||
fs::create_dir_all(&snapshots_dir).expect("Failed to create snapshots directory");
|
||||
fs::create_dir_all(&snapshots_bank_state_dir)
|
||||
.expect("Failed to create snapshots bank state directory");
|
||||
fs::create_dir_all(&snapshots_tar_dir).expect("Failed to create snapshots tar directory");
|
||||
SnapshotConfig::new(
|
||||
snapshots_bank_state_dir,
|
||||
snapshots_tar_dir,
|
||||
s.parse::<usize>().unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
if matches.is_present("limit_ledger_size") {
|
||||
validator_config.max_ledger_slots = Some(DEFAULT_MAX_LEDGER_SLOTS);
|
||||
}
|
||||
|
Reference in New Issue
Block a user