Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scraping service: stop scraping service instances on partial shutdown #417

Merged
merged 3 commits into from
Feb 18, 2021
Merged
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
9 changes: 8 additions & 1 deletion pkg/prom/ha/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,14 @@ func (s *Server) Stop() error {
s.cancel()
<-s.exited

return s.closeDependencies()
err := s.closeDependencies()

// Delete all the local configs that were running.
s.configManagerMut.Lock()
defer s.configManagerMut.Unlock()
s.im.Stop()

return err
}

// stopServices stops services in argument-call order. Blocks until all services
Expand Down
12 changes: 10 additions & 2 deletions pkg/prom/ha/sharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,16 @@ func (m ShardingInstanceManager) DeleteConfig(name string) error {
return err
}

// Stop implements instance.Manager.Stop.
func (m ShardingInstanceManager) Stop() { m.inner.Stop() }
// Stop implements instance.Manager.Stop. It only stops the configs
// passed through to this manager and not all instances.
func (m ShardingInstanceManager) Stop() {
for k := range m.keyToHash {
err := m.DeleteConfig(k)
if err != nil {
level.Error(m.log).Log("msg", "failed to remove config", "name", k, "err", err)
}
}
}

// owns checks if the ShardingInstanceManager is responsible for
// a given hash.
Expand Down