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

use create_and_canonicalize_directory for snapshots dir #3923

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

yihau
Copy link
Member

@yihau yihau commented Dec 4, 2024

Problem

we don't create "snapshots" dir for users before we canonicalize.

Summary of Changes

do something similar with ledger path:

agave/validator/src/main.rs

Lines 997 to 1004 in df27fb3

let ledger_path = create_and_canonicalize_directories([&ledger_path])
.unwrap_or_else(|err| {
eprintln!(
"Unable to access ledger path '{}': {err}",
ledger_path.display(),
);
exit(1);
})

@yihau yihau added the v2.1 Backport to v2.1 branch label Dec 5, 2024
@yihau yihau marked this pull request as ready for review December 5, 2024 04:00
@yihau yihau requested review from brooksprumo and steviez December 5, 2024 04:00
Copy link

mergify bot commented Dec 5, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

validator/src/main.rs Outdated Show resolved Hide resolved
Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Funny enough, I remember reporting this on Discord and doing nothing about it so kudos for making the change.

The change seems fine to me, but Brooks is in the know about all of the snapshot / accountsdb paths so I think we need his ship-it

Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Here's what I'm thinking as the fix:

diff --git a/validator/src/main.rs b/validator/src/main.rs
index bee65e487b..0ae88b94f9 100644
--- a/validator/src/main.rs
+++ b/validator/src/main.rs
@@ -24,7 +24,10 @@ use {
             AccountsIndexConfig, IndexLimitMb, ScanFilter,
         },
         partitioned_rewards::TestPartitionedEpochRewards,
-        utils::{create_all_accounts_run_and_snapshot_dirs, create_and_canonicalize_directories},
+        utils::{
+            create_all_accounts_run_and_snapshot_dirs, create_and_canonicalize_directories,
+            create_and_canonicalize_directory,
+        },
     },
     solana_clap_utils::input_parsers::{keypair_of, keypairs_of, pubkey_of, value_of, values_of},
     solana_core::{
@@ -1671,9 +1674,9 @@ pub fn main() {
     } else {
         &ledger_path
     };
-    let snapshots_dir = fs::canonicalize(snapshots_dir).unwrap_or_else(|err| {
+    let snapshots_dir = create_and_canonicalize_directory(snapshots_dir).unwrap_or_else(|err| {
         eprintln!(
-            "Failed to canonicalize snapshots path '{}': {err}",
+            "Failed to create snapshots directory '{}': {err}",
             snapshots_dir.display(),
         );
         exit(1);

So we only need to change the one fs::create_dir_all() and update the error text.

Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

:shipit:

(Assuming the change still fixes the problem 😸)

@brooksprumo brooksprumo added the v2.0 Backport to v2.0 branch label Dec 5, 2024
Copy link

mergify bot commented Dec 5, 2024

Backports to the stable branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule.

Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Just tried it out and can confirm that passing a directory that did not exist resulted in the directory getting created.

So, with our validator script, this means you can just do rm -rf ledger-snapshots again and let the script figure out to remove --no-snapshot-fetch if you want to force snapshot download.

LGTM

@yihau
Copy link
Member Author

yihau commented Dec 5, 2024

thank you @steviez for checking. yeah, I checked before I pushed but it’s great to see your double confirmation!

@yihau
Copy link
Member Author

yihau commented Dec 5, 2024

@brooksprumo if I don't miss anything, v2.0 doesn't affect by this. maybe we can bp to 2.1 first 🤔

@steviez
Copy link

steviez commented Dec 5, 2024

@brooksprumo if I don't miss anything, v2.0 doesn't affect by this. maybe we can bp to 2.1 first 🤔

In genereal, yes, we should BP to v2.1 first and test it out before considering a v2.0 BP. Given that we used to create this directory (not sure when it changed), I'd be in the favor of the BP. Technically, we are re-establishing pre-existing behavior

@brooksprumo brooksprumo removed the v2.0 Backport to v2.0 branch label Dec 5, 2024
@brooksprumo
Copy link

v2.0 doesn't affect by this

Got it. I looked at the v2.0 code, but I must've done it too quickly and I read it wrong. I see now that v2.0 doesn't canonicalize the snapshots dir, so that's why v2.0 doesn't have this issue.

@yihau yihau merged commit 31606f5 into anza-xyz:master Dec 6, 2024
42 checks passed
@yihau yihau deleted the fix-snapshot-path branch December 6, 2024 03:54
mergify bot pushed a commit that referenced this pull request Dec 6, 2024
* fix snapshot path

* feedback

(cherry picked from commit 31606f5)
yihau added a commit that referenced this pull request Dec 6, 2024
…rt of #3923) (#3969)

use create_and_canonicalize_directory for snapshots dir (#3923)

* fix snapshot path

* feedback

(cherry picked from commit 31606f5)

Co-authored-by: Yihau Chen <yihau.chen@icloud.com>
KirillLykov pushed a commit that referenced this pull request Dec 9, 2024
…rt of #3923) (#3969)

use create_and_canonicalize_directory for snapshots dir (#3923)

* fix snapshot path

* feedback

(cherry picked from commit 31606f5)

Co-authored-by: Yihau Chen <yihau.chen@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.1 Backport to v2.1 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants