katprep
katprep copied to clipboard
Verifying maintenance not possible
Describe the bug
Verifying maintenance is currently not possible as katprep_maintenane
crashes:
TypeError: object of type 'NoneType' has no len()
To Reproduce Steps to reproduce the behavior:
- Prepare maintenance
- Run
katprep_maintenance *.json verify
- See error
Expected behavior Maintenance should be verified.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS version: CentOS 7.5
- Red Hat Satellite or Foreman/Katello version: 1.19.0/3.8.0
Additional context Stacktrace:
$ katprep_maintenance -C pass.auth errata-snapshot-report-xxx.json -I pinkepank verify
Authentication container password:
INFO:katprep_maintenance:This is just a SIMULATION - no changes will be made.
INFO:katprep_maintenance:Snapshot for host 'pinkepank.loc' found.
INFO:katprep_maintenance:Downtime for host 'pinkepank.loc' found.
Traceback (most recent call last):
File "/home/cstan/.local/bin/katprep_maintenance", line 9, in <module>
load_entry_point('katprep==0.5.0', 'console_scripts', 'katprep_maintenance')()
File "/home/cstan/katprep/katprep/maintenance.py", line 885, in cli
main(options, args)
File "/home/cstan/katprep/katprep/maintenance.py", line 864, in main
options.func(options, options.func)
File "/home/cstan/katprep/katprep/maintenance.py", line 447, in verify
if len(crit_services) > 0:
TypeError: object of type 'NoneType' has no len()
Change proposal: If you make use of Pythons Truth Value Testing the critical code can be simplified:
if len(crit_services) > 0:
Can be written as:
if crit_services:
The length check can be omitted in the same way on most occasions until the length is indeed required.
The benefit of this is that a returned None
will not result in errors.