fix for agent graceful shutdown handling (#1251)

This commit is contained in:
Michael Quigley
2026-05-18 11:52:03 -04:00
parent fc3492829e
commit f39e866d2f
3 changed files with 42 additions and 2 deletions
+4
View File
@@ -1,5 +1,9 @@
# CHANGELOG
## v2.0.4
FIX: The agent no longer deletes reserved shares from the controller during graceful shutdown or after an abnormal subordinate process exit. Previously, a `SIGTERM`/`SIGINT` (e.g., on system reboot) caused the agent to issue an unconditional `DeleteShare` against the controller for every active share, destroying the reservation for private shares created with `--share-token` and for public shares with reserved names. The reservation is now preserved unless the user explicitly released the share via `zrok2 agent release`, allowing the agent to reattach on the next start. (https://github.com/openziti/zrok/issues/1251)
## v2.0.3
FIX: The Python SDK `ProxyShare` now rejects absolute proxy request paths before forwarding. This prevents a viewer from using an absolute URL path to make the proxy host request arbitrary internal or loopback services instead of the configured target.
+18
View File
@@ -0,0 +1,18 @@
.DEFAULT_GOAL := build
TARGETS ?= ./cmd/zrok2
.PHONY: clean build test
clean:
rm -rf ui/node_modules ui/dist agent/agentUi/node_modules agent/agentUi/dist
build:
npm --prefix ui install
npm --prefix ui run build
npm --prefix agent/agentUi install
npm --prefix agent/agentUi run build
go install $(TARGETS)
test:
go test ./... -count=1
#go vet ./...
+20 -2
View File
@@ -385,8 +385,26 @@ func (a *Agent) manager() {
if err := proctree.WaitChild(shr.process); err != nil {
dl.Errorf("error joining share '%v': %v", shr.token, err)
}
if err := a.deleteShare(shr.token); err != nil {
dl.Errorf("error deleting share '%v': %v", shr.token, err)
// only delete from controller if the user explicitly released the share,
// or if it's an ephemeral (non-reserved) share. reserved shares must
// survive shutdown/crash so the agent can reattach on next start.
shouldDelete := outShare.releaseRequested
if !shouldDelete {
switch req := outShare.request.(type) {
case *SharePublicRequest:
shouldDelete = !req.hasReservedName()
case *SharePrivateRequest:
shouldDelete = !req.hasReservedToken()
default:
shouldDelete = true
}
}
if shouldDelete {
if err := a.deleteShare(shr.token); err != nil {
dl.Errorf("error deleting share '%v': %v", shr.token, err)
}
} else {
dl.Infof("preserving reserved share '%v' on controller for reattach", shr.token)
}
delete(a.shares, shr.token)