mirror of https://github.com/hashicorp/consul
Backport of NET-5187: Upgrade test timeout due to log producer errors into release/1.15.x (#18471)
backport of commit 59bfc81d49
Co-authored-by: NiniOak <anita.akaeze@hashicorp.com>
pull/18480/head
parent
3e5ffe5602
commit
a12708dc16
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue