-
Notifications
You must be signed in to change notification settings - Fork 452
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
Handle RPM upgrade in %postun script #14379
Conversation
relates to #14380 |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #14379 +/- ##
=======================================
Coverage 58.87% 58.87%
=======================================
Files 925 925
Lines 77319 77333 +14
Branches 2222 2222
=======================================
+ Hits 45521 45531 +10
- Misses 28186 28190 +4
Partials 3612 3612
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
orbit/pkg/packaging/linux_shared.go
Outdated
if [ "$1" = 0 ]; then | ||
rm -rf /var/lib/orbit /var/log/orbit /usr/local/bin/orbit /etc/default/orbit /usr/lib/systemd/system/orbit.service /opt/orbit | ||
fi |
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.
I'm not too familiar with this part of the code, can you point me to where this script is being called?
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.
@mostlikelee hey this is used as a template file for the RPM/DEB package post run script.
We use https://github.com/goreleaser/nfpm to create RPM/DEB installers of fleetd
so this is getting used during fleetctl package -type=rpm
This particular script is executed during the %postun
phase of a RPM upgrade/uninstall.
The problem here is that when upgrading, I think the %postun
phase is executed and will remove the binary files. This conditional checks to see if we are actually doing a real uninstall before removing the files.
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 that! do we need to change where this script is called to pass the new argument, or is that handled natively by the installer?
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.
The system package manager is handling passing the args, yum, rpm, etc.
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.
LGTM!
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.
@mostlikelee I added some details in the issue #14380
Have we checked that with |
What binaries were needed for the upgrade? The new package should have all binaries that it needs. Maybe I'm missing some scenario. |
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.
Left a few questions
All of them. The script is run on upgrade and all of the binaries listed in the script are removed. |
I tested RPM but still need to test DEB. |
Gotcha, but why is that an issue? |
OK, let me know if you need a hand (I have an Ubuntu VM.) |
Because it runs as the final step of the upgrade, thus removing the files it just got finished upgrading. When the service attempts to start, the files don't exist. |
Oh! I missed the fact that this is the "post" part. Thanks for the clarification. |
@edwardsb Do you need a hand getting this tested for deb? |
Yes please |
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.
91a3b13
to
b946591
Compare
…n during RPM upgrade. The check ensures that files and directories are only removed during a full uninstall ( equals 0), safeguarding necessary files from unintended deletion during an upgrade.
📝 docs(linux_shared.go): add comments to clarify the difference between RPM and Debian uninstallation conditions
b946591
to
916e2e5
Compare
@lucasmrod when you have a moment can you retest on debian? |
Works now! (Haven't tested with I've tested the following on Ubuntu 22.04:
On my CentOS 7:
|
This pull request addresses a key aspect of the RPM upgrade process - handling of scripts during upgrades vice pure deletion events.
An RPM upgrade operation consists of both an Install and an Uninstall operation, meaning that during an upgrade, our %postun script is run and previously, it was causing the accidental deletion of binaries needed for the upgrade.
To prevent this unwanted removal during upgrade scenarios, the %postun script now checks for the execution scenario in which it finds itself.
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/
ororbit/changes/
.See Changes files for more information.