RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2058431 - cloud_what is wrongly detecting hosts running on hyper-V (on-premise) as running on Azure
Summary: cloud_what is wrongly detecting hosts running on hyper-V (on-premise) as runn...
Keywords:
Status: CLOSED DUPLICATE of bug 2057053
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: candlepin-bugs
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-02-24 22:18 UTC by Joniel Pasqualetto
Modified: 2022-07-25 13:18 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-01 15:10:24 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-113745 0 None None None 2022-02-24 22:19:16 UTC

Description Joniel Pasqualetto 2022-02-24 22:18:46 UTC
Description of problem:

RHEL 8 running as VM on Hyper-V is being detected as running o Azure using heuristics.

The problem is that, using the current criteria, any host running on hyper-V will be detect as such.

The conditions being triggered are:

0.3 points here (virt.host_type is hyper-v) -> https://github.com/candlepin/subscription-manager/blob/8008cd771ae608e81af138b2273fdf0271755da1/src/cloud_what/providers/azure.py#L107-L110

~~~  
 # We know that Azure uses only HyperV
        if 'virt.host_type' in self.hw_info:
            if 'hyperv' in self.hw_info['virt.host_type']:
                probability += 0.3
~~~

More 0.3 points here (will find Microsoft on dmidecode if it runs on hyper-V) -> https://github.com/candlepin/subscription-manager/blob/8008cd771ae608e81af138b2273fdf0271755da1/src/cloud_what/providers/azure.py#L116-L129

~~~
        # Try to find "Azure" or "Microsoft" keywords in output of dmidecode
        found_microsoft = False
        found_azure = False
        for hw_item in self.hw_info.values():
            if type(hw_item) != str:
                continue
            if 'microsoft' in hw_item.lower():
                found_microsoft = True
            elif 'azure' in hw_item.lower():
                found_azure = True
        if found_microsoft is True:
            probability += 0.3
        if found_azure is True:
            probability += 0.1
~~~

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


How reproducible:
Always

Steps to Reproduce:
1. Install RHEL8 + subscription-manager-1.28.21-3.el8.x86_64 on a VM running over hyper-V
2. Enable debug logging on subscription-manager

subscription-manager config  --logging.default_log_level=DEBUG

3. Load facts:

subscription-manager facts


4. Look at /var/log/rhsm/rhsm.log 

2022-02-24 17:09:51,504 [DEBUG] subscription-manager:10827:MainThread @provider.py:83 - Trying to detect cloud provider
2022-02-24 17:09:51,504 [DEBUG] subscription-manager:10827:MainThread @provider.py:101 - No cloud provider detected using strong signs
2022-02-24 17:09:51,504 [DEBUG] subscription-manager:10827:MainThread @provider.py:116 - Cloud provider aws has probability: 0.3
2022-02-24 17:09:51,505 [DEBUG] subscription-manager:10827:MainThread @provider.py:116 - Cloud provider azure has probability: 0.6
2022-02-24 17:09:51,505 [DEBUG] subscription-manager:10827:MainThread @provider.py:116 - Cloud provider gcp has probability: 0.3
2022-02-24 17:09:51,505 [DEBUG] subscription-manager:10827:MainThread @provider.py:128 - Following cloud providers detected using heuristics: azure


Actual results:
cloud provider is detected and tries to query http://169.254.169.254, resulting in timeouts for the client:


~~~
2022-02-16 05:07:23,355 [ERROR] rhsmcertd-worker:333640:MainThread @base_action_client.py:73 - HTTPConnectionPool(host='169.254.169.254', port=80): Read timed out. (read timeout=10.0)
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib64/python3.6/http/client.py", line 1361, in getresponse
    response.begin()
  File "/usr/lib64/python3.6/http/client.py", line 311, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.6/http/client.py", line 272, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib64/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 693, in reraise
    raise value
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 306, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='169.254.169.254', port=80): Read timed out. (read timeout=10.0)
~~~

Expected results:

Host would not be detected as running on a cloud provider when it's not.

Additional info:

Comment 2 Pino Toscano 2022-03-01 15:10:24 UTC
Hi Joniel,

coincidentally, this was already reported as bz by Jiri Hnidek (of the sub-man team) that noticed the problem in other circumstances.
This is bug 2057053, so I'm closing this one as duplicate of it.

Thanks!

*** This bug has been marked as a duplicate of bug 2057053 ***


Note You need to log in before you can comment on or make changes to this bug.