Use different API to check assigned policy revisions#280
Use different API to check assigned policy revisions#280mtojek merged 4 commits intoelastic:masterfrom
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
| var filtered []kibana.Agent | ||
| for _, agent := range allAgents { | ||
| if agent.PolicyRevision == 0 { | ||
| continue // For some reason Kibana doesn't always return a valid policy revision (eventually it will be present and valid) |
There was a problem hiding this comment.
Not blocking this PR but it would be good to understand why this is happening and try to remove this condition in a follow up PR. @nchaulet maybe you can shed some light here?
There was a problem hiding this comment.
This is actually causing some flakiness for Kubernetes integration. I would be for leaving it here (to unblock our delivery pipeline), but it definitely needs an explanation.
There was a problem hiding this comment.
the policy revision is set when the agent is actually running the policy it's why it could be undefined when an agent enrolled or when reassigning an agent policy
There was a problem hiding this comment.
Is it by design or it just works this way? I'm concerned if it makes sense to have an agent with policy assigned, but no revision. Shouldn't it always be 1 on startup?
| func (c *Client) waitUntilPolicyAssigned(p Policy) error { | ||
| totalAgents, err := c.getTotalAgentForPolicy(p) | ||
| func (c *Client) getAgent(agentID string) (*Agent, error) { | ||
| statusCode, respBody, err := c.get(fmt.Sprintf("%s/agents/%s", FleetAPI, agentID)) |
There was a problem hiding this comment.
Does this API exist in older versions of Kibana? IOW, just wondering if this change is backwards compatible.
There was a problem hiding this comment.
I think it was already there, we just used a different API.
There was a problem hiding this comment.
I quickly tested this PR with 7.10.0 and it works. So we're good on backwards compatibility.
This PR modifies test runner to use different API methods to check agents which picked up latest policy revisions (kuery has been removed).
This is a workaround for elastic/kibana#94053 .