removing function that isn't being used yet

This commit is contained in:
Zack Mullaly 2018-11-22 14:03:49 -05:00
Родитель 9b3205867a
Коммит 49476d62b7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1486642516ED3535
1 изменённых файлов: 0 добавлений и 80 удалений

Просмотреть файл

@ -324,86 +324,6 @@ func (db *DB) GetActionCounters(aid float64) (counters mig.ActionCounters, err e
return
}
// SetupRunnableActionsForAgent retrieves actions that are ready to be run by a particular agent.
func (db *DB) SetupRunnableActionsForAgent(agent mig.Agent) ([]mig.Action, error) {
actions := []mig.Action{}
actionRows, err := db.c.Query(`
update actions
set status='scheduled'
where status='pending'
and validfrom < now()
and expireafter > now()
returning id,
name,
target,
description,
threat,
operations,
validfrom,
expireafter,
status,
pgpsignatures,
syntaxversion;
`)
if actionRows != nil {
defer actionRows.Close()
}
if err != nil && err != sql.ErrNoRows {
err = fmt.Errorf("Error while setting up runnable actions: '%s'", err.Error())
return []mig.Action{}, err
}
for actionRows.Next() {
retrieved := actionFromDB{}
agentIsTargeted := false
err := actionRows.Scan(
&retrieved.ID,
&retrieved.Name,
&retrieved.Target,
&retrieved.DescriptionJSON,
&retrieved.ThreatJSON,
&retrieved.OperationsJSON,
&retrieved.ValidFrom,
&retrieved.ExpireAfter,
&retrieved.Status,
&retrieved.SignaturesJSON,
&retrieved.SyntaxVersion)
if err != nil {
err = fmt.Errorf("Error retrieving action: '%s'", err.Error())
return []mig.Action{}, err
}
action, err := deserializeActionFromDB(retrieved)
if err != nil {
return []mig.Action{}, err
}
// This is a very unfortunate concession to have to make, but it's essentially
// the same thing that `ActiveAgentsByTarget` does in `database/agents.go`.
query := fmt.Sprintf(`
select $1 in
(select distinct on (queueloc) id
from agents
where status in ('%s', '%s')
and (%s)
);
`, mig.AgtStatusOnline, mig.AgtStatusIdle, action.Target)
err = db.c.QueryRow(query, agent.ID).Scan(&agentIsTargeted)
if err != nil {
return []mig.Action{}, err
}
if agentIsTargeted {
actions = append(actions, action)
}
}
return actions, nil
}
// SetupRunnableActions retrieves actions that are ready to run. This function is designed
// to run concurrently across multiple schedulers, by update the status of the action at
// the same time as retrieving it. It returns an array of actions rady to be run.