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

clean_content_views.py fails in Satellite 6.5 #58

Open
icc-marti opened this issue Jun 7, 2019 · 7 comments
Open

clean_content_views.py fails in Satellite 6.5 #58

icc-marti opened this issue Jun 7, 2019 · 7 comments
Assignees
Labels

Comments

@icc-marti
Copy link

Script clean_content_views.py fails in Red Hat Satellite 6.5 with the following error code:

Cleaning content view 'All Repositories'
Traceback (most recent call last):
  File "./clean_content_views.py", line 348, in <module>
    main(sys.argv[1:])
  File "./clean_content_views.py", line 341, in main
    cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefirstpromoted)
  File "./clean_content_views.py", line 144, in cleanup
    version_in_use, version_in_ccv = check_version_views(version['id'])
  File "./clean_content_views.py", line 93, in check_version_views
    if viewlist['katello_content_views']:
KeyError: 'katello_content_views'

Seems issue is in line 94. Tested quering API at https://localhost/katello/api/v2/content_view_versions/id and the list doesn't contain an attribute katello_content_views.

@ggatward ggatward added the bug label Jun 11, 2019
@ggatward
Copy link
Collaborator

Thanks for the report - reproduced here as well. Looks like there is no straight-up replacement of the katello_content_views field in the JSON output - working this one in branch ISSUE-58 against both 6.5 and 6.4 installations.

@adam-kosseck
Copy link

Any news on a fix for this?
As a workaround I've setup a cron job to run hammer in a loop to clear out old content views - however it'd be really nice to have a proper fix.

@assen-totin
Copy link

Would also like to see a fix - it's been 2 months now, we have to manually clean up old versions after each promotion. If you cannot fix the code here, at least, provide a patch to apply locally.

After all, these scripts are more or less "official" RedHat supplementary scripts for what Satellite should have long had as built-in functions -so it is a pity to see them not working after a change in Satellite.

@ggatward
Copy link
Collaborator

ggatward commented Aug 4, 2019

Unfortunately other commitments have left me unable to work on this (or any) issue in this project for a while. These scripts are NOT official RedHat product.

There is an ISSUE-58 branch of this project that contains a semi-fix for Satellite 6.5, in that it uses the new API syntax, however there is no code currently to allow backwards compatibility with 6.3/4, and there also seems to be no way in 6.5 to pull the required info to handle CCV versions nicely, so if you are using CCV's it won't work anyway.

Please feel free to try that branch and see if it helps - I am hoping to get some time to focus on this project again soon.

@assen-totin
Copy link

After looking at the current structure of the viewlist, it seems that this simple patch does the job for me:

--- clean_content_views.py	2019-07-24 21:54:34.230530353 +0200
+++ 1.py	2019-08-11 12:41:48.770446697 +0200
@@ -91,7 +91,7 @@
     # If the list is not empty we need to return this fact. A CV that belongs
     # to NO versions will be a candidate for cleanup.
     viewlist['composite_content_view_ids']
-    if viewlist['katello_content_views']:
+    if viewlist['environments']:
         version_in_use = True
         msg = "Version " + str(viewlist['version']) + " is associated with published CV"
         helpers.log_msg(msg, 'DEBUG')

The "environments" key will be empty whenever the examined version is not part of any environment (i.e. may be deleted if other requirements, like number of instances to keep, are met) - and will not be empty whenever the version is used in an environment, hence should not be touched.

@adam-kosseck
Copy link

@assen-totin I have tested your patch (manually) against code from the master branch and can confirm that it works perfectly. Well done!

@ozchrisishere ozchrisishere self-assigned this Dec 4, 2019
@nin0-0
Copy link

nin0-0 commented Jun 26, 2020

You can replace katello_content_views with content_view too

benformosa added a commit to benformosa/sat6_scripts that referenced this issue Aug 19, 2020
fixes RedHatSatellite#58
Conditionally apply assen-totin's fix by checking the Katello version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants