Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1286523

Summary: hammer content-view promote failed when promoting content-view version with minor versions via option --version
Product: Red Hat Satellite Reporter: Neil Miao <nmiao>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED NEXTRELEASE QA Contact: sthirugn <sthirugn>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1.4CC: bbuckingham, bkearney, sthirugn
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Linux   
URL: http://projects.theforeman.org/issues/12628
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 20:03:31 UTC Type: Bug
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: 1324598    
Bug Blocks:    

Description Neil Miao 2015-11-30 07:10:11 UTC
Description of problem:

I have content-view 'iam'

# hammer content-view list --organization rhit
----------------|------|-------|-----------|-----------------
CONTENT VIEW ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS
----------------|------|-------|-----------|-----------------
10              | iam  | iam   |           | 9, 6, 5, 1, 2, 7

with 2 versions (2.0 and 2.1)

# hammer content-view version list
---|---------|---------|-------------------------
ID | NAME    | VERSION | LIFECYCLE ENVIRONMENTS
---|---------|---------|-------------------------
16 | iam 2.1 | 2.1     | qa
14 | iam 2.0 | 2.0     | Library

When I try to promote v2.1 to stage via hammer, I got this error consistently
# hammer content-view version promote --content-view-id 10 --to-lifecycle-environment stage --version='2.1' --organization rhit
Could not promote the content view:
  Error: content_view_version found more than once


Version-Release number of selected component (if applicable):
katello-2.2.0.16-1.el7sat.noarch

How reproducible:
always

Steps to Reproduce:
1. hammer content-view version promote --content-view-id 10 --to-lifecycle-environment stage --version '2.1'
2.
3.

Actual results:
error

Expected results:
content-view version should be promoted

Additional info:

I tracked the issue down to this file
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.76/app/models/katello/content_view_version.rb

    def self.for_version(version)
      major, minor = version.to_s.split('.')
      query = where(:major => major)
      query.where(:minor => minor) if minor <--- #1
Rails.logger.debug '!!DEBUG!!'
Rails.logger.debug version.to_s
Rails.logger.debug minor.to_s
Rails.logger.debug query.to_sql
      query
    end

-- log --
2015-11-30 06:26:46 [D] !!DEBUG!!
2015-11-30 06:26:46 [D] 2.1
2015-11-30 06:26:46 [D] 1
2015-11-30 06:26:46 [D] SELECT "katello_content_view_versions".* FROM "katello_content_view_versions" INNER JOIN "katello_content_views" ON "katello_content_views"."id" = "katello_content_view_versions"."content_view_id" WHERE "katello_content_views"."id" IN (1, 4, 8, 3, 7, 6, 10) AND "katello_content_view_versions"."content_view_id" = 10 AND "katello_content_view_versions"."major" = 2
-- log --

variable 'version' and 'minor' is getting the right figure, but somehow clause #1 does absolutely nothing, as "minor" = 1 does not appears in the query. 

here is the proposed fix:

    def self.for_version(version)
      major, minor = version.to_s.split('.')
      minor = 0 if minor.nil?
      query = where(:major => major, :minor => minor)
      query
    end

Comment 1 Partha Aji 2015-11-30 08:40:05 UTC
Created redmine issue http://projects.theforeman.org/issues/12628 from this bug

Comment 2 Bryan Kearney 2015-12-18 17:04:14 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/12628 has been closed
-------------
Neil Miao
Applied in changeset commit:katello|9301efab185cd7eef60dfe308bbbe2304e904dc8.

Comment 5 sthirugn@redhat.com 2016-04-07 14:37:47 UTC
Failed for the same reason as shown in https://bugzilla.redhat.com/show_bug.cgi?id=1324598

Comment 8 sthirugn@redhat.com 2016-05-16 12:18:09 UTC
Moving to ON_QA as bug mentioned in Comment 5 is verified.

Comment 10 Bryan Kearney 2017-08-01 20:03:31 UTC
The fix to this bug will be delivered with release 6.3 of Satellite.