Skip to content

Commit

Permalink
[sonic-package-manager] stop service explicitelly before uninstalling…
Browse files Browse the repository at this point in the history
… package (sonic-net#1805)

#### What I did

Fixed an issue with uninstall.
1. When disabling the feature by setting its state to disabled in FEATURE table and then uninstalling it, there is a possibility that service hasn't fully stopped yet.
2. When uninstalling with --force option, and reinstalling the package with --enable option the service does not start.

#### How I did it
Stop and disable service explicitely before uninstalling package.

#### How to verify it

```
sudo spm uninstall cpu-report --force && sudo spm install cpu-report=10.0.0 -v DEBUG -y --enable && docker ps
```
  • Loading branch information
stepanblyschak committed Oct 18, 2021
1 parent d8ee5e9 commit f738818
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sonic_package_manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,17 @@ def uninstall(self, name: str, force=False):
# After all checks are passed we proceed to actual uninstallation

try:
# Stop and disable the service.
# First to make sure we are not uninstalling
# package before the service has fully stopped
# since "config feature state" command is not blocking.
# Second, we make sure the service is in disabled state
# so that after reinstall and enablement hostcfgd will enable
# it and start it.
# TODO: once there is a way to block till hostcfgd will stop
# the service, replace it with new approach.
self._systemctl_action(package, 'stop')
self._systemctl_action(package, 'disable')
self._uninstall_cli_plugins(package)
self.service_creator.remove(package)
self.service_creator.generate_shutdown_sequence_files(
Expand Down

0 comments on commit f738818

Please sign in to comment.