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

Allow packages to expose a runnable hook #5161

Closed
mwrock opened this issue Jun 5, 2018 · 9 comments
Closed

Allow packages to expose a runnable hook #5161

mwrock opened this issue Jun 5, 2018 · 9 comments
Assignees
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Type:Feature PRs that add a new feature Type: Feature Issues that describe a new desired feature

Comments

@mwrock
Copy link
Contributor

mwrock commented Jun 5, 2018

On Windows (and maybe Linux too?) there are some legacy scenarios where a dependency package may need to apply some setup script on the supervisor node before it can be used. Examples are:

  • COM/COM+ registration where a library DLL has to be registered via a command line utility before calling code can reference it.
  • Installing a specific version of the .Net Framework (or possibly some other framework) that needs a bunch of Windows Registry entries and where we would want to just run its installer in the hook
  • Wrapping windows features as packages where we need to run OS APIs to install and configure them
  • Wrapping Powershell modules or DSC resources which is similar in "flow" to the above.

The idea here is that a "service" package could declare a dependency on such a package as listed above and the supervisor would call its hook during (or before) the init phase.

We currently handle this scenario by performing all the setup of the deps in the service's init hook but that makes the dep very much coupled to the service.

@wduncanfraser
Copy link
Member

This would be an excellent addition. Currently, in our windows packages we are able to handle installs of .net framework, legacy IBM drivers, windows services, etc via DSC. We are able to wrap the installers in hab packages to guarantee they are there at runtime, however the DSC has to be reproduced and maintained in each and every package/service that depends on the above items.

It would be much nicer if the packages containing the installers had a hook like described above so they could be used in a modular fashion.

@mwrock
Copy link
Contributor Author

mwrock commented Jun 25, 2018

Its worth referencing the discussion in https://forums.habitat.sh/t/service-paths-config-without-service/643 here as well. @themightychris brings up a scenario of library packages that will never be run as a service. They are command wrappers but still need some configuration performed around templates to reference service paths. One thought there is that we might consider introducing a hab pkg configure command that could run that hook for library packages outside of the context of the supervisors. In such a case hab pkg exec would ensure that hook is called if it exists.

@mwrock
Copy link
Contributor Author

mwrock commented Nov 26, 2018

This is in progress in the following PRs:
habitat-sh/core#90
#5866

Adds behavior to execute a new install hook upon loading a package and also adding a InstallHookMode argument to hab pkg install that takes one of 3 values: default, ignore, and force.

The InstallHookMode values have the following corresponding behavior:
default: Runs the install hook when initially loading/installing a package
ignore: Ignores any install hooks when loading a package (this will be key for exporter scenarios and debugging)
force: will execute the install hook of package and any deps regardless of whether they have been previously installed (also key for exporters and debugging)

@mwrock mwrock self-assigned this Nov 26, 2018
@mwrock mwrock changed the title Allow "Library" packages to expose a runnable hook Allow packages to expose a runnable hook Nov 26, 2018
@themightychris
Copy link
Contributor

@mwrock this is awesome work, I love the approach so far!

How are you envisioning config being input for templating in lieu of being able to target a supervisor with hab config apply? Would hab pkg exec and hab pkg compile support pulling package config from the environment and or CLI args? Or are you picturing non-service config templates being limited to whatever is in default.toml and the built-in pkg.* values?

@mwrock
Copy link
Contributor Author

mwrock commented Nov 27, 2018

@themightychris it will honor a user.toml as well as HAB_ prefixed env vars. Because the install hook will not interact with census data of running services, hab config apply will not have any effect.

@themightychris
Copy link
Contributor

themightychris commented Nov 27, 2018

@mwrock excellent!

It would be a cool bonus if there were a --config-file=./path/to/config.{json,toml} option to hab pkg exec and hab pkg compile that could work too. That would provide a bit more of a natural workflow for shell-scripted uses of habitat-packaged commands.

@mwrock
Copy link
Contributor Author

mwrock commented Nov 27, 2018

yeah that would be a nice addition but perhaps left to a separate PR.

One thing to be clear about is that the install hook is invoked at hab pkg install (or when a supervisor initially loads a package for the first time that has not been installed) time and not hab pkg exec time. Does that continue to work for your scenarios @themightychris ?

@themightychris
Copy link
Contributor

@mwrock it does!

@mwrock
Copy link
Contributor Author

mwrock commented Jan 18, 2019

closed by #5866

@mwrock mwrock closed this as completed Jan 18, 2019
@christophermaier christophermaier added Type:Feature PRs that add a new feature Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Type: Feature Issues that describe a new desired feature and removed X-feature labels Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Type:Feature PRs that add a new feature Type: Feature Issues that describe a new desired feature
Projects
None yet
Development

No branches or pull requests

4 participants