stdevel / katprep

Python toolkit for automating system maintenance and generating patch reports along with Foreman/Katello and Red Hat Satellite 6.x
GNU General Public License v3.0
35 stars 6 forks source link

When trying to remove already removed snapshots, katprep_maintenance crashes with EmptySetException #90

Closed stdevel closed 6 years ago

stdevel commented 6 years ago

Describe the bug When cleaning up systems after maintenance, already removed snapshots cannot be removed. An exception is thrown.

To Reproduce Steps to reproduce the behavior:

  1. Prepare system maintenance
  2. Manually remove a system's snapshot
  3. Run katprep_maintenance errata-snapshot*.json cleanup

Expected behavior A warning should be displayed, e.g. Snapshot $xyz for $hostname was already removed. The execution should continue.

Environment (please complete the following information):

Additional context

$ katprep_maintenance -C container.auth errata-snapshot-report-giertz-20180721-1000.json -I dev -K cleanup
Authentication container password:
WARNING:katprep_maintenance:You decided to skip scheduling downtimes - happy flodding!
Traceback (most recent call last):
  File "/home/stdevel/.local/bin/katprep_maintenance", line 9, in <module>
    load_entry_point('katprep==0.5.0', 'console_scripts', 'katprep_maintenance')()
  File "/home/stdevel/katprep/katprep/maintenance.py", line 877, in cli
    main(options, args)
  File "/home/stdevel/katprep/katprep/maintenance.py", line 856, in main
    options.func(options, options.func)
  File "/home/stdevel/katprep/katprep/maintenance.py", line 542, in cleanup
    manage_host_preparation(options, host, True)
  File "/home/stdevel/katprep/katprep/maintenance.py", line 137, in manage_host_preparation
    vm_name, "katprep_{}".format(REPORT_PREFIX)
  File "/home/stdevel/katprep/katprep/clients/PyvmomiClient.py", line 218, in remove_snapshot
    vm_name, snapshot_title, "", action="remove"
  File "/home/stdevel/katprep/katprep/clients/PyvmomiClient.py", line 137, in __manage_snapshot
    snapshots = self.__get_snapshots(vm_name)
  File "/home/stdevel/katprep/katprep/clients/PyvmomiClient.py", line 255, in __get_snapshots
    raise EmptySetException("No snapshots found")
katprep.clients.EmptySetException: No snapshots found
stdevel commented 6 years ago

Investigating in branch bug-remove_nonexistent_snapshot-issue90.

stdevel commented 6 years ago

Fixed in commit 830b71615edee9d1b0db262283d35f1748b61ac6.