-
Notifications
You must be signed in to change notification settings - Fork 83
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
Ensure that the connecting Elastic Agent is a supported version. #239
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of nits, otherwise lgtm
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: should we validate after the metric that counts checkin calls?
@scunningham what was the purpose of the counter? should it include all checkin calls or just authenticated and validated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I put it before the metric in both check-in and enroll. Can change in follow up if needed.
@@ -79,6 +81,7 @@ type CheckinT struct { | |||
} | |||
|
|||
func NewCheckinT( | |||
verCon version.Constraints, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we always going to have the version constraint?
if not not then make it option function?
nit: the number of params in the constructor "is too darn high" :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we should always have it
cmd/fleet/userAgent.go
Outdated
if len(segments) > 2 { | ||
segments = segments[:2] | ||
} | ||
segments = append(segments, int(^uint(0)>>1)) // max int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
math.MaxInt32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know about it, will change to that
cmd/fleet/userAgent.go
Outdated
return ErrInvalidUserAgent | ||
} | ||
userAgent = strings.ToLower(userAgent) | ||
if !strings.HasPrefix(userAgent, "elastic agent ") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const prefix = "elastic agent "
?
could be local to func
cause it is used in two places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
* Ensure that the connecting Elastic Agent is a supported version. * Revert change to fleet-server.yml * Fix added space in fleet-server.yml. * Fixes from code review. * Update go.mod. (cherry picked from commit 91af65a)
… (#242) * Ensure that the connecting Elastic Agent is a supported version. * Revert change to fleet-server.yml * Fix added space in fleet-server.yml. * Fixes from code review. * Update go.mod. (cherry picked from commit 91af65a) Co-authored-by: Blake Rouse <[email protected]>
What does this PR do?
Adds checks to the enrollment and checkin API to ensure that the
User-Agent
header is correct for an Elastic Agent. This verifies that the version of the Elastic Agent is a support version.This does allow an Elastic Agent to be on a higher patched version than the Fleet Server, but not higher on the MAJOR.MINOR.
Why is it important?
Older Elastic Agents will not work correctly with new Fleet Server, so they need to not connect to the Fleet Server.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues