Project

General

Profile

Bug #12628

hammer content-view promote failed when promoting content-view version with minor versions via option --version

Added by Partha Aji almost 5 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Content Views
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1286523
Description of problem:

I have content-view 'iam'

  1. 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)

  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
  1. 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

Associated revisions

Revision 9301efab (diff)
Added by Neil Miao almost 5 years ago

Fixes #12628 - bugfix for content view version query

Revision cb70b679
Added by David Davis almost 5 years ago

Merge pull request #5636 from neoseele/fixes-12628

Fixes #12628 bugfix for content view version query

History

#1 Updated by The Foreman Bot almost 5 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/5636 added

#2 Updated by Neil Miao almost 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Eric Helms over 4 years ago

  • Legacy Backlogs Release (now unused) set to 86
  • Triaged changed from No to Yes

Also available in: Atom PDF