Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
host: Use new TCP connections after updating flynn-host
Browse files Browse the repository at this point in the history
Signed-off-by: Lewis Marshall <lewis@lmars.net>
  • Loading branch information
lmars committed Nov 23, 2016
1 parent d8246a3 commit 460311b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion host/cli/update.go
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path"
"sync"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/docker/go-units"
ct "github.com/flynn/flynn/controller/types"
"github.com/flynn/flynn/pkg/cluster"
"github.com/flynn/flynn/pkg/dialer"
"github.com/flynn/flynn/pkg/exec"
"github.com/flynn/flynn/pkg/tufutil"
"github.com/flynn/flynn/pkg/version"
Expand Down Expand Up @@ -238,9 +240,17 @@ func runUpdate(args *docopt.Args) error {
return err
}

// create a new cluster client to avoid reusing TCP connections to hosts
// which are shutting down as part of the update
clusterClient = cluster.NewClientWithHTTP(nil, &http.Client{Transport: &http.Transport{Dial: dialer.Retry.Dial}})

// use a flag to determine whether to use a TTY log formatter because actually
// assigning a TTY to the job causes reading images via stdin to fail.
cmd := exec.Command(updaterImage, "/bin/updater", fmt.Sprintf("--tty=%t", term.IsTerminal(os.Stdout.Fd())))
cmd := exec.CommandUsingCluster(
clusterClient,
updaterImage,
"/bin/updater", fmt.Sprintf("--tty=%t", term.IsTerminal(os.Stdout.Fd())),
)
cmd.Stdin = bytes.NewReader(imageJSON)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down

0 comments on commit 460311b

Please sign in to comment.