fix: Tidy up closes for nicer output (#4605)

* fix: Tidy up closes for nicer output

There was a context canceled message that would appear
because of traces, and this was using the wrong close.

I don't think it was causing any specific problems, but
it could make a replica warning appear on restart.

* Fix migration and experimental
This commit is contained in:
Kyle Carberry
2022-10-17 18:36:23 -05:00
committed by GitHub
parent e0a14f68fa
commit c5afaffa7e
7 changed files with 12 additions and 14 deletions
+2 -1
View File
@@ -609,7 +609,8 @@ func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
// ExperimentalEnabled returns if the experimental feature flag is enabled.
func ExperimentalEnabled(cmd *cobra.Command) bool {
return cliflag.IsSetBool(cmd, varExperimental)
enabled, _ := cmd.Flags().GetBool(varExperimental)
return enabled
}
// EnsureExperimental will ensure that the experimental feature flag is set if the given flag is set.
+3 -4
View File
@@ -476,14 +476,13 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
), dflags.PromAddress.Value, "prometheus")()
}
// We use a separate closer so the Enterprise API
// We use a separate coderAPICloser so the Enterprise API
// can have it's own close functions. This is cleaner
// than abstracting the Coder API itself.
coderAPI, closer, err := newAPI(ctx, options)
coderAPI, coderAPICloser, err := newAPI(ctx, options)
if err != nil {
return err
}
defer closer.Close()
client := codersdk.New(localURL)
if dflags.TLSEnable.Value {
@@ -663,7 +662,7 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
wg.Wait()
cmd.Println("Waiting for WebSocket connections to close...")
_ = coderAPI.Close()
_ = coderAPICloser.Close()
cmd.Println("Done waiting for WebSocket connections")
// Close tunnel after we no longer have in-flight connections.