Skip to content

Commit

Permalink
Merge 59bfc81 into backport/NET-5187/highly-cute-koala
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-consul-core authored Aug 15, 2023
2 parents e489abc + 59bfc81 commit 8bd45c1
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions test/integration/consul-container/libs/service/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ func (g ConnectContainer) GetPort(port int) (int, error) {
}

func (g ConnectContainer) Restart() error {
_, err := g.GetStatus()
if err != nil {
return fmt.Errorf("error fetching sidecar container state %s", err)
var deferClean utils.ResettableDefer
defer deferClean.Execute()

if utils.FollowLog {
if err := g.container.StopLogProducer(); err != nil {
return fmt.Errorf("stopping log producer: %w", err)
}
}

fmt.Printf("Stopping container: %s\n", g.GetName())
err = g.container.Stop(g.ctx, nil)

err := g.container.Stop(g.ctx, nil)
if err != nil {
return fmt.Errorf("error stopping sidecar container %s", err)
}
Expand All @@ -81,6 +84,17 @@ func (g ConnectContainer) Restart() error {
if err != nil {
return fmt.Errorf("error starting sidecar container %s", err)
}

if utils.FollowLog {
if err := g.container.StartLogProducer(g.ctx); err != nil {
return fmt.Errorf("starting log producer: %w", err)
}
g.container.FollowOutput(&LogConsumer{})
deferClean.Add(func() {
_ = g.container.StopLogProducer()
})
}

return nil
}

Expand Down

0 comments on commit 8bd45c1

Please sign in to comment.