Bug 1320146

Summary: hammer content-view remove-version doesn't remove version
Product: Red Hat Satellite 6 Reporter: Lukas Pramuk <lpramuk>
Component: Content ManagementAssignee: Christine Fouant <cfouant>
Status: CLOSED NOTABUG QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: abradshaw, bbuckingham, ehelms, mmccune
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/11784
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-19 17:39:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 1190823    

Description Lukas Pramuk 2016-03-22 12:13:12 UTC
Description of problem:
the command looks like successfully finished "The component version has been removed" but nothing happened, version still present.

Version-Release number of selected component (if applicable):
@Sat6.2.0 Beta Snap4

How reproducible:
always

Steps to Reproduce:

1.Create CV 'Custom View'

2.Publish 4x the CV

3.List CV's versions
# hammer content-view info --id 3
...
Versions:               
 1) ID:        3
    Version:   1.0
    Published: 2016/03/22 09:54:07
 2) ID:        4
    Version:   2.0
    Published: 2016/03/22 09:54:39
 3) ID:        5
    Version:   3.0
    Published: 2016/03/22 10:08:49
 4) ID:        6
    Version:   4.0
    Published: 2016/03/22 10:10:40
...

4.Try to delete CV version either by id or number using hammer:
# hammer content-view remove-version --id 3 --content-view-version-id 6
Warning: Option --id is deprecated. This option will be removed in Katello 2.5, Use --uuid
The component version has been removed

# hammer content-view remove-version --id 3 --content-view-version 4.0
Warning: Option --id is deprecated. This option will be removed in Katello 2.5, Use --uuid
The component version has been removed

5.Check for command result:
# hammer content-view info --id 3
...
Versions:               
 1) ID:        3
    Version:   1.0
    Published: 2016/03/22 09:54:07
 2) ID:        4
    Version:   2.0
    Published: 2016/03/22 09:54:39
 3) ID:        5
    Version:   3.0
    Published: 2016/03/22 10:08:49
 4) ID:        6
    Version:   4.0
    Published: 2016/03/22 10:10:40
...

Actual results:
nothing happened

Expected results:
specified version is removed

Comment 1 Lukas Pramuk 2016-03-22 12:21:03 UTC
The tools is happy even with non-existent ids/versions:

# hammer content-view remove-version --id 3 --content-view-version-id 99999
...
The component version has been removed

Comment 3 Christine Fouant 2016-04-01 18:37:26 UTC
*** Bug 1221122 has been marked as a duplicate of this bug. ***

Comment 4 Christine Fouant 2016-04-01 20:29:28 UTC
For this bug, we are going to remove the entire "remove-version" option on content-view because it is redundant with "content-view remove" where you can remove multiple versions on a content view. However, currently content-view remove does not seem to be working in hammer, so I am fixing that, and will remove 'remove-version' with that fix.

Comment 5 Christine Fouant 2016-04-01 20:47:09 UTC
Please scratch the CM#4 (In reply to Christine Fouant from comment #4)
> For this bug, we are going to remove the entire "remove-version" option on
> content-view because it is redundant with "content-view remove" where you
> can remove multiple versions on a content view. However, currently
> content-view remove does not seem to be working in hammer, so I am fixing
> that, and will remove 'remove-version' with that fix.

Please scratch this comment. There was a miscommunication about the remove-version command.

Comment 6 Bryan Kearney 2016-04-05 02:07:10 UTC
Upstream bug component is Content Management

Comment 7 Christine Fouant 2016-04-19 17:33:48 UTC
(In reply to Lukas Pramuk from comment #0)
> Description of problem:
> the command looks like successfully finished "The component version has been
> removed" but nothing happened, version still present.
> 
> Version-Release number of selected component (if applicable):
> @Sat6.2.0 Beta Snap4
> 
> How reproducible:
> always
> 
> Steps to Reproduce:
> 
> 1.Create CV 'Custom View'
> 
> 2.Publish 4x the CV
> 
> 3.List CV's versions
> # hammer content-view info --id 3
> ...
> Versions:               
>  1) ID:        3
>     Version:   1.0
>     Published: 2016/03/22 09:54:07
>  2) ID:        4
>     Version:   2.0
>     Published: 2016/03/22 09:54:39
>  3) ID:        5
>     Version:   3.0
>     Published: 2016/03/22 10:08:49
>  4) ID:        6
>     Version:   4.0
>     Published: 2016/03/22 10:10:40
> ...
> 
> 4.Try to delete CV version either by id or number using hammer:
> # hammer content-view remove-version --id 3 --content-view-version-id 6
> Warning: Option --id is deprecated. This option will be removed in Katello
> 2.5, Use --uuid
> The component version has been removed
> 
> # hammer content-view remove-version --id 3 --content-view-version 4.0
> Warning: Option --id is deprecated. This option will be removed in Katello
> 2.5, Use --uuid
> The component version has been removed
> 
> 5.Check for command result:
> # hammer content-view info --id 3
> ...
> Versions:               
>  1) ID:        3
>     Version:   1.0
>     Published: 2016/03/22 09:54:07
>  2) ID:        4
>     Version:   2.0
>     Published: 2016/03/22 09:54:39
>  3) ID:        5
>     Version:   3.0
>     Published: 2016/03/22 10:08:49
>  4) ID:        6
>     Version:   4.0
>     Published: 2016/03/22 10:10:40
> ...
> 
> Actual results:
> nothing happened
> 
> Expected results:
> specified version is removed

This is being used incorrectly. The remove-version command is used to remove a component version from a composite view. You are trying to remove a published version from a non-composite view, which is a different command, simply 'remove'.

Here is sample output:

# hammer content-view info --id 3 --organization-id 1
ID:                     3
Name:                   cv2
Label:                  cv2
Composite:              true
Description:            
Content Host Count:     0
Organization:           Default Organization
Yum Repositories:       

Docker Repositories:    

OSTree Repositories:    

Puppet Modules:         

Lifecycle Environments: 
 1) ID:   4
    Name: prod
 2) ID:   1
    Name: Library
Versions:               
 1) ID:        5
    Version:   1.0
    Published: 2016/04/18 20:38:36
 2) ID:        6
    Version:   2.0
    Published: 2016/04/18 20:39:22
 3) ID:        8
    Version:   3.0
    Published: 2016/04/19 13:34:01
Components:             
 1) ID:   4
    Name: cv1 3.0
 2) ID:   7
    Name: cv3 1.0
Activation Keys:

Please note, the different versions listed under "Versions" are not removable with the 'remove-version' command. The components which could be removed with 'remove-version' are:
Components:             
 1) ID:   4
    Name: cv1 3.0
 2) ID:   7
    Name: cv3 1.0


# hammer content-view remove-version --id 3 --content-view-version-id 7
The component version has been removed

# hammer content-view info --id 3 --organization-id 1ID:                     3
Name:                   cv2
Label:                  cv2
Composite:              true
Description:            sorry charley
Content Host Count:     0
Organization:           Default Organization
Yum Repositories:       

Docker Repositories:    

OSTree Repositories:    

Puppet Modules:         

Lifecycle Environments: 
 1) ID:   4
    Name: prod
 2) ID:   1
    Name: Library
Versions:               
 1) ID:        5
    Version:   1.0
    Published: 2016/04/18 20:38:36
 2) ID:        6
    Version:   2.0
    Published: 2016/04/18 20:39:22
 3) ID:        8
    Version:   3.0
    Published: 2016/04/19 13:34:01
Components:             
 1) ID:   4
    Name: cv1 3.0
Activation Keys:

Please note that content-view-version 7 was removed as a component of this content view.

As far as non-existent ids/versions working, the mindset is that since we are disassociating a resource, it should not fail as it yields the same results as it would if the resource did exist: the result being that the component is not associated with the content view.