Skip to content

Commit

Permalink
fix shutdown hang when enable socket
Browse files Browse the repository at this point in the history
Signed-off-by: Loong <loong.dai@intel.com>
  • Loading branch information
daixiang0 committed Nov 17, 2021
1 parent 20c3640 commit 9667ecf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions pkg/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func Put(httpPort int, key, value, appID, socket string) error {
}

defer r.Body.Close()
if socket != "" {
// Retryablehttp does not close idle socket connections.
defer client.HTTPClient.CloseIdleConnections()
}
return nil
}

Expand Down
15 changes: 7 additions & 8 deletions tests/e2e/standalone/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,13 @@ func testRun(t *testing.T) {
assert.Contains(t, output, "Exited Dapr successfully")
})

// t.Run("API shutdown with socket", func(t *testing.T) {
// // Test that the CLI exits on a daprd shutdown.
// 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")
// t.Log(output)
// require.NoError(t, err, "run failed")
// assert.Contains(t, output, "Exited App successfully", "App should be shutdown before it has a chance to return non-zero")
// assert.Contains(t, output, "Exited Dapr successfully")
// })
t.Run("API shutdown with socket", func(t *testing.T) {
// Test that the CLI exits on a daprd shutdown.
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")
t.Log(output)
require.NoError(t, err, "run failed")
assert.Contains(t, output, "Exited Dapr successfully")
})
}

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

0 comments on commit 9667ecf

Please sign in to comment.