Bug 1446713

Summary: Satellite 6.2 Upgrade: katello:upgrades:2.4:import_distributions error
Product: Red Hat Satellite Reporter: Satellite Program <pm-sat>
Component: RepositoriesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: high Docs Contact:
Priority: high    
Version: 6.2.0CC: arahaman, bbuckingham, bkearney, byount, chrobert, egolov, famrhein, jcallaha, jsherril, kdixon, ktordeur, mbacovsk, mkalyat, mmccune, rdixon, sthirugn, xdmoon, zhunting
Target Milestone: UnspecifiedKeywords: PrioBumpGSS, Reopened, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: katello-installer-base-3.0.0.81-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1365223 Environment:
Last Closed: 2017-06-20 17:23:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1425437    
Bug Blocks: 1385841, 1410795    

Comment 3 Mike McCune 2017-05-17 17:43:18 UTC
This will require testing by manually removing pulp distributions from the Pulp db to ensure this gets auto-corrected during a 6.1 -> 6.2.10 upgrade

Comment 4 Justin Sherrill 2017-05-30 18:30:43 UTC
Steps to reproduce:

1. Install Satellite 6.1
2. Create a repository, locate the repository ID, via the Repository details URL
3. Open the rails console:  
 # foreman-rake console
4. Delete the repo in pulp:
 > User.current = User.anonymous_api_admin
 > Katello.pulp_server.extensions.repository.delete(Katello::Repository.find(REPO_ID).pulp_id)
Replacing REPO_ID with the numeric ID found in step 2.

5. Upgrade to Satellite 6.2 without error

Comment 5 jcallaha 2017-05-30 21:05:53 UTC
Verified in Satellite 6.2.10 Snap 2. I performed te steps outlined in #4 on both RHEL 6 and RHEL 7 systems upgraded from 6.2.11. Both upgrades completed without issues. 


[root@ibm-x3650m4-01-vm-05 ~]# foreman-rake console
Loading production environment (Rails 3.2.8)
irb(main):001:0> User.current = User.anonymous_api_admin
2017-05-30 16:16:00 [D]   User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."lower_login" = 'foreman_api_admin' LIMIT 1
=> #<User id: 2, login: "foreman_api_admin", firstname: "API", lastname: "Admin", mail: nil, admin: true, last_login_on: nil, auth_source_id: 2, created_at: "2017-05-30 19:27:21", updated_at: "2017-05-30 19:27:21", password_hash: nil, password_salt: nil, locale: nil, helptips_enabled: true, page_size: 25, disabled: false, preferences: #<struct ActiveRecord::AttributeMethods::Serialization::Attribute coder=#<ActiveRecord::Coders::YAMLColumn:0x00000008a9a8c8 @object_class=Hash>, value="--- {}\n", state=:serialized>, remote_id: "admin", avatar_hash: nil, default_organization_id: nil, default_location_id: nil, lower_login: "foreman_api_admin", mail_enabled: true>
irb(main):002:0> Katello.pulp_server.extensions.repository.delete(Katello::Repository.find(3).pulp_id)
2017-05-30 16:16:53 [D]   Katello::Repository Load (0.8ms)  SELECT "katello_repositories".* FROM "katello_repositories" WHERE "katello_repositories"."id" = $1 ORDER BY katello_repositories.name ASC LIMIT 1  [["id", 3]]
=> {"spawned_tasks"=>[{"_href"=>"/pulp/api/v2/tasks/1708d70f-70e4-44e6-99a7-c27263b47bae/", "task_id"=>"1708d70f-70e4-44e6-99a7-c27263b47bae"}], "result"=>nil, "error"=>nil}



Upgrade Steps:

...

Upgrade Step: correct_repositories (this may take a while) ...
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_theme_satellite-0.1.43/app/models/concerns/satellite_packages.rb:4: warning: already initialized constant Katello::Ping::PACKAGES
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/models/katello/ping.rb:7: warning: previous definition of PACKAGES was here
Processing Repository 1/4: Red Hat Satellite 6.2 for RHEL 7 Server RPMs x86_64 (1)
Processing Repository 2/4: Red Hat Satellite 6.2 for RHEL 6 Server RPMs x86_64 (2)
Processing Repository 3/4: Red Hat Satellite 6.1 for RHEL 7 Server RPMs x86_64 (3)
Repository 3 Missing
Recreating 3
Processing Repository 4/4: Red Hat Satellite 6.1 for RHEL 6 Server RPMs x86_64 (4)

...

Upgrade Step: import_distributions (this may take a while) ...
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_theme_satellite-0.1.43/app/models/concerns/satellite_packages.rb:4: warning: already initialized constant Katello::Ping::PACKAGES
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/models/katello/ping.rb:7: warning: previous definition of PACKAGES was here
Importing distribution data into repositories

...

Comment 7 errata-xmlrpc 2017-06-20 17:23:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1553