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

Clean up old habitat packages on upgrade #6635

Open
btm opened this issue Jan 27, 2022 · 2 comments
Open

Clean up old habitat packages on upgrade #6635

btm opened this issue Jan 27, 2022 · 2 comments

Comments

@btm
Copy link
Contributor

btm commented Jan 27, 2022

When Automate is upgraded and dependencies are upgraded, additional copies of the dependencies may be left behind. As these dependencies age, they may be detected by customers vulnerabilities scanners and cause additional reporting and remediation work for the customer. We should clean up unused old packages from disk.

Keep in mind that automate prevents other services from running in it's habitat supervisor, but that a system may have a separate habitat supervisor running using the same /hab filesystem. See #455 and #2478.

hab pkg uninstall does have a --keep-latest n flag that keeps at least n copies of a package, and won't uninstall packages that are dependencies of others. Something like this works, but don't do this:

# don't do this
INSTALLED_PACKAGES=$(hab pkg list -a | awk -F/ '{print $1 "/" $2 }' | uniq)
for p in $INSTALLED_PACKAGES
do
  sudo hab pkg uninstall $p --keep-latest 1
done
@btm
Copy link
Contributor Author

btm commented Jan 28, 2022

Example of customer communications for manual cleanup: https://github.com/chef/customer-bugs/issues/566#issuecomment-1023675551

@stevendanna
Copy link
Contributor

This popped up in my github notifications for some reason and since I'm here, I thought I would mention that changing

c.V1.Svc.PackageCleanupMode = w.String("conservative")
to "aggressive" might get you what you want.
// AggressiveCollect deletes all habitat packages except those that are listed
// in the roots list or are transitive dependencies of those packages. This can
// result in deletion of packages that have been intentionally installed by the
// user, as there is no way to differentiate packages installed by the
// deployment service but are no longer used from those installed by the user.
func (gc *GarbageCollector) AggressiveCollect(roots []habpkg.HabPkg) error {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants