-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Ingest Manager] Fix for comparing versions with -SNAPSHOT suffix #80742
Changes from all commits
2f1197b
7a7dfb7
e4cf535
6f244ba
a2fefd3
aaf4e29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,4 +135,35 @@ describe('Ingest Manager - isAgentUpgradeable', () => { | |
true | ||
); | ||
}); | ||
it('returns false if agent reports upgradeable, with agent snapshot version === kibana version', () => { | ||
expect( | ||
isAgentUpgradeable(getAgent({ version: '7.9.0-SNAPSHOT', upgradeable: true }), '7.9.0') | ||
).toBe(false); | ||
}); | ||
it('returns false if agent reports upgradeable, with agent version === kibana snapshot version', () => { | ||
expect( | ||
isAgentUpgradeable(getAgent({ version: '7.9.0', upgradeable: true }), '7.9.0-SNAPSHOT') | ||
).toBe(false); | ||
}); | ||
it('returns true if agent reports upgradeable, with agent snapshot version < kibana snapshot version', () => { | ||
expect( | ||
isAgentUpgradeable( | ||
getAgent({ version: '7.9.0-SNAPSHOT', upgradeable: true }), | ||
'8.0.0-SNAPSHOT' | ||
) | ||
).toBe(true); | ||
}); | ||
it('returns false if agent reports upgradeable, with agent snapshot version === kibana snapshot version', () => { | ||
expect( | ||
isAgentUpgradeable( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm wondering whether this should be upgradable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the UI we only show upgradeable if the version is less than the kibana version, regardless of whether its a snapshot. Also the agent version should never have the '-SNAPSHOT' suffix in it (it does not currently), I just put it in case that were to change. It currently only reports the number in the metadata. If we want to make an exception where if an agent is a snapshot that the versions can be equal and still upgradeable, I would need to check the agent local metadata to see whether its a snapshot and consider it upgradeable when versions are the same. I am fine with doing that, but not sure how common this case would be. I'd rather add it as an enhancement in the next version. I am not sure this makes much sense to have at the moment because if we are always using whether or not Kibana is on a snapshot as the version, we shouldn't be checking whether or not the agent is on a snapshot. For example, agent is a snapshot but kibana is not, we check that Agent is a snapshot and let it upgrade even though its the same version as kibana, then we provide a stable version download url because kibana is not a snapshot, and so they do not even download the snapshot anyway. Unless we want to do a check that agent and kibana are both snapshots. |
||
getAgent({ version: '8.0.0-SNAPSHOT', upgradeable: true }), | ||
'8.0.0-SNAPSHOT' | ||
) | ||
).toBe(false); | ||
}); | ||
it('returns true if agent reports upgradeable, with agent version < kibana snapshot version', () => { | ||
expect( | ||
isAgentUpgradeable(getAgent({ version: '7.9.0', upgradeable: true }), '8.0.0-SNAPSHOT') | ||
).toBe(true); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,12 @@ export function isAgentUpgradeable(agent: Agent, kibanaVersion: string) { | |
return false; | ||
} | ||
if (agent.unenrollment_started_at || agent.unenrolled_at) return false; | ||
const kibanaVersionParsed = semver.parse(kibanaVersion); | ||
const agentVersionParsed = semver.parse(agentVersion); | ||
if (!agentVersionParsed || !kibanaVersionParsed) return false; | ||
if (!agent.local_metadata.elastic.agent.upgradeable) return false; | ||
return semver.lt(agentVersionParsed, kibanaVersionParsed); | ||
|
||
// make sure versions are only the number before comparison | ||
const agentVersionNumber = semver.coerce(agentVersion); | ||
if (!agentVersionNumber) throw new Error('agent version is invalid'); | ||
const kibanaVersionNumber = semver.coerce(kibanaVersion); | ||
if (!kibanaVersionNumber) throw new Error('kibana version is invalid'); | ||
return semver.lt(agentVersionNumber, kibanaVersionNumber); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: I think this is doing the same not sure which approach we should favorise https://github.com/elastic/kibana/blob/master/x-pack/plugins/ingest_manager/server/services/agents/checkin/state_new_actions.ts/#L127-L137 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nchaulet The thing that makes me a bit paranoid is |
||
} |
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 you also checking the option where agent reports
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.
Do you mean checking whether or not it is a snapshot? It does not test for snapshot because it does not matter if its a snapshot whether or not its upgradeable (unless we decide to filter out snapshots). But I can add the option anyway as part of the tests. Let me know if I am misunderstanding or mistaken with the logic.