wazuh-packages icon indicating copy to clipboard operation
wazuh-packages copied to clipboard

Added service removal to common rollback

Open zbalkan opened this issue 1 year ago • 3 comments

Related issue
https://github.com/wazuh/wazuh-packages/issues/1773

Description

The method installCommon_rollBack is used extensively to rollback the Wazuh installation in case of a failure. However, it does not remove service installations.

This PR makes two additions to the installation process:

  1. Adds a method called installCommon_removeService to remove installed services.
  2. Added checks for each service in installCommon_rollBack method that calls installCommon_removeService method.

Logs example

N/A

Tests

Tests are not applicable for the PR.

  • Build the package in any supported platform
    • [ ] Linux
    • [ ] Windows
    • [ ] macOS
    • [ ] Solaris
    • [ ] AIX
    • [ ] HP-UX
  • [ ] Package installation
  • [ ] Package upgrade
  • [ ] Package downgrade
  • [ ] Package remove
  • [ ] Package install/remove/install
  • [ ] Change added to CHANGELOG.md
  • Tests for Linux RPM
    • [ ] Build the package for x86_64
    • [ ] Build the package for i386
    • [ ] Build the package for armhf
    • [ ] Build the package for aarch64
    • [ ] %files section is correctly updated if necessary
  • Tests for Linux deb
    • [ ] Build the package for x86_64
    • [ ] Build the package for i386
    • [ ] Build the package for armhf
    • [ ] Build the package for aarch64
    • [ ] Package install/remove/install
    • [ ] Package install/purge/install
    • [ ] Check file permissions after installing the package
  • Tests for macOS
    • [ ] Test the package from macOS Sierra to Mojave
  • Tests for Solaris
    • [ ] Test the package on Solaris 10
    • [ ] Test the package on Solaris 11
    • [ ] Check file permissions on Solaris 11 template
  • Tests for IBM AIX
    • [ ] %files section is correctly updated if necessary
    • [ ] Check the changes from IBM AIX 5 to 7

zbalkan avatar Aug 05 '22 14:08 zbalkan

Hello @zbalkan,

Thanks for your patience and contribution, I have reviewed the code and looks good to me but I detected a problem into the unistall step

# ./wazuh-install.sh -u
23/08/2022 07:21:43 INFO: Starting Wazuh installation assistant. Wazuh version: 4.3.6
23/08/2022 07:21:43 INFO: Verbose logging redirected to /var/log/wazuh-install.log
23/08/2022 07:21:45 INFO: Removing Wazuh manager.
23/08/2022 07:22:00 INFO: Wazuh manager removed.
23/08/2022 07:22:00 INFO: Removing service wazuh-manager.
23/08/2022 07:22:00 ERROR: wazuh-manager could not be stopped and/or removed.
23/08/2022 07:22:00 INFO: Removing Wazuh manager.
23/08/2022 07:22:01 INFO: Wazuh manager removed.
23/08/2022 07:22:01 INFO: Removing service wazuh-manager.
23/08/2022 07:22:01 ERROR: wazuh-manager could not be stopped and/or removed.
23/08/2022 07:22:01 INFO: Removing Wazuh manager.
23/08/2022 07:22:01 INFO: Wazuh manager removed.
23/08/2022 07:22:01 INFO: Removing service wazuh-manager.
23/08/2022 07:22:01 ERROR: wazuh-manager could not be stopped and/or removed.
23/08/2022 07:22:01 INFO: Removing Wazuh manager.
23/08/2022 07:22:01 INFO: Wazuh manager removed.
23/08/2022 07:22:01 INFO: Removing service wazuh-manager.
23/08/2022 07:22:01 ERROR: wazuh-manager could not be stopped and/or removed.

It seems that it's stuck in a loop trying to remove the services.

okynos avatar Aug 23 '22 07:08 okynos

Hi @okynos,

Let me check it out. Thank you for the review. Can you tell me which distribution did you try?

zbalkan avatar Aug 23 '22 07:08 zbalkan

Ok. No need for an information. It was a silly issue causing recursion.

zbalkan avatar Aug 23 '22 13:08 zbalkan

Closed for the sake of https://github.com/wazuh/wazuh-packages/pull/1824

zbalkan avatar Sep 01 '22 13:09 zbalkan