elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.65k stars 8.23k forks source link

[Fleet] Agent Bulk Reassign bugs #170949

Open criamico opened 1 year ago

criamico commented 1 year ago

Kibana version: Bugs found in 8.11.0 but possibly present on lower versions

Describe the bugs:

  1. The POST /agents/bulk_reassign returns a 200 OK even though the request itself is empty, which makes troubleshooting hard. Consider returning a different response when the request is empty.
  2. The deprecated PUT /agents/bulk_reassign endpoint returns a 200 OK but the agents aren't actually reassigned. The endpoint was marked as deprecated in 8.8.0, but wasn't removed for bwc: https://github.com/elastic/kibana/pull/152236
elasticmachine commented 1 year ago

Pinging @elastic/fleet (Team:Fleet)

jillguyonnet commented 2 months ago

@criamico and I just tried the first endpoint manually and could not reproduce reported failure. Observations:

1. Request:

POST kbn:api/fleet/agents/bulk_reassign
{}

Result:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[request body.policy_id]: expected value of type [string] but got [undefined]"
}

2. Request:

POST kbn:api/fleet/agents/bulk_reassign
{
  "policy_id": "ea9a24e2-fdd1-4803-9ed6-2f285e236812"
}

Result:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[request body.agents]: expected at least one defined value but got [undefined]"
}

3. Request:

POST kbn:api/fleet/agents/bulk_reassign
{
  "agents": [],
  "policy_id": "52e08e76-20a6-4c64-a9d0-93b23220b697"
}

Result:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "No agents to reassign, already assigned or hosted agents"
}

4. Request:

POST kbn:api/fleet/agents/bulk_reassign
{
  "agents": ["473738ad-296a-4f39-b478-d94636550d44", "4f78e822-73d0-488b-a06f-77c40aecb859"]
}

Result:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[request body.policy_id]: expected value of type [string] but got [undefined]"
}

5. Request:

POST kbn:api/fleet/agents/bulk_reassign
{
  "agents": ["473738ad-296a-4f39-b478-d94636550d44", "4f78e822-73d0-488b-a06f-77c40aecb859"],
  "policy_id": "52e08e76-20a6-4c64-a9d0-93b23220b697"
}

Result (200):

{
  "actionId": "502e4c3a-5ecb-4488-add1-b5cc32902b99"
}