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

Make sure Cargo features work #76

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

hug-dev
Copy link
Member

@hug-dev hug-dev commented Dec 6, 2019

Makes sure that Parsec builds with commands like:

cargo build --no-default-features --features "mbed-crypto-provider"
cargo build --no-default-features --features "tpm-provider"

Also renames the "mbed" features to "mbed-crypto-provider" for
consistency.

Exit the service with an error code if no provider could be instanciated.

@hug-dev hug-dev added the bug Something isn't working label Dec 6, 2019
@hug-dev hug-dev self-assigned this Dec 6, 2019
@hug-dev hug-dev mentioned this pull request Dec 6, 2019
@hug-dev hug-dev force-pushed the features-fix branch 2 times, most recently from 77ac1d0 to c44a13d Compare December 6, 2019 15:38
src/bin/main.rs Outdated
@@ -71,7 +78,13 @@ fn main() -> Result<(), Error> {
config_file = ::std::fs::read_to_string(CONFIG_FILE_PATH)
.expect("Failed to read configuration file");
config = toml::from_str(&config_file).expect("Failed to parse service configuration");
front_end_handler = Arc::from(ServiceBuilder::build_service(&config));
front_end_handler = Arc::from(match ServiceBuilder::build_service(&config) {
Copy link
Member

Choose a reason for hiding this comment

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

...build_service(&config).ok_or_else(|| Err(Error::new... )?...

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice one! Will change.

}
#[cfg(not(all(feature = "mbed-crypto-provider", feature = "pkcs11-provider")))]
_ => {
warn!(
Copy link
Member

Choose a reason for hiding this comment

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

I know we're not ready for a release yet, but this sounds like a case where we should panic instead of just printing a warning - if the config file defines a provider but that provider isn't enabled, the admin might be expecting some functionality to be available which will not be there

Copy link
Member Author

Choose a reason for hiding this comment

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

we should panic instead of just printing a warning

That is what I did first but having it return an Option allows us to do the following things:

  • even if one of the providers could not be instantiated, Parsec can still run with the other ones
  • an admin might reload the configuration with a bad one, adding a provider that is not in the binary: in that case, it will print a warning without the whole service shutting down
  • I added a feature in this commit that checks if no providers could be instantiated in which case the Parsec binary will exit with an error code: I think that is still a better way to exit than panicking which can be confusing.

IMO returning always seems cleaner than panicking when it is possible.

the admin might be expecting some functionality to be available which will not be there

You have a point there: I think it is better to solve this with the admin reading the logs and executing tests after Parsec has been installed than just panicking. I guess both options are possible and we will have to make a decision about this.

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with this going in like this, we'll have to see if we get any feedback about it

Makes sure that Parsec builds with commands like:
cargo build --no-default-features --features "mbed-crypto-provider"
cargo build --no-default-features --features "tpm-provider"

Also renames the "mbed" features to "mbed-crypto-provider" for
consistency.

Signed-off-by: Hugues de Valon <[email protected]>
@hug-dev hug-dev merged commit b7312dc into parallaxsecond:master Dec 9, 2019
@hug-dev hug-dev deleted the features-fix branch December 9, 2019 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants