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

[hab] Automatically installs hab-sup if missing when invoked. #348

Merged
merged 1 commit into from
Apr 6, 2016

Conversation

fnichol
Copy link
Collaborator

@fnichol fnichol commented Apr 5, 2016

This change lays the groundwork for some future subcommands that need
some simlar behavior. With this change, the hab binary performs the
following checks if hab sup or hab start is invoked:

  • If an environment variable HABITAT_SUP_BINARY is present, exec this
    value as the hap-sup program
  • Otherwise, see if a Supervisor package (currently chef/hap-sup) is
    locally installed. Use it if installed and if not download the latest
    version and use that.

Ignoring the particulars of the current UI output, here is a sample run
of hab start chef/redis without either chef/redis or chef/hap-sup
being locally installed:

> hab start chef/redis
Package for chef/hab-sup not found, installing from depot
Installing chef/hab-sup
Package chef/bzip2/1.0.6/20160310204954 already installed
Package chef/cacerts/2016.01.20/20160310211035 already installed
Package chef/gcc-libs/5.2.0/20160310204947 already installed
Package chef/glibc/2.22/20160310192356 already installed
Package chef/gpgme/1.6.0/20160310223048 already installed
Package chef/libarchive/3.1.2/20160310222903 already installed
Package chef/libassuan/2.4.2/20160310223025 already installed
Package chef/libgpg-error/1.20/20160310222812 already installed
Package chef/linux-headers/4.3/20160310192326 already installed
Package chef/openssl/1.0.2f/20160310211038 already installed
Package chef/rngd/5/20160310222754 already installed
Package chef/xz/5.2.2/20160310210257 already installed
Package chef/zlib/1.2.8/20160310193228 already installed
hab-sup 5358751/5358751
Installed chef/hab-sup/0.4.0/20160405170211
bldr(MN): Starting chef/redis
bldr(CS): chef/redis is not installed
bldr(CS): Searching for chef/redis in remote http://52.37.151.35:9632
Installing chef/redis
Package chef/glibc/2.22/20160310192356 already installed
Package chef/linux-headers/4.3/20160310192326 already installed
redis 927215/927215
Installed chef/redis/3.0.7/20160405144915
bldr(GS): Supervisor 172.17.0.2: 705a56b8-5f5f-4b93-b874-60d917e6bafb
bldr(GS): Census redis.default: c5bd9595-3f2d-4530-84ba-66712b147534
bldr(GS): Starting inbound gossip listener
bldr(GS): Starting outbound gossip distributor
bldr(GS): Starting gossip failure detector
bldr(CN): Starting census health adjuster
bldr(SC): Updated redis.config
redis(TS): Starting
redis(SO):                 _._
redis(O):            _.-``__ ''-._
redis(O):       _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
redis(O):   .-`` .-```.  ```\/    _.,_ ''-._
redis(O):  (    '      ,       .-`  | `,    )     Running in standalone mode
redis(O):  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
redis(O):  |    `-._   `._    /     _.-'    |     PID: 31704
redis(O):   `-._    `-._  `-./  _.-'    _.-'
redis(O):  |`-._`-._    `-.__.-'    _.-'_.-'|
redis(O):  |    `-._`-._        _.-'_.-'    |           http://redis.io
redis(O):   `-._    `-._`-.__.-'_.-'    _.-'
redis(O):  |`-._`-._    `-.__.-'    _.-'_.-'|
redis(O):  |    `-._`-._        _.-'_.-'    |
redis(O):   `-._    `-._`-.__.-'_.-'    _.-'
redis(O):       `-._    `-.__.-'    _.-'
redis(O):           `-._        _.-'
redis(O):               `-.__.-'
redis(O):
redis(O): 31704:M 05 Apr 22:22:50.253 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis(O): 31704:M 05 Apr 22:22:50.253 # Server started, Redis version 3.0.7
redis(O): 31704:M 05 Apr 22:22:50.253 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis(O): 31704:M 05 Apr 22:22:50.253 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis(O): 31704:M 05 Apr 22:22:50.253 * DB loaded from disk: 0.000 seconds
redis(O): 31704:M 05 Apr 22:22:50.253 * The server is now ready to accept connections on port 6379
^Credis(O): 31704:signal-handler (1459894970) Received SIGINT scheduling shutdown...
redis(O): 31704:signal-handler (1459894970) Received SIGTERM scheduling shutdown...
redis(O): 31704:M 05 Apr 22:22:50.859 # User requested shutdown...
redis(O): 31704:M 05 Apr 22:22:50.859 * Saving the final RDB snapshot before exiting.
redis(O): 31704:M 05 Apr 22:22:50.861 * DB saved on disk
redis(O): 31704:M 05 Apr 22:22:50.861 # Redis is now ready to exit, bye bye...
bldr(TP): Waiting for supervisor to finish
bldr(TP): Supervisor has finished
bldr(MN): Finished with chef/redis

@fnichol
Copy link
Collaborator Author

fnichol commented Apr 5, 2016

What new users may think of hab start chef/redis:

gif-keyboard-2067103448151153312

@chef-delivery
Copy link
Contributor

This PR has passed 'Verify' and is ready for review and approval!
Use: '@delivery approve' when code review is complete.

@@ -17,6 +17,7 @@ pub fn start(peers: &Vec<String>,
number: u64,
file_path: Option<&Path>)
-> Result<()> {
let sg1 = sg.clone();
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to clone here. You've passed ownership of sg to ConfigFile::from_file(..) which is assigned to file. On line 29 if you print &file.service_group you won't get complaints from the compiler about ownership and need to clone here

@reset
Copy link
Collaborator

reset commented Apr 6, 2016

@fnichol this is super clean and exactly what we need. Just a few comments inline which aren't super important. If you want to resolve those just feel free to merge for yourself

gif-keyboard-725198118049644513

This change lays the groundwork for some future subcommands that need
some simlar behavior. With this change, the `hab` binary performs the
following checks if `hab sup` or `hab start` is invoked:

* If an environment variable `HABITAT_SUP_BINARY` is present, exec this
  value as the `hap-sup` program
* Otherwise, see if a Supervisor package (currently `chef/hap-sup`) is
  locally installed. Use it if installed and if not download the latest
  version and use that.

Ignoring the particulars of the current UI output, here is a sample run
of `hab start chef/redis` without either `chef/redis` or `chef/hap-sup`
being locally installed:

```
> hab start chef/redis
Package for chef/hab-sup not found, installing from depot
Installing chef/hab-sup
Package chef/bzip2/1.0.6/20160310204954 already installed
Package chef/cacerts/2016.01.20/20160310211035 already installed
Package chef/gcc-libs/5.2.0/20160310204947 already installed
Package chef/glibc/2.22/20160310192356 already installed
Package chef/gpgme/1.6.0/20160310223048 already installed
Package chef/libarchive/3.1.2/20160310222903 already installed
Package chef/libassuan/2.4.2/20160310223025 already installed
Package chef/libgpg-error/1.20/20160310222812 already installed
Package chef/linux-headers/4.3/20160310192326 already installed
Package chef/openssl/1.0.2f/20160310211038 already installed
Package chef/rngd/5/20160310222754 already installed
Package chef/xz/5.2.2/20160310210257 already installed
Package chef/zlib/1.2.8/20160310193228 already installed
hab-sup 5358751/5358751
Installed chef/hab-sup/0.4.0/20160405170211
bldr(MN): Starting chef/redis
bldr(CS): chef/redis is not installed
bldr(CS): Searching for chef/redis in remote http://52.37.151.35:9632
Installing chef/redis
Package chef/glibc/2.22/20160310192356 already installed
Package chef/linux-headers/4.3/20160310192326 already installed
redis 927215/927215
Installed chef/redis/3.0.7/20160405144915
bldr(GS): Supervisor 172.17.0.2: 705a56b8-5f5f-4b93-b874-60d917e6bafb
bldr(GS): Census redis.default: c5bd9595-3f2d-4530-84ba-66712b147534
bldr(GS): Starting inbound gossip listener
bldr(GS): Starting outbound gossip distributor
bldr(GS): Starting gossip failure detector
bldr(CN): Starting census health adjuster
bldr(SC): Updated redis.config
redis(TS): Starting
redis(SO):                 _._
redis(O):            _.-``__ ''-._
redis(O):       _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
redis(O):   .-`` .-```.  ```\/    _.,_ ''-._
redis(O):  (    '      ,       .-`  | `,    )     Running in standalone mode
redis(O):  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
redis(O):  |    `-._   `._    /     _.-'    |     PID: 31704
redis(O):   `-._    `-._  `-./  _.-'    _.-'
redis(O):  |`-._`-._    `-.__.-'    _.-'_.-'|
redis(O):  |    `-._`-._        _.-'_.-'    |           http://redis.io
redis(O):   `-._    `-._`-.__.-'_.-'    _.-'
redis(O):  |`-._`-._    `-.__.-'    _.-'_.-'|
redis(O):  |    `-._`-._        _.-'_.-'    |
redis(O):   `-._    `-._`-.__.-'_.-'    _.-'
redis(O):       `-._    `-.__.-'    _.-'
redis(O):           `-._        _.-'
redis(O):               `-.__.-'
redis(O):
redis(O): 31704:M 05 Apr 22:22:50.253 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis(O): 31704:M 05 Apr 22:22:50.253 # Server started, Redis version 3.0.7
redis(O): 31704:M 05 Apr 22:22:50.253 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis(O): 31704:M 05 Apr 22:22:50.253 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis(O): 31704:M 05 Apr 22:22:50.253 * DB loaded from disk: 0.000 seconds
redis(O): 31704:M 05 Apr 22:22:50.253 * The server is now ready to accept connections on port 6379
^Credis(O): 31704:signal-handler (1459894970) Received SIGINT scheduling shutdown...
redis(O): 31704:signal-handler (1459894970) Received SIGTERM scheduling shutdown...
redis(O): 31704:M 05 Apr 22:22:50.859 # User requested shutdown...
redis(O): 31704:M 05 Apr 22:22:50.859 * Saving the final RDB snapshot before exiting.
redis(O): 31704:M 05 Apr 22:22:50.861 * DB saved on disk
redis(O): 31704:M 05 Apr 22:22:50.861 # Redis is now ready to exit, bye bye...
bldr(TP): Waiting for supervisor to finish
bldr(TP): Supervisor has finished
bldr(MN): Finished with chef/redis
```
@fnichol fnichol force-pushed the fnichol/hap-installs-supervisor branch from a076bbd to 8c2a916 Compare April 6, 2016 14:36
@chef-delivery
Copy link
Contributor

This PR has passed 'Verify' and is ready for review and approval!
Use: '@delivery approve' when code review is complete.

@fnichol
Copy link
Collaborator Author

fnichol commented Apr 6, 2016

gif-keyboard-815654043718215782

@fnichol
Copy link
Collaborator Author

fnichol commented Apr 6, 2016

@delivery approve

@chef-delivery chef-delivery merged commit 90ca045 into master Apr 6, 2016
@chef-delivery chef-delivery deleted the fnichol/hap-installs-supervisor branch April 6, 2016 14:52
@chef-delivery
Copy link
Contributor

Change: 827f7509-f2a6-4c4e-b660-7daf415edb97 approved by: @fnichol

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.

3 participants