Skip to content

Commit

Permalink
Gracefully stop collector container
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Oct 20, 2023
1 parent e7c822e commit 7723e48
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/infra/open_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ func NewCollector(ctx context.Context, cli *client.Client, net *Networks, params

}

// Close kills and deletes the container and deletes updater mount paths related to the run.
func (u *Collector) Close() error {
return u.cli.ContainerRemove(context.Background(), u.containerID, types.ContainerRemoveOptions{
Force: true,
})
// Close stops and removes the container.
func (c *Collector) Close() error {
timeout := 5
_ = c.cli.ContainerStop(context.Background(), c.containerID, container.StopOptions{Timeout: &timeout})

err := c.cli.ContainerRemove(context.Background(), c.containerID, types.ContainerRemoveOptions{Force: true})
if err != nil {
return fmt.Errorf("failed to remove collector container: %w", err)
}
return nil
}

0 comments on commit 7723e48

Please sign in to comment.