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

this makes sure binaries are not deleted #2025

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ func (u *Upgrader) ensureRestarted(service ...string) error {

// UninstallBinary from a single flist.
func (u *Upgrader) UninstallBinary(flist FListInfo) error {
return u.uninstall(flist)
// we never delete those files from the system
// since there is no `package manager` for zos (yet)
// deleting the files from the flist blindly can cause
// issues if some deleted files were shared between
// multiple packages.
return u.uninstall(flist, false)
}

// upgradeSelf will try to check if the flist has
Expand Down Expand Up @@ -284,7 +289,9 @@ func (u *Upgrader) upgradeSelf(store meta.Walker) error {
return ErrRestartNeeded
}

func (u *Upgrader) uninstall(flist FListInfo) error {
// uninstall a package, if del is true, also delete the files in that package
// from the system filesystem
func (u *Upgrader) uninstall(flist FListInfo, del bool) error {
files, err := flist.Files()
if err != nil {
return errors.Wrapf(err, "failed to get list of current installed files for '%s'", flist.Absolute())
Expand Down Expand Up @@ -326,6 +333,10 @@ func (u *Upgrader) uninstall(flist FListInfo) error {
}
}

if !del {
return nil
}

// now delete ALL files, ignore what doesn't delete
for _, file := range files {
stat, err := os.Stat(file.Path)
Expand Down Expand Up @@ -367,7 +378,7 @@ func (u *Upgrader) applyUpgrade(from, to FullFListInfo) error {
return err
}

if err := u.uninstall(from.FListInfo); err != nil {
if err := u.uninstall(from.FListInfo, true); err != nil {
log.Error().Err(err).Msg("failed to uninstall current flist. Upgraded anyway")
}

Expand Down
Loading