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

Validating policy ID only when running in Fleet mode for Elastic Agent #6938

Merged
merged 2 commits into from
Jun 22, 2023

Conversation

kvalliyurnatt
Copy link
Contributor

The Agent webhook attempts to check if PolicyID is set whether or not the Agent is running in fleet or standalone mode, This check should only be done in fleet mode. Fixes #6903

@kvalliyurnatt kvalliyurnatt added >bug Something isn't working v2.9.0 labels Jun 21, 2023
@@ -38,7 +38,7 @@ func (a *Agent) GetWarnings() []string {
if a == nil {
return nil
}
if len(a.Spec.PolicyID) == 0 {
if a.Spec.Mode == AgentFleetMode && len(a.Spec.PolicyID) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change makes perfect sense, but I also think it's a perfect opportunity for a set of unit tests around this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are existing unit tests, will fix those and add a new one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only looking for a webhooks_test.go file and didn't see it. My apologies.

Copy link
Contributor

@barkbay barkbay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kvalliyurnatt kvalliyurnatt marked this pull request as ready for review June 22, 2023 13:23
Copy link
Contributor

@naemono naemono left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also lgtm now

@pebrc pebrc changed the title validating policy id only when running in fleet mode for elastic agent Validating policy ID only when running in fleet mode for Elastic Agent Jun 22, 2023
@kvalliyurnatt kvalliyurnatt merged commit e96992a into elastic:main Jun 22, 2023
@kvalliyurnatt kvalliyurnatt deleted the fix-policyid-warning branch June 22, 2023 18:27
@thbkrkr thbkrkr changed the title Validating policy ID only when running in fleet mode for Elastic Agent Validating policy ID only when running in Fleet mode for Elastic Agent Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working v2.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent: "spec.PolicyID is empty" warning is raised despite Agent is running in standalone mode
3 participants