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

Propagate install and uninstall hook exit codes #7782

Merged
merged 8 commits into from
Jul 9, 2020

Conversation

davidMcneil
Copy link
Contributor

Resolves #6964

This PR adds the logic to propagate the exit code of the install and uninstall hook to the hab command.

@@ -61,7 +61,7 @@ impl Default for ExitCode {
pub trait Hook: fmt::Debug + Sized + Send {
type ExitValue: fmt::Debug + Send;

fn file_name() -> &'static str;
const FILE_NAME: &'static str;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

@@ -315,6 +320,61 @@ pub trait Hook: fmt::Debug + Sized + Send {
fn stderr_log_path(&self) -> &Path;
}

#[async_trait::async_trait]
pub trait HookExt: Hook<ExitValue = ExitStatus> + Sync {
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming and typing of this trait doesn't clearly capture that it's for install and uninstall hooks only. It'd be nice to make that more obvious (though I admittedly am not sure what a better name for the trait and function would be).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I struggled around the naming of this. There is no reason this has to apply only to the install and uninstall hooks so I left the naming very general.

The method and frequency of when the install and uninstall hooks are run may provide an axis of differentiation. What if I called the trait one of the following: OneOffHookExt, AuxiliaryHookExt, PackageMaintenceHookExt...?

Ultimately, I think the Hook trait could use some cleanup. There is a lot of duplicated functionality when calling the hooks that should be moved into the trait itself and the handle_exit functionality seems unnecessarily general. There is really only a few different kinds of exit types and this would probably be better handled with different run functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the Hook trait needs a lot of love ☹️

The idea of using method/frequency of hook execution as an axis of differentiation is a great one. Of the suggestions given, I lean toward PackageMaintenanceHookExt as it's more descriptive and seems to capture something core to the whole idea of having install and uninstall hooks. Making that name change, along with a nice documentation comment, would be a nice addition 👍

Copy link
Contributor Author

@davidMcneil davidMcneil Jul 8, 2020

Choose a reason for hiding this comment

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

Thanks! Addressed in c02aca

@davidMcneil davidMcneil force-pushed the dmcneil/propogate-hook-exit-status branch 2 times, most recently from c02acae to 62adbd3 Compare July 8, 2020 18:03
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
@davidMcneil davidMcneil force-pushed the dmcneil/propogate-hook-exit-status branch from 62adbd3 to d661b9a Compare July 9, 2020 13:52
@davidMcneil davidMcneil merged commit 3d18988 into master Jul 9, 2020
@chef-expeditor chef-expeditor bot deleted the dmcneil/propogate-hook-exit-status branch July 9, 2020 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed install hook should bubble up exit code to hab pkg install
2 participants