mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
Cleanup live query store for orphaned query (#847)
Cleans up a case in which a query could continue to be returned even after it had been detected orphaned.
This commit is contained in:
parent
fc4924a321
commit
e33391e8d3
2 changed files with 5 additions and 0 deletions
|
|
@ -1010,6 +1010,9 @@ func (svc service) ingestDistributedQuery(host kolide.Host, name string, rows []
|
|||
// execute that query when we can't write to any subscriber
|
||||
campaign, err := svc.ds.DistributedQueryCampaign(uint(campaignID))
|
||||
if err != nil {
|
||||
if err := svc.liveQueryStore.StopQuery(strconv.Itoa(int(campaignID))); err != nil {
|
||||
return osqueryError{message: "stop orphaned campaign after load failure: " + err.Error()}
|
||||
}
|
||||
return osqueryError{message: "loading orphaned campaign: " + err.Error()}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1321,6 +1321,8 @@ func TestIngestDistributedQueryOrphanedCampaignLoadError(t *testing.T) {
|
|||
return nil, fmt.Errorf("missing campaign")
|
||||
}
|
||||
|
||||
lq.On("StopQuery", "42").Return(nil)
|
||||
|
||||
host := kolide.Host{ID: 1}
|
||||
|
||||
err := svc.ingestDistributedQuery(host, "fleet_distributed_query_42", []map[string]string{}, false, "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue