-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Detect and fail early if user attempts to upgrade Agent using the CLI in unsupported scenarios #4890
Comments
cc: @ycombinator @cmacknz |
Upgrading Fleet managed agents from the cli isn't supported. We should detect this and fail earlier before attempting the upgrade. |
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
++ renamed issue title accordingly. |
What's the reason for not supporting CLI upgrades? I have agents that can't reach the web but are reachable by SSH, so I can push the package to them and upgrade through Ansible, which works quite well. Setting up an artifact repo is also not an option, as I don't control what those agents have access to. EDIT: or at least Kibana should allow |
This is only for Fleet managed agents, who expect to be told to upgrade from the Fleet UI and not the CLI today. The specific error in the issue is that the agent reports its progress through the upgrade back to Fleet and if the upgrade wasn't started from the UI Fleet considers it an error since the upgrade is unexpected. I think there are some situations where initiating upgrades of Fleet managed agents from the CLI is useful, but we'd have to fix this error for this to work properly. Also with unprivileged agents where users who are not root/admin can potentially use the CLI, forbidding upgrades from the CLI is a way to prevent upgrades outside of Fleet's control from occurring which is probably desirable to many people. We'd have to consider this too if we change approaches here. |
elastic/fleet-server#3991 will remove the 500 error when this happens. I am a little bit hesitant to just forbid running We could add a log that it's unsupported with a confirmation to proceed anyway to clarify expectations though. |
I was discussing this issue with @kaanyalti 1-1 and one thought I had was: what if we have Agent call the Fleet API for upgrading the Agent if we detect that the Agent is Fleet-managed and the user has tried to initiate an upgrade using the CLI? That way, we're essentially internally "rerouting" the upgrade flow to start from the correct place, Fleet, even though the user didn't do so. Thoughts @cmacknz? |
A problem with that, and with "Person who has access to agent in terminal" and "Person whose role allows management of agents in Fleet" are not necessarily the same. This is even worse for unprivileged agents because we don't require upgrades to be done by a privileged user (you don't need to be root to run I have been hesitant to just ban use of |
See also: A standalone agent can't mark certain versions as forbidden but Fleet could. |
Thanks @cmacknz, good point about the CLI upgrade path circumventing Fleet RBAC restrictions. Makes sense, then, to go with the approach you proposed in #4890 (comment). |
@cmacknz I understand wanting some backdoor way of issuing an upgrade. Could we go the log/warning route and say "Fleet Managed agents can not be upgraded from the command line. Please Fleet to upgrade the agent" Also could we utilize the "--force" flag to by pass this as the backdoor option? we can just place that option in the docs. |
So there are two UX options being proposed here. We should decide which one we want to go with so we can start implementing the solution. Option 1Present the user with a prompt saying this Agent is Fleet-managed and should be upgraded from Fleet + asking them if they're sure they want to proceed anyway?
Option 2Output that this Agent is Fleet-managed and should not be upgraded from the command line.
@cmacknz @nimarezainia which option do you prefer? |
I would prefer For containers, RPM, and DEB packages the The |
Thanks @cmacknz. @kaanyalti I've created a Definition of Done section in this issue's description to cover all the cases that @cmacknz mentioned in the previous comment. I've also updated this issue's title and sprint size estimate to reflect the expanded scope. This issue is now ready to be worked on. |
@ycombinator thanks for the detailed Definition, regarding this last one:
This option should only be available for the privileged user. |
Thanks for catching that, @nimarezainia. I updated and reordered the checklist in Definition of Done so hopefully it makes more sense now. |
For the DEB, RPM, and container use cases I think those are covered by #5832, in particular there is agreement around the solution in #5832 (comment). Maybe that issue should come before this one, which has more to do with cases where we don't forbid upgrades for the current package type completely. |
Version: 8.14.0
Operating System: Ubuntu 24.04 LTS
Platform: arm64
While working on this issue comparing root and unprivileged elastic agents, I encountered an error when upgrading the agent.
Steps to Reproduce:
sudo ./elastic-agent install --url=<fleet url> --enrollment-token=<token>
sudo elastic-agent upgrade 8.14.0
This bug occurs for both privileged and unprivileged agents.
Definition of Done
Synthesized from #4890 (comment):
isAdmin
check incmd/install.go
).elastic-agent upgrade ...
), Agent should refuse to upgrade and output a message explaining why. The message should NOT mention anything about a--force
flag (explained below).--force
flag in the previous scenario, Agent should present a warning message and proceed with the upgrade anyway. This--force
flag should be hidden; it should NOT show up in the output ofelastic-agent help upgrade
.The text was updated successfully, but these errors were encountered: