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

Refactor search with updateByQuery #250

Merged
merged 7 commits into from
Jan 24, 2025

Conversation

f-galland
Copy link
Member

Description

This PR replaces the SearchThread class with a new one that uses updateByQuery to conform to the latest command-manager design requirements.

Issues

Closes #249

Match these with past due delivery timestamp
@f-galland f-galland linked an issue Jan 24, 2025 that may be closed by this pull request
@f-galland f-galland self-assigned this Jan 24, 2025
@f-galland
Copy link
Member Author

It looks like this works ok even for larger numbers of commands. I tested this with the following script:

#!/bin/bash

command='{"source":"Engine","user":"user53","target":{"id":"target4","type":"agent"},"action":{"name":"restart","args":{"arg1":"/path/to/executable/arg6"},"version":"v4"},"timeout":30}'
commands='{"commands": ['

for i in {1..744}
do
  commands+="$command"
  commands+=","
done

commands=${commands::-1}
commands+=']}'

echo $commands > commands.json

curl http://localhost:9200/_plugins/_command_manager/commands -H 'Content-Type: application/json' -d "$(cat commands.json)"

The number of commands, 744, was chosen as it was the maximum curl would allow me to send at once. I fired this repeatedly and then waited for the timeouts.

I then queried the engine for commands with failure status:

#!/bin/bash


echo -ne 'Failed:\n\n'
curl http://localhost:9200/.commands/_count -H 'Content-Type: application/json' -d '
{
  "query": { 
    "bool": { 
      "filter": [ 
        { "term":  { "command.status": "failure" }}
      ]
    }
  }
}
'
echo -ne '\n\nPending:\n\n'
curl http://localhost:9200/.commands/_count -H 'Content-Type: application/json' -d '
{
  "query": { 
    "bool": { 
      "filter": [ 
        { "term":  { "command.status": "pending" }}
      ]
    }
  }
}
'

This is what I got:

Failed:

{"count":3720,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0}}

Pending:

{"count":0,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0}}

@f-galland f-galland marked this pull request as ready for review January 24, 2025 15:22
@f-galland f-galland requested a review from a team as a code owner January 24, 2025 15:22
@AlexRuiz7 AlexRuiz7 merged commit deb9aaf into master Jan 24, 2025
1 check passed
@AlexRuiz7 AlexRuiz7 deleted the 226-refactor-search-with-updateByQuery branch January 24, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New commands maintenance design [BUG] Infinite loop during the pagination of search results
2 participants