Repository navigation
fix(go): close the last signal.Notify path in the test OCI server - #463
Merged
Merged
Conversation
Follow-ups from the review of #411: - RepoOciServerStart no longer sets an HTTP drain timeout, which made distribution's Registry.ListenAndServe call signal.Notify and take over the host JVM's SIGINT/SIGTERM handlers - install.go explains why signal.Notify is not used and the trade-off (a signal no longer cancels an in-flight install); use client.Run - HelmSignalHandlerTest is bounded by a timeout, keeps the child's output, uses @tempdir, asserts that shutdown hooks run, and covers install, template and the test OCI server - NativeLibraryTest clears the forceUpdate system property, and TestSearchRepo creates its repositories file in t.TempDir() Relates to #409 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Marc Nuri <marc@marcnuri.com>
Both swallowed setup errors, so a failure surfaced later as an unrelated assertion (an empty search result, or a ConnectException after 30 s) instead of its cause: - TestSearchRepo fails on a RepoAdd error, and uses a path in t.TempDir() instead of an unchecked temp file (RepoAdd creates it) - the signal test's OCI probe throws with the native error when the test OCI server fails to start Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Marc Nuri <marc@marcnuri.com>
manusa
commented
Nov 21, 2026
manusa
left a comment
Owner
Author
There was a problem hiding this comment.
Review of #463
Verdict: approve. This is a comment rather than an approval only because it's my own PR. There are no Critical or Important findings. The two minor suggestions from the review of 4c107a8 are already addressed in 940c556.
This PR delivers every suggestion from the #411 review:
- The
install.gocomment is accurate and names SIGQUIT. DrainTimeoutis removed.- The signal test has a timeout and keeps the child's output.
- It uses
@TempDir. - It asserts the shutdown hook and covers
template.
The description matches the diff.
Correctness
DrainTimeoutremoval. distribution v3.1.2 (native/go.mod) returnsserver.Serve(ln)whenDrainTimeout == 0(registry/registry.go:325-327), before thesignal.Notifyat:330.- Nothing relied on the drain: it only runs after a signal,
serverStopnever stops OCI servers, and nothing callsShutdownor helm'srepotest.NewOCIServer. - Nothing else linked into the library reaches
signal.Notify. The kubectlinterruptandtermhelpers are linked, but nothing calls them.
- Nothing relied on the drain: it only runs after a signal,
install.go. In helm v3.22.1,Install.RunisRunWithContext(context.Background(), …). The comment's trade-off is accurate:failReleasemarks the release failed, or uninstalls it withAtomic;pending-installis set before the run;upgradenever had signal cancellation.
HelmSignalHandlerTest
- Black-box behaviour. It asserts exit code 143 and the shutdown-hook marker. The OCI case uses
HelmLibHolder.INSTANCEto start the test registry, asHelmRegistryTest,HelmPushTestandHelmShowTestalready do, since no public API exists for it. - Timing and cleanup. The timing fits within the 2-minute
@Timeout. The child is destroyed before the@TempDiris cleaned up, and the native library extraction and Go'sTMPDIRboth land in the@TempDir. - Each case fails on its own when its bug returns:
- with the pre-#411
signal.Notifyback ininstall(), only the install and template cases fail; - with
DrainTimeout = 1sback, only the OCI case fails.
- with the pre-#411
- CI. It runs on Linux and macOS: 3/3 on macOS in 10.9 s. Windows is skipped by design.
Addressed in 940c556
TestSearchReponow uses a path int.TempDir(), whichRepoAddcreates, and fails on aRepoAdderror instead of reporting a confusing search failure.- The signal test's OCI probe throws with the native error when the test OCI server fails to start, instead of hitting an unrelated
ConnectException30 s later.
Follow-up, tracked separately
The other Go RepoAdd tests still create their file with os.CreateTemp("", …), which leaves /tmp/repositories.lock behind. They, and the Java tests, also write to the developer's real ~/.cache/helm. Test isolation is handled in a separate PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups from the review of #411, which stopped the native library from replacing the host JVM's signal handlers during
install.Relates to #409
Changes
install.gocomment andclient.Run. The comment now explains whysignal.Notifyis deliberately not used: in a c-shared library it takes over the JVM's SIGINT/SIGTERM/SIGQUIT handlers for good, so shutdown hooks never run andkill -3thread dumps stop working. It also states the trade-off: a signal no longer cancels an in-flight install, and the release can be leftpending-install. It references Go runtime signal handlers permanently replace the host JVM's SIGINT/SIGTERM handlers after install #409, fix(go): stop replacing host process signal handlers during install #411, fix: prevent segmentation faults when performing helm install #113 and Segmentation faults and other native errors running helm-java with async-profiler #112.client.Run(...)replacesRunWithContext(context.Background(), ...), which is the same call in helm v3.22.1.signal.Notifypath closed.RepoOciServerStartno longer setsconfig.HTTP.DrainTimeout. With a non-zero value, distribution'sRegistry.ListenAndServeregisterssignal.Notify(..., os.Interrupt, syscall.SIGTERM). With 0 it serves directly (distribution v3.1.2registry/registry.go:325-330). So a JVM that starts the test OCI registry (HelmPushTest,HelmRegistryTest,HelmShowTest, or a downstream test) keeps its handlers. Nothing else linked into the library reachessignal.Notify.HelmSignalHandlerTesthardened.@Timeout(2 min, SEPARATE_THREAD)bounds each test.@TempDirand appears in every assertion description. A file is needed becauseProcess.destroy()closes the pipes, which would lose the output written after SIGTERM.TMPDIRalso go to the@TempDir, so nothing is left behind even if the child has to be killed.install,template, and starting the test OCI server. The OCI case waits for an HTTP response, which proves that any signal handlers are already registered.NativeLibraryTestnow clears thecom.marcnuri.jkube-helm.forceUpdatesystem property, which leaked to later tests.TestSearchRepocreates its repositories file int.TempDir()instead of leaving it in the system temp directory.Testing
On Java 8 (linux/amd64):
make build-native,gofmt -l,go vetandgit diff --checkare clean.HelmSignalHandlerTestpasses 3/3, repeated over several runs at about 1–6 s per case.HelmPushTest,HelmRegistryTest,HelmShowTest, thelib/apitests, and the Go tests that use the OCI server (TestPush*,TestRegistryLogin*,TestRegistryLogout) all pass, as do theinstall/template/upgradeGo tests andTestSearchRepo.Fail-without-fix checks, each against a rebuilt native library:
signal.Notifyput back ininstall(), the install and template cases fail ("JVM should exit on SIGTERM after a native helm install call (issue Go runtime signal handlers permanently replace the host JVM's SIGINT/SIGTERM handlers after install #409)", with the child's output), and the OCI case passes.DrainTimeout = 1sput back, only the OCI case fails.