Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions integration/e2e/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func (s *ConcreteService) Stop() error {
logger.Log("Stopping", s.name)

if out, err := RunCommandAndGetOutput("docker", "stop", "--time=30", s.containerName()); err != nil {
// If the container has already exited and been removed (e.g., started
// with --rm), treat it as a successful stop.
if strings.Contains(string(out), "No such container") {
s.usedNetworkName = ""
return nil
}
logger.Log(string(out))
return err
}
Expand All @@ -181,6 +187,12 @@ func (s *ConcreteService) Kill() error {
logger.Log("Killing", s.name)

if out, err := RunCommandAndGetOutput("docker", "kill", s.containerName()); err != nil {
// If the container has already exited and been removed (e.g., started
// with --rm), treat it as a successful kill.
if strings.Contains(string(out), "No such container") {
s.usedNetworkName = ""
return nil
}
logger.Log(string(out))
return err
}
Expand Down
8 changes: 8 additions & 0 deletions integration/runtime_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ overrides:
"-querier.store-gateway-addresses": strings.Join([]string{storeGateway.NetworkGRPCEndpoint()}, ","),
}), "")
require.Error(t, s.StartAndWaitReady(querier))
// Stop the failed service to unregister it before retrying with the same name.
// Ignore error: if the container crashed before Start() completed, the service
// was never registered and Stop() returns "does not exist" which is fine.
_ = s.Stop(querier)

// Start Query frontend
queryFrontend := e2ecortex.NewQueryFrontendWithConfigFile("query-frontend", "", flags, "")
Expand All @@ -231,6 +235,8 @@ overrides:
// Ruler start, but fail with "-distributor.shard-by-all-labels": "false"
ruler := e2ecortex.NewRuler("ruler", consul.NetworkHTTPEndpoint(), mergeFlags(flags, RulerFlags()), "")
require.Error(t, s.StartAndWaitReady(ruler))
// Stop the failed service to unregister it before retrying with the same name.
_ = s.Stop(ruler)

// Ruler start, should success with "-distributor.shard-by-all-labels": "true"
ruler = e2ecortex.NewRuler("ruler", consul.NetworkHTTPEndpoint(), mergeFlags(flags, RulerFlags(), map[string]string{
Expand All @@ -249,6 +255,8 @@ overrides:
// Distributor start, but fail with "-distributor.shard-by-all-labels": "false"
distributor := e2ecortex.NewQuerier("distributor", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), mergeFlags(flags, map[string]string{}), "")
require.Error(t, s.StartAndWaitReady(distributor))
// Stop the failed service to unregister it before retrying with the same name.
_ = s.Stop(distributor)

// Distributor start, should success with "-distributor.shard-by-all-labels": "true"
distributor = e2ecortex.NewQuerier("distributor", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), mergeFlags(flags, map[string]string{
Expand Down
Loading