habitat icon indicating copy to clipboard operation
habitat copied to clipboard

`hab unload` followed by `hab start` does not usually result in a service restart

Open stevendanna opened this issue 6 years ago • 8 comments

Running hab unload followed by hab start does not usually result in a service restart.

This isn't necessarily a bug but a consequence of the current hab-sup implementation that might not be clear to users from the documentation alone.

If the unload and start happen inside the file_watcher timeout and if the start command produces the same spec file content that existed on disk before the unload, no change to the service will occur. A brief skimming of the code seems to indicate that the file-watcher uses a poll-based approach rather than relying on notifications from the operating system.

For example, the following test script will show that the PID does not change on almost every run (the script obviously needs to be modified to use a service that you can start:

#!/bin/bash

TEST_WAIT=5
for i in {1..100}; do
    PID_BEFORE=$(cat /hab/svc/authz-service/PID)
    hab sup unload chef/authz-service
    hab sup start chef/authz-service --channel dev --bind automate-postgresql:automate-postgresql.default
    sleep $TEST_WAIT

    PID_AFTER=$(cat /hab/svc/authz-service/PID)
    if [[ "$PID_AFTER" = "$PID_BEFORE" ]]; then
       echo "PID changed: NO ($PID_AFTER)"
    else
       echo "PID changed: YES ($PID_BEFORE -> $PID_AFTER)"
    fi
done

This might be unexpected for some users who have read the documentation which says:

https://www.habitat.sh/docs/habitat-cli/#hab-svc:

If the Supervisor is running when the service is unloaded the service will be stopped.

stevendanna avatar Mar 26 '18 10:03 stevendanna

Hi @stevendanna, I think what you're running into will be addressed by this: https://github.com/habitat-sh/habitat/pull/4805

tashimi avatar Mar 26 '18 16:03 tashimi

Not quite yet, #4805 is a predecessor for the change which will address this

reset avatar Mar 26 '18 18:03 reset

Confirmed this is still an issue in 0.56.0, although in 0.56.0 unload is not the right command, rather you can reproduce this with stop followed by start.

stevendanna avatar Jun 04 '18 17:06 stevendanna

The scoping of #4805 was altered a bit so this will actually be resolved when https://github.com/habitat-sh/habitat/issues/1973 is closed

reset avatar Jun 05 '18 19:06 reset

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] avatar Apr 03 '20 01:04 stale[bot]

I haven't tested this again but I'm fairly certain this is still an issue.

stevendanna avatar Apr 03 '20 10:04 stevendanna

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] avatar Aug 12 '22 10:08 stale[bot]

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] avatar Aug 12 '23 16:08 stale[bot]