Fix orphaned app process and async bind error in apps run-local#5509
Open
simonfaltum wants to merge 2 commits into
Open
Fix orphaned app process and async bind error in apps run-local#5509simonfaltum wants to merge 2 commits into
simonfaltum wants to merge 2 commits into
Conversation
If proxy setup failed, the already-started app process was never killed and kept running in the background holding the app port. The proxy listener was also bound inside a goroutine, so a taken proxy port only printed an error while the command kept running without a working proxy. Kill the app process on the proxy setup error path, and bind the proxy listener synchronously (via the new appproxy Listen/Serve split) before serving in a goroutine so bind errors fail the command. Co-authored-by: Isaac
Contributor
Approval status: pending
|
Collaborator
|
Commit: 5b59f34
22 interesting tests: 15 SKIP, 7 KNOWN
Top 29 slowest tests (at least 2 minutes):
|
Co-authored-by: Isaac
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.
Why
Found during a full-repo review of the CLI.
databricks apps run-localstarts the app process before setting up the local proxy. If proxy setup failed (for example the current-user lookup failed), the CLI exited but the app process kept running in the background, holding the app port. Separately, the proxy listener was bound inside a goroutine, so when the proxy port was already taken the CLI only printed an error and kept running without a working proxy.Changes
Before, a proxy setup failure left the already-started app process running forever, and a taken proxy port did not stop the command; now both cases fail the command cleanly and the app process is killed.
cmd/apps/run_local.go: bind the proxy listener synchronously insetupProxyso bind errors fail the command, and only serve in the goroutine. On the proxy setup error path, kill and reap the already-started app process via the newkillAppProcesshelper.libs/appproxy: exportListenandServeso callers can bind synchronously and serve in the background. RemoveListenAndServe, which combined the two steps and has no remaining callers.Test plan
TestSetupProxyPortInUseverifiessetupProxyreturns an error synchronously when the proxy port is already taken (previously it returned nil)TestKillAppProcessverifies a running app process is killed and reapedgo test ./libs/appproxy ./cmd/appspasses; new tests also pass with-race./task fmt-q,./task lint-q, and./task checkspassThis pull request and its description were written by Isaac.