Skip to content

Commit 6b13457

Browse files
daixiang0Mukundan Sundararajan
andauthored
fix shutdown hang when enable socket (#835)
* fix shutdown hang when enable socket Signed-off-by: Loong <[email protected]> * feedback Signed-off-by: Loong <[email protected]> Co-authored-by: Loong <[email protected]> Co-authored-by: Mukundan Sundararajan <[email protected]>
1 parent 91e1571 commit 6b13457

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

pkg/metadata/metadata.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ func Put(httpPort int, key, value, appID, socket string) error {
7878
}
7979

8080
defer r.Body.Close()
81+
if socket != "" {
82+
// Retryablehttp does not close idle socket connections.
83+
defer client.HTTPClient.CloseIdleConnections()
84+
}
8185
return nil
8286
}
8387

tests/e2e/standalone/standalone_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ const (
3737
daprDashboardVersion = "0.9.0"
3838
)
3939

40-
// Removing unix domain socket tests till shutdown API with unix domain sockets is fixed.
41-
// https://github.com/dapr/dapr/issues/3894
42-
var socketCases = []string{""}
40+
var socketCases = []string{"", "/tmp"}
4341

4442
func TestStandaloneInstall(t *testing.T) {
4543
// Ensure a clean environment.
@@ -382,14 +380,13 @@ func testRun(t *testing.T) {
382380
assert.Contains(t, output, "Exited Dapr successfully")
383381
})
384382

385-
// t.Run("API shutdown with socket", func(t *testing.T) {
386-
// // Test that the CLI exits on a daprd shutdown.
387-
// output, err := spawn.Command(daprPath, "run", "--app-id", "testapp", "--unix-domain-socket", "/tmp", "--", "bash", "-c", "curl --unix-socket /tmp/dapr-testapp-http.socket -v -X POST http://unix/v1.0/shutdown; sleep 10; exit 1")
388-
// t.Log(output)
389-
// require.NoError(t, err, "run failed")
390-
// assert.Contains(t, output, "Exited App successfully", "App should be shutdown before it has a chance to return non-zero")
391-
// assert.Contains(t, output, "Exited Dapr successfully")
392-
// })
383+
t.Run("API shutdown with socket", func(t *testing.T) {
384+
// Test that the CLI exits on a daprd shutdown.
385+
output, err := spawn.Command(daprPath, "run", "--app-id", "testapp", "--unix-domain-socket", "/tmp", "--", "bash", "-c", "curl --unix-socket /tmp/dapr-testapp-http.socket -v -X POST http://unix/v1.0/shutdown; sleep 10; exit 1")
386+
t.Log(output)
387+
require.NoError(t, err, "run failed")
388+
assert.Contains(t, output, "Exited Dapr successfully")
389+
})
393390
}
394391

395392
func executeAgainstRunningDapr(t *testing.T, f func(), daprArgs ...string) {

0 commit comments

Comments
 (0)