Bug 2216704

Summary: 4xx error is not reported for 'status'
Product: Red Hat Enterprise Linux 9 Reporter: mhorky
Component: subscription-managerAssignee: CSI Client Tools Bugs <csi-client-tools-bugs>
Status: NEW --- QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: low    
Version: 9.3CC: sbakaj
Target Milestone: rcKeywords: Triaged
Target Release: ---   
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: 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 mhorky 2023-06-22 10:12:06 UTC
Description of problem:
subscription-manager does not report 4xx messages sent by the Candlepin server. Instead, it shows the cached value and does not report the error status it has received.

Version-Release number of selected component (if applicable):


How reproducible:
100 %

Steps to Reproduce:
1. Spin up local Candlepin server
2. Register a new system to it
3. Restart the Candlepin server and make sure to redeploy the test data, to make the local certificate installed at the system invalid
4. Run 'subscription-manager status'

Actual results:

> +-------------------------------------------+
>    System Status Details
> +-------------------------------------------+
> Overall Status: Current
> 
> System Purpose Status: Not Specified

Expected results:

The 4xx status message is taken into account. One possibility is to do not display anything and only show the error message, as we usually do with error messages received from the server.

Another option is to include a message similar to the SCA one: show the table, but include additional information about the server reported failure.

> +-------------------------------------------+
>    System Status Details
> +-------------------------------------------+
> Overall Status: Current
> The system has received an error from the server: "Invalid Credentials". Cached value has been displayed.
> 
> System Purpose Status: Not Specified


Additional info:

The following is a debug output from the original reporter.

    [root@dhcp131-49 ~]# subscription-manager status --ondate=2025-01-28
    401 {'x-candlepin-request-uuid': 'c89118bc-b1ee-42a6-8751-5601fda37bd6', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "c89118bc-b1ee-42a6-8751-5601fda37bd6"
    }
     
    401 {'x-candlepin-request-uuid': 'fcf70c49-c049-44b9-98a5-a538f17f868b', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "fcf70c49-c049-44b9-98a5-a538f17f868b"
    }
     
    401 {'x-candlepin-request-uuid': '1a133ad8-d969-43a0-8747-0e3d2db9c434', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "1a133ad8-d969-43a0-8747-0e3d2db9c434"
    }
     
    401 {'x-candlepin-request-uuid': 'ad0889e4-b7ae-4654-af57-4ee50c2567f5', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "ad0889e4-b7ae-4654-af57-4ee50c2567f5"
    }
     
    +-------------------------------------------+
       System Status Details
    +-------------------------------------------+
    401 {'x-candlepin-request-uuid': '27c4cbdf-465a-4421-b283-deac40652f18', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "27c4cbdf-465a-4421-b283-deac40652f18"
    }
     
    Overall Status: Current
     
    200 {'x-candlepin-request-uuid': 'f8ea0b7a-3830-4593-a4ff-108f78d5be5c', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "mode" : "NORMAL",
      "modeReason" : null,
      "modeChangeTime" : null,
      "result" : true,
      "version" : "4.3.6",
      "release" : "1",
      "standalone" : true,
      "timeUTC" : "2023-06-22T08:25:39+00:00",
      "rulesSource" : "default",
      "rulesVersion" : "5.44",
      "managerCapabilities" : [ "instance_multiplier", "derived_product", "vcpu", "cert_v3", "hypervisors_heartbeat", "remove_by_pool_id", "syspurpose", "storage_band", "cores", "multi_environment", "hypervisors_async", "org_level_content_access", "guest_limit", "ram", "batch_bind" ],
      "keycloakRealm" : null,
      "keycloakAuthUrl" : null,
      "keycloakResource" : null,
      "deviceAuthRealm" : null,
      "deviceAuthUrl" : null,
      "deviceAuthClientId" : null,
      "deviceAuthScope" : null
    }
     
    401 {'x-candlepin-request-uuid': 'bd3bc901-55aa-4f67-b4c7-ae3091eeb8be', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:38 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "bd3bc901-55aa-4f67-b4c7-ae3091eeb8be"
    }
     
    401 {'x-candlepin-request-uuid': '7321a87b-e525-44b0-adcf-65718ff02a41', 'WWW-Authenticate': 'Basic Realm=candlepin', 'X-Version': '4.3.6-1', 'vary': 'accept-encoding', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 08:25:39 GMT', 'Keep-Alive': 'timeout=60', 'Connection': 'keep-alive'}
    {
      "displayMessage" : "Invalid Credentials",
      "requestUuid" : "7321a87b-e525-44b0-adcf-65718ff02a41"
    }
     
    System Purpose Status: Not Specified