-
Notifications
You must be signed in to change notification settings - Fork 154
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
Always launch more recent watcher #4491
Always launch more recent watcher #4491
Conversation
This pull request does not have a backport label. Could you fix it @pchila? 🙏
NOTE: |
7de5860
to
b7bfbb2
Compare
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
switch major { | ||
case 8: | ||
return NewParsedSemVer(7, 17, 10, psv.Prerelease(), psv.BuildMetadata()), nil | ||
for i := 0; i < minPrereleaseTokens; i++ { |
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.
What problem is this solving? Do we need this code to handle something in our current or planned release versioning scheme or is it just in case?
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.
This is the correct implementation for comparing 2 semver version strings. Prerelease strings should be compared token by token as strings or numbers depending on their format.
Right now we only use "SNAPSHOT" prerelease string and the previous impl would just compare 2 versions based on the presence of prerelease string without comparing those, leading to versions like
1.2.3-SNAPSHOT
, 1.2.3-alpha
, 1.2.3-SNAPHOT.extraprereleasetoken
not to have an definite order.
This new implementation is able to parse the tokens and correctly determine precedence based on the prerelease token: an example when this is gonna come into play is of we decide to use repackaged agents in upgrade tests as 1.2.3-SNAPSHOT.repackaged
now has a defined order when compared with 1.2.3-SNAPSHOT
This is a part of a general overhaul of agent version handling correct versioning both at packaging and runtime which I then extracted to put in a separate PR as it would make this change too big.
Edit: this is the other PR's commit containing the rest of changes 863a638
func selectWatcherExecutable(topDir string, previous agentInstall, current agentInstall) string { | ||
// check if the upgraded version is less than the previous (currently installed) version | ||
if current.parsedVersion.Less(*previous.parsedVersion) { | ||
// use the current agent executable for watch, if downgrading the old agent doesn't understand the current agent's path structure. |
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.
comment says use the current as currently installed but it's not current as a variable name. it gets confusing
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.
Agreed but this is the existing names that follow where the symlink points.
So after rotating the symlink the currently running agent is named previous and the new one is named current.
I don't know if this is more confusing or swapping the variable names so when we look at it in different places in the code it gets confusing...
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.
can we maybe rephrase
use the current agent executable for watch, if downgrading the old agent doesn't understand the current agent's path structure.
to
if downgrading the target agent may not understand the current agent's path structure.
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.
Really don't like the hard-coding of 8.13.0.
changelog/fragments/1712737337-always-launch-more-recent-watcher.yaml
Outdated
Show resolved
Hide resolved
changelog/fragments/1712737337-always-launch-more-recent-watcher.yaml
Outdated
Show resolved
Hide resolved
@blakerouse If you want I can change that fallback to always run the newly installed agent watcher (dangerous for downgrade) or stop the upgrade process at this point and roll back everything... |
ece5816
to
c3821e7
Compare
Removed |
Co-authored-by: Blake Rouse <[email protected]>
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.
Thanks for the fixes.
Like this implement of the pressed version string much better.
buildkite test this |
|
What does this PR do?
This PR changes the way elastic-agent launches the upgrade watcher in the final phases of the upgrade process.
Before this change, the elastic-agent binary from the incoming version (the one specified in the
upgrade
command) was always used but this meant that during a downgrade an older version of elastic agent would be launched, potentially not supporting new fields in the upgrade marker generated during the upgrade.Now the agent will check the current and incoming version and always select the newer one to launch the watcher process: during a downgrade this means that the current agent binary will function as a watcher to check that the incoming version functions correctly after the restart.
Why is it important?
We want to avoid issues during watch/cleanup/rollback phases of upgrades even if the incoming version is older than the current install.
Checklist
./changelog/fragments
using the changelog toolAuthor's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs
Questions to ask yourself