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

[ Fleet ] Fleet UI should allow upgrades to agents where the patch version is higher than Kibana #168502

Closed
leandrojmp opened this issue Oct 10, 2023 · 16 comments · Fixed by #173167
Assignees
Labels
QA:Validated Issue has been validated by QA Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@leandrojmp
Copy link

leandrojmp commented Oct 10, 2023

Describe the feature:

Currently if you are on version X.Y.0 and want to upgrade an Elastic Agent to version X.Y.1, you can't do this through Fleet UI because the upgrade option will be grayed out, this means that the Elastic Agent version you can upgrade through Fleet UI is pinned to the patch version of Kibana.

The product compatibility does not mention this, it says for example that Elasticsearch 8.10.X is compatible with Elastic Agent 7.17.X - 8.10.X, so an User would expect to be able to run an Elastic Agent 8.10.3 even if the rest of the stack is on a lower patch version.

Kibana documentation mentions that generally Kibana is compatible with Elasticsearch on different patch versions, but does not mention if Kibana patch can be higher than Elastisearch patch, it also recommends to run the exact same version.

So if an user wants to follow this recommendation and needs to upgrade just a couple of agents to fix some issue, it would need to upgrade the entire stack, which is far from the ideal.

The solution in this case would be to manually upgrade an agent, which is also not ideal when you have many agents.

If the Elastic Agent needs to be so tight coupled with the Kibana version, then this needs to be reflected in the Support Matrix page.

Describe a specific use case for the feature:

Users should be able to upgrade the patch version of an Elastic Agent through the Fleet UI, this may happen when you need to upgrade for just fix a bug.

@botelastic botelastic bot added the needs-team Issues missing a team label label Oct 10, 2023
@jsanz jsanz added the Team:Fleet Team label for Observability Data Collection Fleet team label Oct 13, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Oct 13, 2023
@rodrigc
Copy link
Contributor

rodrigc commented Oct 21, 2023

@juliaElastic
Copy link
Contributor

I think the reason we don't allow this is laying on the agent side, @cmacknz correct me if I'm wrong. I tried to find the recent gh comments about this, but couldn't.

@lucabelluccini
Copy link
Contributor

Just a comment about what we say in the docs.

For Elastic Agents there's a constraint on Fleet Server (docs)

The version of Elastic Agents running Fleet Server must be greater than or equal to the version of the Elastic Agents that enroll in them.

Here, we do not mention the patch version.

Meaning the Fleet Server version >= Elastic Agents. Usually Fleet Server is aligned with the stack.

On our doc we have also:

For version compatibility: Elasticsearch >= Fleet Server >= Elastic Agent (except for bugfix releases).
Kibana should be on the same minor version as Elasticsearch.

So we always mention minor version but not the patch.

@rodrigc
Copy link
Contributor

rodrigc commented Oct 23, 2023

@juliaElastic In this post: https://discuss.elastic.co/t/elastic-agent-upgrade-option-is-grayed-out-on-fleet-server/344753/5?u=craig_rodrigues
@leandrojmp mentioned that it is possible to upgrade from the command-line to elastic-agent 8.10.4 against a Kibana 8.10.2 server. But the Fleet UI does not allow this.

So this restriction/bug is in the Fleet UI.

@leandrojmp
Copy link
Author

So we always mention minor version but not the patch.

@lucabelluccini The support matrix page also does not mention anything about the patch version, normally the compatibility is mentioned up to the minor version, like 8.10.X

So based on the documentation available, the user will assume that an agent on version 8.10.4 is compatible with the stack running on version 8.10.2, but currently the patch version is pinned on Kibana version.

The use case for having an Agent on a patch version higher than the rest of the stack would be to fix some bugs, like a recent one that broke some networking monitoring on Linux systems and was fixed on 8.10.3.

It is pretty common for on-premises deployments to have maintenance windows to upgrade the stack, and this cannot be done for every patch version, for example 8.10.3 was released on October 10th and 8.10.4 was released on October 17th, just one week late, but upgrading agents is easier than upgrading the entire stack, so it would be nice to be able to upgrade the agents through Fleet UI.

Upgrading the agent using the command line works without any issue, but this is not practical when you have hundreds or thousands of agents.

So based on this I think that the Kibana Fleet UI should allow the upgrade to agents on a higher patch version, if this is not possible then the documentation should reflect it and at least provide some orientation to the user on how to proceed with manual upgrades.

@lucabelluccini
Copy link
Contributor

I'm not against your assessment. I was just collecting/gathering what we report in the documentation.

@cmacknz
Copy link
Member

cmacknz commented Oct 23, 2023

There is a version constraint in Fleet Server that will not accept agents with a higher minor or major version. It is explicitly allowing agents in the same minor release to connect regardless of the patch version. So the intent is to allow what is described here at the Fleet Server level.

https://github.com/elastic/fleet-server/blob/d591423a489d45c383f8c2b32c4211fe9046a3cf/internal/pkg/api/verConst.go#L17-L24

func BuildVersionConstraint(verStr string) (version.Constraints, error) {
	ver, err := version.NewVersion(verStr)
	if err != nil {
		return nil, err
	}
	verStr = maximizePatch(ver)
	return version.NewConstraint(fmt.Sprintf(">= %s, <= %s", MinVersion, verStr))
}

The agent doesn't enforce any version restrictions itself, it simply reports its current version to Fleet Server and acts on the response it receives.

@rodrigc
Copy link
Contributor

rodrigc commented Oct 23, 2023

What logic does the Kibana UI use for greying out the available upgrade?

I tried looking at the code in:

but didn't have time to follow it all

@rodrigc
Copy link
Contributor

rodrigc commented Oct 23, 2023

Maybe this line in Kibana is kicking out availalbe versions where MAJOR and MINOR are the same, but PATCH is different:

return semverLt(version, kibanaVersion);

          agentVersionToUse =
            availableVersions.find((version) => {
              return semverLt(version, kibanaVersion);
            }) || availableVersions[0];

@juliaElastic
Copy link
Contributor

juliaElastic commented Oct 24, 2023

I see your point, I think we can then easily change this logic in Fleet UI to allow upgrading agents to the latest patch on the same major.minor as kibana.

@juliaElastic
Copy link
Contributor

@kpollich @jen-huang Could we add this to next sprint? It's a quick fix.

@kpollich
Copy link
Member

Added to sprint 20

@joshdover
Copy link
Contributor

While we're fixing this, it would be nice to just go ahead and add support for the upcoming "build releases" to Fleet UI / API at the same time. They will have the version suffix that will match this regex \+build[0-9]+$. For example, 8.11.0+build123456789. Fleet should allow this in the validation and retain the full version number when sending to Fleet Server in the action document, similar to how we handle -SNAPSHOT versions now.

@kpollich kpollich added the QA:Needs Validation Issue needs to be validated by QA label Nov 8, 2023
juliaElastic added a commit that referenced this issue Dec 13, 2023
…173167)

## Summary

Closes #168502

Changed the version check to allow agent upgrade if the agent version
has a newer patch than kibana.

To verify:
- change kibana locally to return a mock version `8.11.0`
[here](https://github.com/elastic/kibana/blob/05bfe53cb3a2fe33ecb9eec4a6fcb19a492aaadf/x-pack/plugins/fleet/public/hooks/use_kibana_version.ts#L17)
- enroll an agent version 8.11.0
- verify that the upgrade is allowed to 8.11.1 and 8.11.2
- verify that the upgrade works

<img width="1282" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/0bb0c8ca-ac0f-49c1-b67c-b02d085e7045">
<img width="799" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/7be3b64b-43e5-451a-a630-65cfc2607dab">
<img width="1256" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/4841bc2a-5238-4854-a63e-27761a02f1e3">

Tested the new agent build version by adding a dummy version to the
available_versions API response.
It is showing up for an agent 8.11.1 (same as the mock kibana version):
<img width="775" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/fa02c62d-9399-4c2c-8311-412e5fe03a96">



### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Dec 13, 2023
…lastic#173167)

## Summary

Closes elastic#168502

Changed the version check to allow agent upgrade if the agent version
has a newer patch than kibana.

To verify:
- change kibana locally to return a mock version `8.11.0`
[here](https://github.com/elastic/kibana/blob/05bfe53cb3a2fe33ecb9eec4a6fcb19a492aaadf/x-pack/plugins/fleet/public/hooks/use_kibana_version.ts#L17)
- enroll an agent version 8.11.0
- verify that the upgrade is allowed to 8.11.1 and 8.11.2
- verify that the upgrade works

<img width="1282" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/0bb0c8ca-ac0f-49c1-b67c-b02d085e7045">
<img width="799" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/7be3b64b-43e5-451a-a630-65cfc2607dab">
<img width="1256" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/4841bc2a-5238-4854-a63e-27761a02f1e3">

Tested the new agent build version by adding a dummy version to the
available_versions API response.
It is showing up for an agent 8.11.1 (same as the mock kibana version):
<img width="775" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/fa02c62d-9399-4c2c-8311-412e5fe03a96">

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit a26eec4)
kibanamachine referenced this issue Dec 13, 2023
…ibana (#173167) (#173296)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Fleet] allow agent upgrades if patch version is higher than kibana
(#173167)](#173167)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Bardi","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-12-13T16:00:20Z","message":"[Fleet]
allow agent upgrades if patch version is higher than kibana
(#173167)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/168502\r\n\r\nChanged the
version check to allow agent upgrade if the agent version\r\nhas a newer
patch than kibana.\r\n\r\nTo verify:\r\n- change kibana locally to
return a mock version
`8.11.0`\r\n[here](https://github.com/elastic/kibana/blob/05bfe53cb3a2fe33ecb9eec4a6fcb19a492aaadf/x-pack/plugins/fleet/public/hooks/use_kibana_version.ts#L17)\r\n-
enroll an agent version 8.11.0\r\n- verify that the upgrade is allowed
to 8.11.1 and 8.11.2\r\n- verify that the upgrade works\r\n\r\n<img
width=\"1282\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/0bb0c8ca-ac0f-49c1-b67c-b02d085e7045\">\r\n<img
width=\"799\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7be3b64b-43e5-451a-a630-65cfc2607dab\">\r\n<img
width=\"1256\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/4841bc2a-5238-4854-a63e-27761a02f1e3\">\r\n\r\nTested
the new agent build version by adding a dummy version to
the\r\navailable_versions API response.\r\nIt is showing up for an agent
8.11.1 (same as the mock kibana version):\r\n<img width=\"775\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/fa02c62d-9399-4c2c-8311-412e5fe03a96\">\r\n\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"a26eec451fb54317a2b08d1f49b3f2b30fcbddca","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","v8.12.0","v8.13.0"],"number":173167,"url":"https://github.com/elastic/kibana/pull/173167","mergeCommit":{"message":"[Fleet]
allow agent upgrades if patch version is higher than kibana
(#173167)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/168502\r\n\r\nChanged the
version check to allow agent upgrade if the agent version\r\nhas a newer
patch than kibana.\r\n\r\nTo verify:\r\n- change kibana locally to
return a mock version
`8.11.0`\r\n[here](https://github.com/elastic/kibana/blob/05bfe53cb3a2fe33ecb9eec4a6fcb19a492aaadf/x-pack/plugins/fleet/public/hooks/use_kibana_version.ts#L17)\r\n-
enroll an agent version 8.11.0\r\n- verify that the upgrade is allowed
to 8.11.1 and 8.11.2\r\n- verify that the upgrade works\r\n\r\n<img
width=\"1282\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/0bb0c8ca-ac0f-49c1-b67c-b02d085e7045\">\r\n<img
width=\"799\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7be3b64b-43e5-451a-a630-65cfc2607dab\">\r\n<img
width=\"1256\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/4841bc2a-5238-4854-a63e-27761a02f1e3\">\r\n\r\nTested
the new agent build version by adding a dummy version to
the\r\navailable_versions API response.\r\nIt is showing up for an agent
8.11.1 (same as the mock kibana version):\r\n<img width=\"775\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/fa02c62d-9399-4c2c-8311-412e5fe03a96\">\r\n\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"a26eec451fb54317a2b08d1f49b3f2b30fcbddca"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173167","number":173167,"mergeCommit":{"message":"[Fleet]
allow agent upgrades if patch version is higher than kibana
(#173167)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/168502\r\n\r\nChanged the
version check to allow agent upgrade if the agent version\r\nhas a newer
patch than kibana.\r\n\r\nTo verify:\r\n- change kibana locally to
return a mock version
`8.11.0`\r\n[here](https://github.com/elastic/kibana/blob/05bfe53cb3a2fe33ecb9eec4a6fcb19a492aaadf/x-pack/plugins/fleet/public/hooks/use_kibana_version.ts#L17)\r\n-
enroll an agent version 8.11.0\r\n- verify that the upgrade is allowed
to 8.11.1 and 8.11.2\r\n- verify that the upgrade works\r\n\r\n<img
width=\"1282\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/0bb0c8ca-ac0f-49c1-b67c-b02d085e7045\">\r\n<img
width=\"799\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7be3b64b-43e5-451a-a630-65cfc2607dab\">\r\n<img
width=\"1256\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/4841bc2a-5238-4854-a63e-27761a02f1e3\">\r\n\r\nTested
the new agent build version by adding a dummy version to
the\r\navailable_versions API response.\r\nIt is showing up for an agent
8.11.1 (same as the mock kibana version):\r\n<img width=\"775\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/fa02c62d-9399-4c2c-8311-412e5fe03a96\">\r\n\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"a26eec451fb54317a2b08d1f49b3f2b30fcbddca"}}]}]
BACKPORT-->

Co-authored-by: Julia Bardi <[email protected]>
juliaElastic added a commit that referenced this issue Jan 29, 2024
…175775)

## Summary

Adding the fix in #175765 to main
too.

To verify:
- add a fleet-server version 8.12.0
- enroll an agent version 8.12.0-SNAPSHOT
- take the agent id and in console run this API request
```
POST kbn:/api/fleet/agents/6a56f865-a611-4921-9f24-87757259223e/upgrade
  {
    "version": "8.12.1-SNAPSHOT"
  }
```
- verify that the API returns 200 

Relates #168502
juliaElastic added a commit that referenced this issue Jan 29, 2024
… version differs only in patch (#175765)

Fixes #175766

[8.12][Fleet] Partial backport of
#175198

To verify:
- add a fleet-server version 8.12.0
- enroll an agent version 8.12.0-SNAPSHOT
- take the agent id and in console run this API request
```
POST kbn:/api/fleet/agents/6a56f865-a611-4921-9f24-87757259223e/upgrade
  {
    "version": "8.12.1-SNAPSHOT"
  }
```
- verify that the API returns 200 

Relates #168502
@harshitgupta-qasource
Copy link

Hi Team,

We have created 03 testcases under testrail for this feature under Fleet test suite at links:

Please let us know if any other scenario needs to be added from our end.

Thanks!

CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this issue Feb 15, 2024
…lastic#175775)

## Summary

Adding the fix in elastic#175765 to main
too.

To verify:
- add a fleet-server version 8.12.0
- enroll an agent version 8.12.0-SNAPSHOT
- take the agent id and in console run this API request
```
POST kbn:/api/fleet/agents/6a56f865-a611-4921-9f24-87757259223e/upgrade
  {
    "version": "8.12.1-SNAPSHOT"
  }
```
- verify that the API returns 200 

Relates elastic#168502
@harshitgupta-qasource
Copy link

Hi Team,

We have executed 03 testcases under the Feature test run for the 8.12.1 release at the link:

Status:

  • PASS: 03

Build details:
VERSION: 8.12.1
BUILD: 70228
COMMIT: 3457f32

As the testing is completed on this feature, we are marking this as QA:Validated.
Please let us know if anything else is required from our end.

Thanks

@harshitgupta-qasource harshitgupta-qasource added QA:Validated Issue has been validated by QA and removed QA:Needs Validation Issue needs to be validated by QA labels Feb 21, 2024
fkanout pushed a commit to fkanout/kibana that referenced this issue Mar 4, 2024
…lastic#175775)

## Summary

Adding the fix in elastic#175765 to main
too.

To verify:
- add a fleet-server version 8.12.0
- enroll an agent version 8.12.0-SNAPSHOT
- take the agent id and in console run this API request
```
POST kbn:/api/fleet/agents/6a56f865-a611-4921-9f24-87757259223e/upgrade
  {
    "version": "8.12.1-SNAPSHOT"
  }
```
- verify that the API returns 200 

Relates elastic#168502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA:Validated Issue has been validated by QA Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants