Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: /quitquitquit api now responds to HTTP GET and POST requests. #1947

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Sep 13, 2023

The /quitquitquit endpoint used to return a 400 error when it received a request other than an HTTP POST. Now, it
will shut down the proxy if it receives either a GET or a POST request. This will make it possible for kubernetes
pod lifecycle handlers to gracefully signal the proxy to shut down.

Fixes #1946

cmd/root_test.go Outdated
@@ -1307,7 +1307,7 @@ func TestPProfServer(t *testing.T) {
}
}

func TestQuitQuitQuit(t *testing.T) {
func TestQuitQuitQuitHttpPost(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

cmd/root_test.go Outdated
c := NewCommand(WithDialer(&spyDialer{}))
c.SilenceUsage = true
c.SilenceErrors = true
c.SetArgs([]string{"--quitquitquit", "--admin-port", "9192", "my-project:my-region:my-instance"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use 9193 or some other port to avoid conflicts with the test above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

cmd/root_test.go Outdated
@@ -1348,6 +1348,41 @@ func TestQuitQuitQuit(t *testing.T) {
}
}

func TestQuitQuitQuitHttpGet(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@hessjcg hessjcg requested a review from enocom September 14, 2023 18:19
cmd/root_test.go Outdated
errCh <- err
}()

resp, err := tryDial("GET", "http://localhost:9192/quitquitquit")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we pull the port out as a constant to avoid this kind of mistake (9192 here, 9193 above)

@enocom enocom self-requested a review September 14, 2023 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow HTTP GET to /quitquitquit admin api for k8s compatibility
3 participants