Fix(agent): Improve tunnel preservation during agent upgrade when using tunnel. Housekeeping of shellhub-agent files in own directory - #5943
Conversation
fbab19e to
a7beeba
Compare
a7beeba to
1e42d5b
Compare
1e42d5b to
50f40b7
Compare
otavio
left a comment
There was a problem hiding this comment.
The biggest problem I foresee here is migrating the field-deployed agents.
So even though I agree with the idea of this change, we need to consider how we will migrate the existing agents to work with this new approach or provide a backward-compatible way for them to keep working.
How do you foresee solving this issue?
|
With all the testing. I've stumbled upon this myself. The only persistent remaining file is just Two methods for transition:
@otavio someone should be able to replicate my findings for confirmation. EDIT: |
|
@otavio You are correct that users using the tunnel to upgrade their agent will have their tunnel ceremoniously terminated when migrating from the runc binary to go-native binary. I tried sending the shell install script to background and including using nohup to ignore sighup. However still no luck as the child process executing the agent install did not appear to initiate. This observation was the same for an standalone agent upgrade made through the tunnel for the following situations
With all tunnels terminated when users used shellhub tunnel to upgrade the agent |
|
Found a work around, can someone review please and test the containerised installation/upgrade. Problem: Running the installation under systemd-run worked, but once again was not verbose, and increased complexity in managing the existing service once finished. Solution: Changes: |
ad7c9d8 to
0d222f4
Compare
88ffb2d to
0d222f4
Compare
0d222f4 to
0d6ec33
Compare
@otavio I noticed that the migration from non native shellhub-agent to the go-native shellhub-agent triggers the same issue of a new pending device join request due to the change in location of shellhub.key from I have provided a migration path for users who don't wish to deal with just removing old device and re-accepting the new device above. By moving the shellhub-agent service restart to end of installation, this allows users to upgrade the agent over a shellhub tunnel as the tunnel is not terminated when the service is stopped at the start of the installation process. |
0d6ec33 to
35b4a99
Compare
35b4a99 to
5148282
Compare
5148282 to
ae06a1d
Compare
|
/review |
|
@ltan10 You are not authorized to request an explicit review. If you believe this PR needs a new automated review round, please tag the |
|
@shellhub-io/admin |
|
/review |
|
Claude finished @otavio's task in 23s —— View job Code Review CompleteReviewed 3 files across code quality, security, testing, Go patterns, and architecture — no issues found. The code looks good as-is. Review notes:
If you've addressed feedback and want a new review, tag |
ae06a1d to
6d88f23
Compare
|
Rebased branch. Proposed change completed. @otavio any chance PR to be merged for next release? |
6d88f23 to
772ff28
Compare
|
@ltan10 There is still a conflict that needs to be resolved. Can you take a look? Besides this, I am wondering what tests of the upgrade you have done? |
772ff28 to
6ec1a39
Compare
|
@otavio rebased to the master branch to resolve the conflicts. I've also updated the comments to make more sense. As for the testing, I have only performed the For an upgrade context, I have tested the upgrade over an active remote ShellHub SSH tunnel multiple times, and was successful each of those times. However like with every remote configuration there is a chance that it may fail. Every upgrade for runc-agent and go-agent always rewrites it's shellhub-agent.env as is normal behavior. Observations for the tests are mentioned in previous comments. I'll try to summarize them here. When upgrading from the runc-agent to "ungrouped" go-agent or "ungrouped" go-agent to this "grouped" version, the existing private key is not migrated. As a result, the new agent will generate a new key, and the device will be treated as a new device registration and await acceptance on the dashboard. Subsequently any existing A migration guide is included in the PR description with steps to preserve the existing key and avoid re-registration. I have NOT tested the |
fe93e24 to
ea1a9bd
Compare
Create directory if doesn't exist.
agent installer: avoid service disruption during upgrade over SSH tunnel - Remove pre-install service disable step - Enable service without starting it - Restart service after installation completes This allows upgrades over an active SSH tunnel while ensuring the service restarts with the updated binary and re-establishes the tunnel.
6ec1a39 to
d5427ac
Compare
What kind of change does this PR introduce?
Description:
/etc/shellhub-agent//etc/shellhub.keyand/etc/shellhub-agent.envor/opt/shellhub/shellhub.keyto/etc/shellhub-agent/shellhub.keyprior to performing installation/upgrade/etc/shellhub-agentMigration Guide *Optional*
The following guide also applies when migrating from
runc-shellhub-agentto the nativego-shellhub-agent.The following steps are only needed if you want to retain the same device unique ID in ShellHub and avoid creating a new pending request.
If the migration steps are not performed, the device will be registered as a new device, and the pending request will need to be accepted.
/etc/shellhub-agent/directoryshellhub.keyfrom/opt/shellhub-agent/shelhlub.keyor/etc/shellhub.keyto/etc/shellhub-agent/shellhub.key/opt/shellhub-agent/and/etc/shellhub.keyand/etc/shellhub-agent.env