Skip to content

Commit

Permalink
fix: empty shard need ensure idle state every coordinate period
Browse files Browse the repository at this point in the history
  • Loading branch information
RayHuangCN committed Apr 23, 2021
1 parent 9785f22 commit e76c6fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/shard/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func (r *Shard) UpdateTarget(request *UpdateTargetsRequest) error {
}

if r.needUpdate(newTargets) {
r.log.Infof("%s need update targets", r.ID)
if len(newTargets) != 0 || len(r.scraping) != 0 {
r.log.Infof("%s need update targets", r.ID)
}
if err := r.APIPost(r.url+"/api/v1/shard/targets/", &request, nil); err != nil {
return err
}
Expand All @@ -108,7 +110,7 @@ func (r *Shard) UpdateTarget(request *UpdateTargetsRequest) error {
}

func (r *Shard) needUpdate(targets map[uint64]*target.Target) bool {
if len(targets) != len(r.scraping) {
if len(targets) != len(r.scraping) || len(targets) == 0 {
return true
}

Expand Down

0 comments on commit e76c6fb

Please sign in to comment.