Allow a solana-validator
to join a cluster established by solana-test-validator
(backport #18394) (#18399)
* Report 404 instead of 502 when a snapshot file is not found This provides the client with more useful information about why their request failed (cherry picked from commit40d696fcbc
) * As a last resort try to download an uncompressed snapshot `solana-test-validator` creates uncompressed snapshots and it can be useful to attach another validator to a `solana-test-validator` cluster from time to time (cherry picked from commite36247d187
) Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -258,6 +258,7 @@ pub fn download_snapshot<'a, 'b>(
|
|||||||
ArchiveFormat::TarZstd,
|
ArchiveFormat::TarZstd,
|
||||||
ArchiveFormat::TarGzip,
|
ArchiveFormat::TarGzip,
|
||||||
ArchiveFormat::TarBzip2,
|
ArchiveFormat::TarBzip2,
|
||||||
|
ArchiveFormat::Tar, // `solana-test-validator` creates uncompressed snapshots
|
||||||
] {
|
] {
|
||||||
let desired_snapshot_package = snapshot_utils::get_snapshot_archive_path(
|
let desired_snapshot_package = snapshot_utils::get_snapshot_archive_path(
|
||||||
snapshot_output_dir.to_path_buf(),
|
snapshot_output_dir.to_path_buf(),
|
||||||
@ -269,7 +270,7 @@ pub fn download_snapshot<'a, 'b>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if download_file(
|
match download_file(
|
||||||
&format!(
|
&format!(
|
||||||
"http://{}/{}",
|
"http://{}/{}",
|
||||||
rpc_addr,
|
rpc_addr,
|
||||||
@ -282,11 +283,13 @@ pub fn download_snapshot<'a, 'b>(
|
|||||||
&desired_snapshot_package,
|
&desired_snapshot_package,
|
||||||
use_progress_bar,
|
use_progress_bar,
|
||||||
progress_notify_callback,
|
progress_notify_callback,
|
||||||
)
|
) {
|
||||||
.is_ok()
|
Ok(()) => return Ok(()),
|
||||||
{
|
Err(err) => info!("{}", err),
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err("Snapshot couldn't be downloaded".to_string())
|
Err(format!(
|
||||||
|
"Failed to download a snapshot for slot {} from {}",
|
||||||
|
desired_snapshot_hash.0, rpc_addr
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,11 @@ impl RpcRequestMiddleware {
|
|||||||
should_validate_hosts: true,
|
should_validate_hosts: true,
|
||||||
response: Box::pin(async {
|
response: Box::pin(async {
|
||||||
match Self::open_no_follow(filename).await {
|
match Self::open_no_follow(filename).await {
|
||||||
Err(_) => Ok(Self::internal_server_error()),
|
Err(err) => Ok(if err.kind() == std::io::ErrorKind::NotFound {
|
||||||
|
Self::not_found()
|
||||||
|
} else {
|
||||||
|
Self::internal_server_error()
|
||||||
|
}),
|
||||||
Ok(file) => {
|
Ok(file) => {
|
||||||
let stream =
|
let stream =
|
||||||
FramedRead::new(file, BytesCodec::new()).map_ok(|b| b.freeze());
|
FramedRead::new(file, BytesCodec::new()).map_ok(|b| b.freeze());
|
||||||
|
Reference in New Issue
Block a user