Bug 1879856

Summary: Warning message shouldnot be displayed when user tries to set valid syspurpose attributes with random case
Product: Red Hat Enterprise Linux 8 Reporter: Shwetha Kallesh <skallesh>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: ---CC: arpandey, jsefler, redakkan
Target Milestone: rcKeywords: EasyFix, Triaged
Target Release: 8.5Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.28.17-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:37:33 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 2020-09-17 07:49:57 UTC
Description of problem:
Warning message shouldnot be displayed when user tries to set valid syspurpose attributes with random case

Version-Release number of selected component (if applicable):
[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.1.19-1
subscription management rules: 5.41
subscription-manager: 1.27.16-1.el8

How reproducible:


Steps to Reproduce:
[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager register --serverurl subscription.rhsm.stage.redhat.com:443/subscription
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_auto_syspurpose001
Password: 
The system has been registered with ID: 45f98c84-ea05-4317-95ef-47e5dc5ec9df
The registered system name is: ibm-x3650m4-01-vm-14.ibm2.lab.eng.bos.redhat.com
[root@ibm-x3650m4-01-vm-14 ~]# syspurpose show
{
  "service_level_agreement": "PrEmium"
}
[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager role --list
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node

Set valid role with random alphabetic case:
--------------------------------------------------------
[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager role --set "Red HaT EnterprisE LinuX WorkstatioN"
Warning: Provided value "Red HaT EnterprisE LinuX WorkstatioN" is not included in the list of valid values
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
role set to "Red HaT EnterprisE LinuX WorkstatioN".

[root@ibm-x3650m4-01-vm-14 ~]# syspurpose show
{
  "role": "Red HaT EnterprisE LinuX WorkstatioN",
  "service_level_agreement": "PrEmium"
}

Now lets try to auto attach and confirm auto-attach ignores the case:
---------------------------------------------------------------------
[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 High Touch Beta
Status:       Subscribed

Product Name: Red Hat Enterprise Linux for x86_64
Status:       Subscribed

[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager list --consumed
+-------------------------------------------+
   Consumed Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Enterprise Linux Workstation, Premium
Provides:            Red Hat Beta
                     Red Hat CodeReady Linux Builder for x86_64
                     Red Hat Container Images
                     Red Hat Container Images Beta
                     Oracle Java (for RHEL Client)
                     dotNET on RHEL (for RHEL Workstation)
                     Oracle Java (for RHEL Workstation)
                     dotNET on RHEL Beta (for RHEL Workstation)
                     Red Hat Enterprise Linux for x86_64
                     dotNET on RHEL (for RHEL Server)
                     Red Hat Software Collections Beta (for RHEL Workstation)
                     dotNET on RHEL Beta (for RHEL Server)
                     Red Hat Enterprise Linux Workstation         -----> SKU with role "Red Hat Enterprise Linux Workstation" is attached, so case is ignored while attaching the sku
                     Red Hat Ansible Engine
SKU:                 RH0923296
Contract:            12034270
Account:             6320620
Serial:              1498228729952099163
Pool ID:             8a99f9ae6e3a9cac016e3b6525a70015
Provides Management: Yes
Active:              True
Quantity Used:       1
Service Type:        L1-L3
Roles:               Red Hat Enterprise Linux Workstation
Service Level:       Premium
Usage:               Production
Add-ons:             
Status Details:      Subscription is current
Subscription Type:   Standard
Starts:              11/05/2019
Ends:                11/04/2020
Entitlement Type:    Virtual

Subscription Name:   Red Hat Enterprise Linux High Touch Beta
Provides:            Red Hat Enterprise Linux for SAP Applications for IBM z Systems High Touch Beta
                     Red Hat Enterprise Linux for x86_64 High Touch Beta
                     Red Hat Container Images HTB
                     Red Hat Enterprise Linux 7 Workstation High Touch Beta
                     Red Hat Enterprise Linux for IBM z Systems High Touch Beta
                     Red Hat Enterprise Linux for Power, little endian High Touch Beta
                     Red Hat Enterprise Linux 7 for HPC Compute Node High Touch Beta
                     Red Hat CodeReady Linux Builder for x86_64 High Touch Beta
                     Red Hat CodeReady Linux Builder for Power, little endian High Touch Beta
                     Red Hat CodeReady Linux Builder for ARM 64 High Touch Beta
                     Red Hat Enterprise Linux High Availability High Touch Beta
                     Red Hat Enterprise Linux for Real Time High Touch Beta
                     Red Hat Enterprise Linux for ARM 64 High Touch Beta
                     Red Hat Enterprise Linux Atomic Host HTB
                     Red Hat Enterprise Linux 7 Load Balancer High Touch Beta
                     Red Hat Enterprise Linux for SAP HANA for x86_64 High Touch Beta
                     Red Hat CodeReady Linux Builder for IBM z Systems High Touch Beta
                     Red Hat Enterprise Linux Resilient Storage High Touch Beta
                     Red Hat Enterprise Linux for SAP HANA for Power, little endian High Touch Beta
                     Red Hat Enterprise Linux for SAP Applications for x86_64 High Touch Beta
                     Red Hat Enterprise Linux 7 Desktop High Touch Beta
                     Red Hat Enterprise Linux for SAP Applications for Power, little endian High Touch Beta
SKU:                 RH00076
Contract:            12034273
Account:             6320620
Serial:              1731867568961124808
Pool ID:             8a99f9ae6e3a9cac016e3b677ae500b4
Provides Management: No
Active:              True
Quantity Used:       1
Service Type:        L1-L3
Roles:               
Service Level:       Self-Support
Usage:               
Add-ons:             
Status Details:      Subscription is current
Subscription Type:   Standard
Starts:              11/05/2019
Ends:                11/04/2020
Entitlement Type:    Physical


[root@ibm-x3650m4-01-vm-14 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

System Purpose Status: Matched
^^ observe the status is also matched, case is ignored here as well



Actual results:
Warning message is displayed when user tries to set valid syspurpose attributes with random case

Expected results:
Warning message shouldnot be displayed when user tries to set valid syspurpose attributes with random case

Additional info:

Comment 2 Tiffany Merry 2021-03-08 21:11:38 UTC
pull Request https://github.com/candlepin/subscription-manager/pull/2479

Comment 3 Archana Pandey 2021-04-16 09:40:54 UTC
Pre-verifying on subscription-manager-1.28.15-1.el8.x86_64

[root@kvm-08-guest13 ~]# subscription-manager role --list
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
root@kvm-08-guest13 ~]# syspurpose show
{}

[root@kvm-08-guest13 ~]# subscription-manager role --set "Red Hat Enterprise LiNux ServeR"
Warning: Provided value "Red Hat Enterprise LiNux ServeR" is not included in the list of valid values
 - Red Hat Enterprise Linux Workstation    ^^^^ warning still being displayed
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
role set to "Red Hat Enterprise LiNux ServeR".

[root@kvm-08-guest13 ~]# subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 Beta
Status:       Subscribed

[root@kvm-08-guest13 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

System Purpose Status: Matched

[root@kvm-08-guest13 ~]# 


[root@kvm-08-guest13 ~]# 
[root@kvm-08-guest13 ~]# rpm -qa --changelog subscription-manager | grep 1879856
[root@kvm-08-guest13 ~]#
                           ^^^^ no changelog present for this bug

@Tiffany Can you please confirm if the fix was merged to subscription-manager-1.28.15-1.el8.x86_64

Comment 4 Tiffany Merry 2021-04-21 16:09:42 UTC
This fix was not included in subscription-manager-1.28, I will cherry-pick the change and include it the branch.

Comment 5 Shwetha Kallesh 2021-05-20 10:07:52 UTC
Reproducer:

[root@kvm-02-guest25 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.11-1
subscription management rules: 5.41
subscription-manager: 1.28.16-1.el8


[root@kvm-02-guest25 ~]# subscription-manager role --list
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Workstation
 - SP Server
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node


[root@kvm-02-guest25 ~]# subscription-manager role --set "Red Hat Enterprise LinuX SerVeR"
Warning: Provided value "Red Hat Enterprise LinuX SerVeR" is not included in the list of valid values
 - Red Hat Enterprise Linux Workstation
 - SP Server
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
role set to "Red Hat Enterprise LinuX SerVeR".
[root@kvm-02-guest25 ~]# subscription-manager usage --list
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Production
[root@kvm-02-guest25 ~]# subscription-manager usage --set "PRoDuctioN"
Warning: Provided value "PRoDuctioN" is not included in the list of valid values
 - Production
usage set to "PRoDuctioN".


[root@kvm-02-guest25 ~]# subscription-manager service-level --list
+-------------------------------------------+
           Available Service Levels
+-------------------------------------------+
AMC-Enhanced
Premium
Self-Support
Standard


[root@kvm-02-guest25 ~]# subscription-manager service-level --set "amc-EnHanced"
Warning: Provided value "amc-EnHanced" is not included in the list of valid values
 - AMC-Enhanced
 - Standard
 - Premium
 - Self-Support
service_level_agreement set to "amc-EnHanced".

[root@kvm-02-guest25 ~]# subscription-manager addons --list
+-------------------------------------------+
              Available addons
+-------------------------------------------+
 - ADDON1
 - ADDON3
 - ADDON2


[root@kvm-02-guest25 ~]# subscription-manager addons --add "Addon1"
Warning: Provided value "Addon1" is not included in the list of valid values
 - ADDON1
 - ADDON3
 - ADDON2
addons updated.

Comment 6 Shwetha Kallesh 2021-05-20 10:10:56 UTC
Pre-verification comments:

[root@kvm-01-guest17 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.11-1
subscription management rules: 5.41
subscription-manager: 1.28.16-1.git.19.dfbe16a.el8


[root@kvm-01-guest17 ~]# rm -rf /var/lib/rhsm/cache/valid_fields.json 
[root@kvm-01-guest17 ~]# subscription-manager role --list
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Workstation
 - SP Server
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
[root@kvm-01-guest17 ~]# subscription-manager role --set "Red Hat Enterprise LinuX SerVeR"
role set to "Red Hat Enterprise LinuX SerVeR".
^^ no warning message is displayed when user tries to set valid values with random case

[root@kvm-01-guest17 ~]# subscription-manager usage --list
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Production
[root@kvm-01-guest17 ~]# subscription-manager usage --set "PRoDuctioN"
usage set to "PRoDuctioN".
^^ no warning message is displayed when user tries to set valid values with random case

[root@kvm-01-guest17 ~]# subscription-manager service-level --list
+-------------------------------------------+
           Available Service Levels
+-------------------------------------------+
AMC-Enhanced
Premium
Self-Support
Standard
[root@kvm-01-guest17 ~]# subscription-manager service-level --set "amc-EnHanced"
service_level_agreement set to "amc-EnHanced".
^^ no warning message is displayed when user tries to set valid values with random case

[root@kvm-01-guest17 ~]# subscription-manager addons --list
+-------------------------------------------+
              Available addons
+-------------------------------------------+
 - ADDON1
 - ADDON3
 - ADDON2
[root@kvm-01-guest17 ~]# subscription-manager addons --add "Addon1"
addons updated.
^^ no warning message is displayed when user tries to set valid values with random case


Warning messages are displayed when user tries to set invalid values:

[root@kvm-01-guest17 ~]# subscription-manager role --set SPSERVER
Warning: Provided value "SPSERVER" is not included in the list of valid values
 - SP Starter
 - SP Server
role set to "SPSERVER".
[root@kvm-01-guest17 ~]# subscription-manager service-level --set SPSERVER
Warning: Provided value "SPSERVER" is not included in the list of valid values
 - Super
 - Full-Service
 - Premium
 - Standard
 - None
service_level_agreement set to "SPSERVER".
[root@kvm-01-guest17 ~]# subscription-manager usage --set SPSERVER
Warning: Provided value "SPSERVER" is not included in the list of valid values
 - Production
 - Development
usage set to "SPSERVER".

Comment 10 Rehana 2021-06-14 15:54:27 UTC
Verifying on : 
=============
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.18-1
subscription management rules: 5.41
subscription-manager: 1.28.17-1.el8


# rpm -qa subscription-manager --changelog | grep 1879856
- 1879856: suppress the warning message when setting syspurpose values (tmerry)

# rm -rf /var/lib/rhsm/cache/valid_fields.json 

# subscription-manager role --list
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node

#  subscription-manager role --set "Red Hat Enterprise LinuX SerVeR"
role set to "Red Hat Enterprise LinuX SerVeR".

# subscription-manager usage --list
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Development/Test
 - Production

# subscription-manager usage --set "PRoDuctioN"
usage set to "PRoDuctioN".

# subscription-manager service-level --list
+-------------------------------------------+
           Available Service Levels
+-------------------------------------------+
Premium
Self-Support
Standard

[root@kvm-02-guest25 ~]# subscription-manager service-level --set "pREmium"
service_level_agreement set to "pREmium".

[root@kvm-02-guest25 ~]# subscription-manager addons --list
There are no available values for the system purpose "addons" from the available subscriptions in this organization.


# syspurpose show
The 'syspurpose' command is deprecated and will be removed in a future major release. Please use the 'subscription-manager syspurpose' command going forward.
{
  "addons": [
    "HA"
  ],
  "role": "Red Hat Enterprise LinuX SerVeR",
  "service_level_agreement": "pREmium",
  "usage": "prODUCTION"
}

Now auto-attach the system and check if the above values influenced the results 

# subscription-manager remove --all ; subscription-manager attach --auto
2 local certificates have been deleted.
2 subscriptions removed at the server.
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 Beta
Status:       Subscribed

# subscription-manager list --consumed ; subscription-manager status
+-------------------------------------------+
   Consumed Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Beta Access
Provides:            Red Hat Enterprise Linux for Power, little endian Beta
                     Red Hat CodeReady Linux Builder for x86_64 Beta
                     Red Hat Enterprise Linux for ARM 64 Beta
                     Red Hat CodeReady Linux Builder for Power, little endian Beta
                     Red Hat Enterprise Linux for SAP HANA for Power, little endian Beta
                     Red Hat Enterprise Linux for x86_64 Beta
                     Red Hat Enterprise Linux Fast Datapath Beta for Power, little endian
                     Red Hat CodeReady Linux Builder for ARM 64 Beta
                     Red Hat Enterprise Linux High Availability Beta
                     Red Hat Enterprise Linux for SAP Applications for x86_64 Beta
                     Red Hat CodeReady Linux Builder for IBM z Systems Beta
                     Red Hat Enterprise Linux for SAP Applications for Power, little endian Beta
                     Red Hat Enterprise Linux for IBM z Systems Beta
                     Red Hat Enterprise Linux Resilient Storage Beta
                     Red Hat Enterprise Linux for Real Time Beta
                     Red Hat Directory Server Beta
                     Red Hat Enterprise Linux for SAP Applications for IBM z Systems Beta
                     Red Hat Certificate System Beta
                     Red Hat Enterprise Linux for Real Time for NFV Beta
                     Red Hat Enterprise Linux Fast Datapath Beta for x86_64
                     Red Hat Enterprise Linux for SAP HANA for x86_64 Beta
SKU:                 RH00069
Contract:            12112973
Account:             6367075
Serial:              3735216291982500644
Pool ID:             8a99f9ad795d50e901797ef81ff2061e
Provides Management: No
Active:              True
Quantity Used:       1
Service Type:        L1-L3
Roles:               
Service Level:       Self-Support
Usage:               
Add-ons:             
Status Details:      Subscription is current
Subscription Type:   Standard
Starts:              05/18/2021
Ends:                05/17/2022
Entitlement Type:    Physical

Subscription Name:   Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes)
Provides:            Red Hat CodeReady Linux Builder for x86_64
                     Red Hat Enterprise Linux Atomic Host
                     Red Hat Enterprise Linux Atomic Host Beta
                     Red Hat Developer Tools (for RHEL Server)
                     Red Hat Container Images
                     Red Hat Developer Tools Beta (for RHEL Server)
                     Red Hat Container Images Beta
                     Red Hat Developer Toolset (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server) - Extended Update Support
                     Red Hat Enterprise Linux for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64 - Extended Update Support
                     dotNET on RHEL (for RHEL Server)
                     Red Hat Enterprise Linux for x86_64 - Extended Update Support
                     dotNET on RHEL Beta (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended Update Support
                     Red Hat Beta
                     Red Hat EUCJP Support (for RHEL Server) - Extended Update Support
                     Oracle Java (for RHEL Server)
                     Red Hat Software Collections (for RHEL Server)
                     Oracle Java (for RHEL Server) - Extended Update Support
                     Red Hat CodeReady Linux Builder for x86_64 - Extended Update Support
                     Red Hat S-JIS Support (for RHEL Server) - Extended Update Support
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux High Availability for x86_64 - Extended Update Support
                     Red Hat Ansible Engine
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update Support
                     Red Hat Enterprise Linux Server
SKU:                 RH00003
Contract:            12112971
Account:             6367075
Serial:              3694306150882221125
Pool ID:             8a99f9ad795d50e901797ef81f4d061c
Provides Management: No
Active:              True
Quantity Used:       1
Service Type:        L1-L3
Roles:               Red Hat Enterprise Linux Server
Service Level:       Premium
Usage:               Production
Add-ons:             
Status Details:      Subscription is current
Subscription Type:   Instance Based
Starts:              05/18/2021
Ends:                05/17/2022
Entitlement Type:    Physical

+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

System Purpose Status: Mismatched
- The requested add-on "HA" is not provided by a currently consumed subscription.

^^ Notice that on a Beta system a subscription "RH00003" was attached that matched all of the syspurpose values . Since addons is not yet supported the above mismatch message is accurate. 

Based on the above observation , moving the bug to verified!!!

Comment 13 errata-xmlrpc 2021-11-09 19:37:33 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 (subscription-manager bug fix and enhancement update), 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-2021:4390