habitat-sh / habitat

Modern applications with built-in automation
https://www.habitat.sh
Apache License 2.0
2.61k stars 315 forks source link

Lifecycle hooks removed from a package are not removed from service directory #4925

Open gfodor opened 6 years ago

gfodor commented 6 years ago

If a package is updated and one of its lifecycle hooks are removed as part of the change, the supervisor does not remove the hook from the service directory.

baumanj commented 6 years ago

Valid on v0.57:

[5][default:/src:0]# hab svc load jbauman/minimial-habitat-app
The jbauman/minimial-habitat-app service was successfully loaded
[6][default:/src:0]# hab sup status
package                                            type        state  elapsed (s)  pid  group
jbauman/minimial-habitat-app/0.1.0/20180702210015  standalone  down   2            0    minimial-habitat-app.default
[7][default:/src:0]# ls
habitat  results
[8][default:/src:0]# ls habitat/
plan.sh
[9][default:/src:0]# ls habitat/hooks
ls: cannot access 'habitat/hooks': No such file or directory
[10][default:/src:2]# mkdir habitat/hooks
[11][default:/src:0]# cat > habitat/hooks/run
#!/bin/bash

echo "I am the run hook" 
[12][default:/src:0]# chmod +x habitat/hooks/run 
[13][default:/src:0]# build
   : Loading /src/habitat/plan.sh
   minimial-habitat-app: Plan loaded
   minimial-habitat-app: Validating plan metadata
   minimial-habitat-app: Using HAB_BIN=/hab/pkgs/core/hab/0.58.0/20180629144346/bin/hab for installs, signing, and hashing
   minimial-habitat-app: hab-plan-build setup
   minimial-habitat-app: Writing pre_build file
   minimial-habitat-app: Resolving build dependencies
   minimial-habitat-app: Resolving run dependencies
   minimial-habitat-app: Setting up environment
   minimial-habitat-app: Populating runtime environment from dependencies
   minimial-habitat-app: Populating buildtime environment from dependencies
   minimial-habitat-app: Layering runtime environment on top of system environment
   minimial-habitat-app: Layering buildtime environment on top of system environment
   minimial-habitat-app: Setting PATH=/hab/pkgs/core/hab-plan-build/0.58.0/20180629150501/bin:/hab/pkgs/core/bash/4.3.42/20170513213519/bin:/hab/pkgs/core/binutils/2.25.1/20170513201927/bin:/hab/pkgs/core/bzip2/1.0.6/20170513212938/bin:/hab/pkgs/core/coreutils/8.25/20170513213226/bin:/hab/pkgs/core/file/5.24/20170513201915/bin:/hab/pkgs/core/findutils/4.4.2/20170513214305/bin:/hab/pkgs/core/gawk/4.1.3/20170513213646/bin:/hab/pkgs/core/grep/2.22/20170513213444/bin:/hab/pkgs/core/gzip/1.6/20170513214605/bin:/hab/pkgs/core/hab/0.58.0/20180629144346/bin:/hab/pkgs/core/rq/0.9.2/20170612005822/bin:/hab/pkgs/core/sed/4.2.2/20170513213123/bin:/hab/pkgs/core/tar/1.29/20170513213607/bin:/hab/pkgs/core/unzip/6.0/20180310001951/bin:/hab/pkgs/core/wget/1.19.1/20171024102323/bin:/hab/pkgs/core/xz/5.2.2/20170513214327/bin:/hab/pkgs/core/glibc/2.22/20170513201042/bin:/hab/pkgs/core/ncurses/6.0/20170513213009/bin:/hab/pkgs/core/acl/2.2.52/20170513213108/bin:/hab/pkgs/core/attr/2.4.47/20170513213059/bin:/hab/pkgs/core/libcap/2.24/20170513213120/bin:/hab/pkgs/core/pcre/8.38/20170513213423/bin:/hab/pkgs/core/less/481/20170513213936/bin:/hab/pkgs/core/libidn/1.32/20170513215043/bin:/hab/pkgs/core/openssl/1.0.2l/20171014213633/bin
   minimial-habitat-app: Clean the cache
   minimial-habitat-app: Setting build environment
mkdir: created directory '/hab/cache/src/minimial-habitat-app-0.1.0'
   minimial-habitat-app: Setting PREFIX=/hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452
   minimial-habitat-app: Setting LD_RUN_PATH=
   minimial-habitat-app: Setting CFLAGS=
   minimial-habitat-app: Setting CXXFLAGS=
   minimial-habitat-app: Setting CPPFLAGS=
   minimial-habitat-app: Setting LDFLAGS=
   minimial-habitat-app: Setting PKG_CONFIG_PATH=
   minimial-habitat-app: Preparing to build
   minimial-habitat-app: Building
   minimial-habitat-app: Installing
mkdir: created directory '/hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452'
   minimial-habitat-app: Writing configuration
   minimial-habitat-app: Writing service management scripts
   minimial-habitat-app: Using run hook /src/habitat/hooks/run
   minimial-habitat-app: Stripping unneeded symbols from binaries and libraries
   minimial-habitat-app: Building package metadata
   minimial-habitat-app: Generating blake2b hashes of all files in the package
   minimial-habitat-app: Generating signed metadata FILES
» Signing minimial-habitat-app_blake2bsums
☛ Signing minimial-habitat-app_blake2bsums with jbauman-20180125163633 to create /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452/FILES
★ Signed artifact /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452/FILES.
   minimial-habitat-app: Creating manifest
   minimial-habitat-app: Generating package artifact
/hab/pkgs/core/tar/1.29/20170513213607/bin/tar: Removing leading `/' from member names
/hab/cache/artifacts/.jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.tar (1/1)
  100 %           1348 B / 20.0 KiB = 0.066                                    
» Signing /hab/cache/artifacts/.jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.tar.xz
☛ Signing /hab/cache/artifacts/.jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.tar.xz with jbauman-20180125163633 to create /hab/cache/artifacts/jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.hart
★ Signed artifact /hab/cache/artifacts/jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.hart.
'/hab/cache/artifacts/jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.hart' -> '/src/results/jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.hart'
   minimial-habitat-app: hab-plan-build cleanup
   minimial-habitat-app: 
   minimial-habitat-app: Source Path: /hab/cache/src/minimial-habitat-app-0.1.0
   minimial-habitat-app: Installed Path: /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452
   minimial-habitat-app: Artifact: /src/results/jbauman-minimial-habitat-app-0.1.0-20180702210452-x86_64-linux.hart
   minimial-habitat-app: Build Report: /src/results/last_build.env
   minimial-habitat-app: SHA256 Checksum: 53de592bfa7ab207c0cdff63ea63410850f560d6e3c87e2a5cff9be7c968ef29
   minimial-habitat-app: Blake2b Checksum: a4400c56657ad6075e83d66bae38637a8441f6aeb6a8c2cf8c401b78839727d3
   minimial-habitat-app: 
   minimial-habitat-app: I love it when a plan.sh comes together.
   minimial-habitat-app: 
   minimial-habitat-app: Build time: 0m1s
[14][default:/src:0]# ls /hab/pkgs/
core/    jbauman/ 
[14][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210
20180702210015/ 20180702210452/ 
[14][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210
20180702210015/ 20180702210452/ 
[14][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452/
FILES      IDENT      MANIFEST   SVC_GROUP  SVC_USER   TARGET     TYPE       hooks/     
[14][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452/hooks/
run
[15][default:/src:0]# cat /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210452/hooks/run 
#!/bin/bash

echo "I am the run hook"
[16][default:/src:0]# ls /hab/svc/minimial-habitat-app/
config/ data/   files/  hooks/  logs/   static/ var/    
[16][default:/src:0]# ls /hab/svc/minimial-habitat-app/hooks/
[17][default:/src:0]# hab sup status
package                                            type        state  elapsed (s)  pid  group
jbauman/minimial-habitat-app/0.1.0/20180702210015  standalone  down   213          0    minimial-habitat-app.default
[18][default:/src:0]# hab pkg install jbauman/minimial-habitat-app
» Installing jbauman/minimial-habitat-app
☁ Determining latest version of jbauman/minimial-habitat-app in the 'stable' channel
∵ Missing remote version of 'jbauman/minimial-habitat-app' in the 'stable' channel, but an installed version was found locally (jbauman/minimial-habitat-app/0.1.0/20180702210452)
→ Using jbauman/minimial-habitat-app/0.1.0/20180702210452
★ Install of jbauman/minimial-habitat-app/0.1.0/20180702210452 complete with 0 new packages installed.
[19][default:/src:0]# hab sup status
package                                            type        state  elapsed (s)  pid  group
jbauman/minimial-habitat-app/0.1.0/20180702210015  standalone  down   249          0    minimial-habitat-app.default
[20][default:/src:0]# hab svc load jbauman/minimial-habitat-app
✗✗✗
✗✗✗ [Err: 3] Service already loaded, unload 'jbauman/minimial-habitat-app' and try again
✗✗✗
[21][default:/src:1]# hab svc unload jbauman/minimial-habitat-app
Unloading jbauman/minimial-habitat-app
[22][default:/src:0]# hab svc load jbauman/minimial-habitat-app
The jbauman/minimial-habitat-app service was successfully loaded
[23][default:/src:0]# ls /hab/svc/minimial-habitat-app/hooks/
run
[24][default:/src:0]# cat /hab/svc/minimial-habitat-app/hooks/run 
#!/bin/bash

echo "I am the run hook"
[25][default:/src:0]# rm habitat/hooks/run 
[26][default:/src:0]# build
   : Loading /src/habitat/plan.sh
   minimial-habitat-app: Plan loaded
   minimial-habitat-app: Validating plan metadata
   minimial-habitat-app: Using HAB_BIN=/hab/pkgs/core/hab/0.58.0/20180629144346/bin/hab for installs, signing, and hashing
   minimial-habitat-app: hab-plan-build setup
   minimial-habitat-app: Writing pre_build file
   minimial-habitat-app: Resolving build dependencies
   minimial-habitat-app: Resolving run dependencies
   minimial-habitat-app: Setting up environment
   minimial-habitat-app: Populating runtime environment from dependencies
   minimial-habitat-app: Populating buildtime environment from dependencies
   minimial-habitat-app: Layering runtime environment on top of system environment
   minimial-habitat-app: Layering buildtime environment on top of system environment
   minimial-habitat-app: Setting PATH=/hab/pkgs/core/hab-plan-build/0.58.0/20180629150501/bin:/hab/pkgs/core/bash/4.3.42/20170513213519/bin:/hab/pkgs/core/binutils/2.25.1/20170513201927/bin:/hab/pkgs/core/bzip2/1.0.6/20170513212938/bin:/hab/pkgs/core/coreutils/8.25/20170513213226/bin:/hab/pkgs/core/file/5.24/20170513201915/bin:/hab/pkgs/core/findutils/4.4.2/20170513214305/bin:/hab/pkgs/core/gawk/4.1.3/20170513213646/bin:/hab/pkgs/core/grep/2.22/20170513213444/bin:/hab/pkgs/core/gzip/1.6/20170513214605/bin:/hab/pkgs/core/hab/0.58.0/20180629144346/bin:/hab/pkgs/core/rq/0.9.2/20170612005822/bin:/hab/pkgs/core/sed/4.2.2/20170513213123/bin:/hab/pkgs/core/tar/1.29/20170513213607/bin:/hab/pkgs/core/unzip/6.0/20180310001951/bin:/hab/pkgs/core/wget/1.19.1/20171024102323/bin:/hab/pkgs/core/xz/5.2.2/20170513214327/bin:/hab/pkgs/core/glibc/2.22/20170513201042/bin:/hab/pkgs/core/ncurses/6.0/20170513213009/bin:/hab/pkgs/core/acl/2.2.52/20170513213108/bin:/hab/pkgs/core/attr/2.4.47/20170513213059/bin:/hab/pkgs/core/libcap/2.24/20170513213120/bin:/hab/pkgs/core/pcre/8.38/20170513213423/bin:/hab/pkgs/core/less/481/20170513213936/bin:/hab/pkgs/core/libidn/1.32/20170513215043/bin:/hab/pkgs/core/openssl/1.0.2l/20171014213633/bin
   minimial-habitat-app: Clean the cache
   minimial-habitat-app: Setting build environment
mkdir: created directory '/hab/cache/src/minimial-habitat-app-0.1.0'
   minimial-habitat-app: Setting PREFIX=/hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834
   minimial-habitat-app: Setting LD_RUN_PATH=
   minimial-habitat-app: Setting CFLAGS=
   minimial-habitat-app: Setting CXXFLAGS=
   minimial-habitat-app: Setting CPPFLAGS=
   minimial-habitat-app: Setting LDFLAGS=
   minimial-habitat-app: Setting PKG_CONFIG_PATH=
   minimial-habitat-app: Preparing to build
   minimial-habitat-app: Building
   minimial-habitat-app: Installing
mkdir: created directory '/hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834'
   minimial-habitat-app: Writing configuration
   minimial-habitat-app: Writing service management scripts
   minimial-habitat-app: Stripping unneeded symbols from binaries and libraries
   minimial-habitat-app: Building package metadata
   minimial-habitat-app: Generating blake2b hashes of all files in the package
   minimial-habitat-app: Generating signed metadata FILES
» Signing minimial-habitat-app_blake2bsums
☛ Signing minimial-habitat-app_blake2bsums with jbauman-20180125163633 to create /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834/FILES
★ Signed artifact /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834/FILES.
   minimial-habitat-app: Creating manifest
   minimial-habitat-app: Generating package artifact
/hab/pkgs/core/tar/1.29/20170513213607/bin/tar: Removing leading `/' from member names
/hab/cache/artifacts/.jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.tar (1/1)
  100 %           1132 B / 10.0 KiB = 0.111                                    
» Signing /hab/cache/artifacts/.jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.tar.xz
☛ Signing /hab/cache/artifacts/.jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.tar.xz with jbauman-20180125163633 to create /hab/cache/artifacts/jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.hart
★ Signed artifact /hab/cache/artifacts/jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.hart.
'/hab/cache/artifacts/jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.hart' -> '/src/results/jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.hart'
   minimial-habitat-app: hab-plan-build cleanup
   minimial-habitat-app: 
   minimial-habitat-app: Source Path: /hab/cache/src/minimial-habitat-app-0.1.0
   minimial-habitat-app: Installed Path: /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834
   minimial-habitat-app: Artifact: /src/results/jbauman-minimial-habitat-app-0.1.0-20180702210834-x86_64-linux.hart
   minimial-habitat-app: Build Report: /src/results/last_build.env
   minimial-habitat-app: SHA256 Checksum: af615a4f0b5eaaf7b77a827fac2024ac76a8c787f4f3a9d1c0a5bc5503356bbf
   minimial-habitat-app: Blake2b Checksum: 564d0d91cc85f1973c0ce4e4d54f73d77b65072a67c40302d6fcf03310c98009
   minimial-habitat-app: 
   minimial-habitat-app: I love it when a plan.sh comes together.
   minimial-habitat-app: 
   minimial-habitat-app: Build time: 0m0s
[27][default:/src:0]# hab pkg install jbauman/minimial-habitat-app
» Installing jbauman/minimial-habitat-app
☁ Determining latest version of jbauman/minimial-habitat-app in the 'stable' channel
∵ Missing remote version of 'jbauman/minimial-habitat-app' in the 'stable' channel, but an installed version was found locally (jbauman/minimial-habitat-app/0.1.0/20180702210834)
→ Using jbauman/minimial-habitat-app/0.1.0/20180702210834
★ Install of jbauman/minimial-habitat-app/0.1.0/20180702210834 complete with 0 new packages installed.
[28][default:/src:0]# ls /hab/pkgs/
core/    jbauman/ 
[28][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210
20180702210015/ 20180702210452/ 20180702210834/ 
[28][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834/
FILES     IDENT     MANIFEST  TARGET    TYPE      hooks/    
[28][default:/src:0]# ls /hab/pkgs/jbauman/minimial-habitat-app/0.1.0/20180702210834/hooks/
[29][default:/src:0]# hab svc unload jbauman/minimial-habitat-app
Unloading jbauman/minimial-habitat-app
[30][default:/src:0]# ls /hab/svc/minimial-habitat-app/
PID  config  data  files  hooks  logs  run  static  var
[31][default:/src:0]# ls /hab/svc/minimial-habitat-app/hooks/
run
[32][default:/src:0]# hab svc load jbauman/minimial-habitat-app
The jbauman/minimial-habitat-app service was successfully loaded
[33][default:/src:0]# ls /hab/svc/minimial-habitat-app/
PID     config/ data/   files/  hooks/  logs/   run     static/ var/    
[33][default:/src:0]# ls /hab/svc/minimial-habitat-app/hooks/
run
christophermaier commented 5 years ago

This will be taken care of in a broader refactoring of how services are shut down and restarted that I'm currently working on.

christophermaier commented 5 years ago

Reopening this after #6348.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.