Bug 1658159

Summary: addon value is removed from syspurpose file when you try to add the same addon twice
Product: Red Hat Enterprise Linux 8 Reporter: Shwetha Kallesh <skallesh>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: khowell, redakkan, skallesh
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-12-11 11:14:09 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:

Description Shwetha Kallesh 2018-12-11 12:17:05 UTC
Description of problem:

addon value is removed from syspurpose file when you try to add the same addon twice
Version-Release number of selected component (if applicable):

root@hp-dl380pgen8-02-vm-16 ~]# subscription-manager  version
server type: This system is currently not registered.
subscription management server: 2.6.0-1
subscription management rules: 5.30
subscription-manager: 1.23.8-6.el8


How reproducible:


Steps to Reproduce:

[root@hp-dl380pgen8-02-vm-16 ~]# cat /etc/rhsm/syspurpose/syspurpose.json 
{}[

Add an addon ELS on a unregistered system:
-----------------------------------------------------------------------------
root@hp-dl380pgen8-02-vm-16 ~]syspurpose add-addons ELS
Added ELS to addons.
Unable to send system purpose to subscription management server

Verify the value is added to syspurpose.json file
------------------------------------------------------------------------
[root@hp-dl380pgen8-02-vm-16 ~]# cat /etc/rhsm/syspurpose/syspurpose.json 
{
  "addons": [
    "ELS"
  ]
}

Add the add on again
----------------------------------------------------------------------------
[root@hp-dl380pgen8-02-vm-16 ~]#syspurpose add-addons ELS 
Not adding value ELS to addons; it already exists.
Unable to send system purpose to subscription management server

Observe the value is actually removed from syspurpose.json file
-----------------------------------------------------------------------
[root@hp-dl380pgen8-02-vm-16 ~]# cat /etc/rhsm/syspurpose/syspurpose.json 
{}

Actual results:
Value is removed from syspurpose.json file

Expected results:
Value shouldnot be removed

Additional info:

Comment 1 Kevin Howell 2019-01-07 15:47:45 UTC
Can you please retest against latest build?

Comment 2 Shwetha Kallesh 2019-01-09 08:54:44 UTC
Issue is fixed in the latest build:
[root@kvm-04-guest14 ~]# subscription-manager  version
server type: This system is currently not registered.
subscription management server: Unknown
subscription management rules: Unknown
subscription-manager: 1.23.8-12.el8


[root@kvm-04-guest14 ~]# cat /etc/rhsm/syspurpose/syspurpose.json 
{}[root@kvm-04-guest14 ~]# syspurpose add-addons ELS
Added ELS to addons.
Unable to send system purpose to subscription management server
[root@kvm-04-guest14 ~]#  cat /etc/rhsm/syspurpose/syspurpose.json 
{
  "addons": [
    "ELS"
  ]
}[root@kvm-04-guest14 ~]# syspurpose add-addons ELS 
Not adding value ELS to addons; it already exists.
Unable to send system purpose to subscription management server
[root@kvm-04-guest14 ~]# cat /etc/rhsm/syspurpose/syspurpose.json
{
  "addons": [
    "ELS"
  ]
}[root@kvm-04-guest14 ~]# syspurpose show
{
  "addons": [
    "ELS"
  ]
}
Unable to send system purpose to subscription management server

Comment 3 Rehana 2019-01-16 09:27:06 UTC
Verifying on :
===========

# subscription-manager version
subscription management server: 2.3.12-1
subscription management rules: 5.30
subscription-manager: 1.23.8-14.el8

On a unregistered system :
===========================

[root@kvm-02-guest09 ~]# syspurpose show
{}
Unable to send system purpose to subscription management server

# syspurpose add-addons ELS
Added ELS to addons.
Unable to send system purpose to subscription management server

# syspurpose show
{
  "addons": [
    "ELS"
  ]
}
Unable to send system purpose to subscription management server

# syspurpose add-addons ELS ; syspurpose show
Not adding value ELS to addons; it already exists.
Unable to send system purpose to subscription management server
{
  "addons": [
    "ELS"
  ]
}
Unable to send system purpose to subscription management server

^^ Notice the value was not removed when tried to add the same value again 

On a Registered system:
========================

# syspurpose show
{}
System purpose successfully sent to subscription management server.

# syspurpose add-addons EUS ; syspurpose show
Added EUS to addons.
System purpose successfully sent to subscription management server.
{
  "addons": [
    "EUS"
  ]
}
System purpose successfully sent to subscription management server.

# syspurpose add-addons EUS ; syspurpose show
Not adding value EUS to addons; it already exists.
System purpose successfully sent to subscription management server.
{
  "addons": [
    "EUS"
  ]
}
System purpose successfully sent to subscription management server.

^^ Notice the value was not removed when tried to add the same value again 

Also repeated the same steps for subscription-manager addon module as well, made the same observations there as well.

# subscription-manager addons --add "ELS" ; subscription-manager addons --add "ELS" ; syspurpose show
addons updated.
addons updated.
{
  "addons": [
    "ELS"
  ]
}
System purpose successfully sent to subscription management server.

Based on the above observations, moving the bug to Verified.

Comment 5 Rehana 2020-12-11 11:14:09 UTC
Old bug clean up :
================

Closing the bug with Current release ,the bug was verified by QE during a RHEL release cycle but was not closed.