Skip to content

Commit

Permalink
connect: remove proxy socket for restarted client
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Sep 25, 2019
1 parent 047b93c commit bb0d807
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/allocrunner/consulsock_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ func (s *sockProxy) run(alloc *structs.Allocation) error {
}

hostGRPCSockPath := filepath.Join(s.allocDir.AllocDir, allocdir.AllocGRPCSocket)

// if the socket already exists we'll try to remove it, but if not then any
// other errors will bubble up to the caller here or when we try to listen
_, err := os.Stat(hostGRPCSockPath)
if err == nil {
err := os.Remove(hostGRPCSockPath)
if err != nil {
return fmt.Errorf(
"unable to remove existing unix socket for Consul gRPC endpoint: %v", err)
}
}

listener, err := net.Listen("unix", hostGRPCSockPath)
if err != nil {
return fmt.Errorf("unable to create unix socket for Consul gRPC endpoint: %v", err)
Expand Down

0 comments on commit bb0d807

Please sign in to comment.