From f39e866d2fda21e3527139f8f6de91fb2984abd3 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Mon, 18 May 2026 11:52:03 -0400 Subject: [PATCH 1/2] fix for agent graceful shutdown handling (#1251) --- CHANGELOG.md | 4 ++++ Makefile | 18 ++++++++++++++++++ agent/agent.go | 22 ++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c47715f..8d16d47f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..fe0e684d --- /dev/null +++ b/Makefile @@ -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 ./... \ No newline at end of file diff --git a/agent/agent.go b/agent/agent.go index cf3646d1..e8b83cc6 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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) From 2c56fc4e43d5f845408f6ff99c0d5b0a1b0cfa25 Mon Sep 17 00:00:00 2001 From: Nico Alba Date: Mon, 18 May 2026 16:37:58 +0000 Subject: [PATCH 2/2] new hook updates --- .github/workflows/mattermost-doc-alerts.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/mattermost-doc-alerts.yml b/.github/workflows/mattermost-doc-alerts.yml index d3543b7b..ac386f7c 100644 --- a/.github/workflows/mattermost-doc-alerts.yml +++ b/.github/workflows/mattermost-doc-alerts.yml @@ -1,7 +1,5 @@ name: mattermost-doc-alerts on: - issues: - types: [opened, closed, reopened] issue_comment: pull_request_review: types: [submitted] @@ -23,7 +21,7 @@ jobs: - name: Strip Vercel HTML from event JSON id: preprocess run: | - CLEANED_JSON=$(jq -c 'if .comment.body then .comment.body |= gsub("\\s*]*vercel\\.com[^>]*>.*?"; ""; "ig") else . end' "$GITHUB_EVENT_PATH") + CLEANED_JSON=$(jq -c 'if .comment.body then .comment.body |= (gsub("\\s*]*vercel\\.com[^>]*>.*?"; ""; "ig") | gsub("\\[vc\\]: #[^\\n]*\\n?"; "")) else . end' "$GITHUB_EVENT_PATH") echo "event_json<> "$GITHUB_OUTPUT" echo "$CLEANED_JSON" >> "$GITHUB_OUTPUT" echo "DELIM" >> "$GITHUB_OUTPUT"