Post-stop hook doesn't appear to be called

I have an application set up with pre-start, post-start, and post-stop hooks. The first 2 are executing appropriately. The post-stop hook does not appear to be when ending a session. If I start a session then use amc to shell into the running instance, I can successfully execute the post-stop hook manually (from /var/lib/anbox/app/hooks). There are no errors when the session is ended so I can’t grab any logs. What should I check to figure out why this hook isn’t running?



Thanks for reaching out.

Would you let us know the image version that you were using?
Also, you could view instance runtime logs and figure out why it’s not executing. For instance, to do that:
$ amc launch <your_app_id>
$ amc logs -f <instance_id>

In another terminal, delete the instance:
$ amc delete <instance_id>

This would trigger the post-stop hook to be executed, which help you to diagnose the underlying issue a bit.


I think I found the issue. If I delete the instance using amc delete it does cause the post-stop hook to be called. If I end a session via the streaming gateway, which does kill the container, the post-stop hook is not called. Is there something I need to pass during session creation to allow the post-stop hook to be called?

I am using image version jammy:android13:arm64 and Anbox version 1.21.0

A: That’s correct. If you simply end a session, the post-stop hook won’t be called because it’s only executed when stopping an instance as you found.

A: By design, the post-stop hook only gets executed when stopping an instance. If I understand correctly, you are looking for a hook/mechanism which could be called whenever a session gets disconnected?

I may have used the wrong terminology. I am ending the session by calling the DELETE session endpoint on the streaming gateway. This stops, then removes the instance, so I would expect the post-stop hook to be called. Should I be deleting the instance using the DELETE instance endpoint on the AMS instead? If so, is the post-stop hook being called the only difference between deleting a session vs deleting an instance?

Thanks for the clarification.

This stops, then removes the instance, so I would expect the post-stop hook to be called.

A: Yes, in such a case, the post-stop hook should get called. As you found, when terminating a session by calling the DELETE session endpoint, it ultimately deletes the instance in the AMS as well.
I just gave it a quick try and can confirm that the same issue that you discovered can be easily reproduced.

Thanks for the bug report @devperson
I just created a bug to track the issue that you mentioned above