-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add a feature to create automatically a random temporary directory for base path & remove Clone
#6221
Conversation
Forked at: 342caad Parent branch: origin/master
|
It looks like @cecton signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
Clone
client/cli/src/commands/run_cmd.rs
Outdated
| pub tmp: bool, | ||
|
|
||
| #[structopt(skip)] | ||
| temp_base_path: RefCell<Option<TempDir>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. This is a really bad hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What part you don't like exactly? (so I can find another way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not having the temp base path as parameter here.
We could create some custom type that we return in base_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok done! Now the TempDir is hold in the configuration object instead of the SubstrateCli object, then it's move to the service and dropped with it. Also the core of the feature itself has moved from sc-cli to sc-service.
client/cli/src/commands/run_cmd.rs
Outdated
|
|
||
| /// Run a temporary node. | ||
| /// | ||
| /// A random temporary directory will be created to store the configuration and will be deleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"random temporary" => "temporary"
Please also make the user aware that this is the "base-path" and what will be part of this path. Database, node key etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 55ed555
Parent branch: origin/master Forked at: 342caad
bkchr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already looks much better, the only problem is now that run_service_until_exit will drop the base path before everything has stopped. This could lead to errors on stopping the node.
client/cli/src/commands/mod.rs
Outdated
| } | ||
|
|
||
| fn base_path(&self) -> $crate::Result<::std::option::Option<::std::path::PathBuf>> { | ||
| fn base_path(&self) -> $crate::Result<::std::option::Option<::sc_service::config::BasePath>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| fn base_path(&self) -> $crate::Result<::std::option::Option<::sc_service::config::BasePath>> { | |
| fn base_path(&self) -> $crate::Result<::std::option::Option<sc_service::config::BasePath>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think these are all wrong. sc-cli should probably make a hidden re-export of sc_service and the macro should get it from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make another PR for that for the sake of having isolated commits per change
client/service/src/lib.rs
Outdated
| keystore: sc_keystore::KeyStorePtr, | ||
| marker: PhantomData<TBl>, | ||
| prometheus_registry: Option<prometheus_endpoint::Registry>, | ||
| _base_path: Option<BasePath>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why we need this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
client/service/src/config.rs
Outdated
| )) | ||
| } | ||
|
|
||
| /// Create a base path based on an existing path on disk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we create it if it does not exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not explicitly. We create only the network_config_dir which is a subdirectory. We could explicitly create the directories. Though this doc sentence actually meant "create a BasePath struct".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Than please write it. I did not understand it like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're totally right. Done in cb140b6
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Fair point! 😓
To be honest I kinda disagree. When I see that more things need to be handled in this I wonder if we should remove the |
|
Yeah, the situation with dropping the service is shit. That is right ;) |
Companion PR: paritytech/polkadot#1213
Following up of this idea:
Some people liked it
cc @JoshOrndorff @apopiak
Note: there were many Clone on the structopt. I think it was used in the original implementation before I refactored sc-cli but it is not needed anymore so I removed them.