Hello.
I have a case where GitHub codespaces open a connection to my Zrok when a codespace activates on Github. I am not able to disable the Zrok before the codespace shut down therefore I would nees some kind of timeout that outclose the connection to the container. Is this possible to do in Zrok?
Welcome, @Unksess.
Does your GitHub Codespace connect to a zrok public share URL or a zrok private access frontend, i.e., runs zrok access private
in the Codespace?
1 Like
Hello.
Each unique git repo is used as a name in order to reserve a name. I do use public reserve.
Ah, so you want the reservation to be cleaned up as part of the GitHub Codespace shutdown process or as part of deleting the GitHub repo? Or, are those the same thing in this case?
There is an API and CLI operation for deleting a reservation.
CLI example:
zrok release mycodespacerepo
This requires that ~/.zrok
contains the zrok environment that owns the reserved share token you wish to release. That is, the same zrok environment for which you exec'd zrok reserve public --unique-name mycodespacerepo
.
The DELETE /unshare
API operation requires parameters including the zrok environment ID and share token. If you're implementing that API you can GET /overview
and parse out the environment IDs and their respective shares to compose the unshare request.
Thanks for your input. GitHub Codespaces does not offer any way as I know to actually hook the shutdown of the codespace. I tried to trap SIGKILL / SIGINT and also look for hooks "onShutdown", checked the devcontainer file format and so on.
Therefore the easiest solution would be to have some kind of "release time", where the name could be released automatically if no activity has been seen for the x amount of minutes / hours.
Or I would need to have some kind of external script for this "garbage collection" externally.
Are the zrok enable
and zrok reserve public
commands also exec'd inside the Codespace? If so, is it necessary for the share token to be predictable, i.e., resembling the repo name?
If not predictable, a temporary share with a random token is self-cleaning as long as the zrok share public
command can exit gracefully.