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 1736865 - [cloud-init][Azure] cloud-init sometimes can't find /run/cloud-init/dhclient.hooks
Summary: [cloud-init][Azure] cloud-init sometimes can't find /run/cloud-init/dhclient....
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: cloud-init
Version: 8.1
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Eduardo Otubo
QA Contact: Yuxin Sun
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-02 08:35 UTC by Yuhui Jiang
Modified: 2022-03-03 02:29 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-02-02 07:30:08 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Yuhui Jiang 2019-08-02 08:35:32 UTC
Description of problem:
Sometimes, cloud-init executes too quickly, while cloud-init want to search endpoint address, NetworkManager hook script(/etc/NetworkManager/dispatcher.d/cloud-init-azure-hook) has not finished. So, at present, there is no /run/cloud-init/dhclient.hooks folder. So cloud-init can't get endpoint server address from lease file. Finally, cloud-init will use a defaut value as endpoint address. But, while I add time.sleep(1) into cloud-init's code, this issue will fix.

    @azure_ds_telemetry_reporter
    def _load_dhclient_json():
        dhcp_options = {}
        hooks_dir = WALinuxAgentShim._get_hooks_dir()
        time.sleep(1)
        if not os.path.exists(hooks_dir):
            LOG.debug("%s not found.", hooks_dir)
            return None
        hook_files = [os.path.join(hooks_dir, x)
                      for x in os.listdir(hooks_dir)]
        for hook_file in hook_files:
            try:
                name = os.path.basename(hook_file).replace('.json', '')
                dhcp_options[name] = json.loads(util.load_file((hook_file)))
            except ValueError:
                raise ValueError(
                    '{_file} is not valid JSON data'.format(_file=hook_file))
        return dhcp_options



Version-Release number of selected component (if applicable):
cloud-init-18.5-7.el8.noarch
RHEL-8.1

How reproducible:
30%

Steps to Reproduce:
1.Prepare a RHEL-8.1 vm and install cloud-init-18.5-7.el8.noarch(enable cloud-init services)
2.Use this vm as a template to create a new vm
3.Login the new vm to check cloud-init's log

Actual results:
Sometimes, we can get error log
================================yujiangrtfinal12================================
2019-08-01 11:19:01,853 - azure.py[INFO]: Registering with Azure...
2019-08-01 11:19:01,854 - handlers.py[DEBUG]: start: azure-ds/find_endpoint: find_endpoint
2019-08-01 11:19:01,854 - azure.py[DEBUG]: Finding Azure endpoint from networkd...
2019-08-01 11:19:01,854 - handlers.py[DEBUG]: start: azure-ds/_networkd_get_value_from_leases: _networkd_get_value_from_leases
2019-08-01 11:19:01,854 - handlers.py[DEBUG]: finish: azure-ds/_networkd_get_value_from_leases: SUCCESS: _networkd_get_value_from_leases
2019-08-01 11:19:01,854 - azure.py[DEBUG]: Finding Azure endpoint from hook json...
2019-08-01 11:19:01,854 - handlers.py[DEBUG]: start: azure-ds/_load_dhclient_json: _load_dhclient_json
2019-08-01 11:19:01,855 - util.py[DEBUG]: Read 1238 bytes from /etc/cloud/cloud.cfg
2019-08-01 11:19:01,874 - util.py[DEBUG]: Read 2057 bytes from /etc/cloud/cloud.cfg.d/05_logging.cfg
2019-08-01 11:19:01,900 - util.py[DEBUG]: loaded blob returned None, returning default.
2019-08-01 11:19:01,901 - azure.py[DEBUG]: /run/cloud-init/dhclient.hooks not found.
2019-08-01 11:19:01,902 - handlers.py[DEBUG]: finish: azure-ds/_load_dhclient_json: SUCCESS: _load_dhclient_json
2019-08-01 11:19:01,902 - handlers.py[DEBUG]: start: azure-ds/_get_value_from_dhcpoptions: _get_value_from_dhcpoptions
2019-08-01 11:19:01,902 - handlers.py[DEBUG]: finish: azure-ds/_get_value_from_dhcpoptions: SUCCESS: _get_value_from_dhcpoptions
2019-08-01 11:19:01,902 - azure.py[DEBUG]: Unable to find endpoint in dhclient logs. Falling back to check lease files
2019-08-01 11:19:01,902 - azure.py[DEBUG]: Looking for endpoint in lease file /var/lib/dhcp/dhclient.eth0.leases
2019-08-01 11:19:01,902 - handlers.py[DEBUG]: start: azure-ds/_get_value_from_leases_file: _get_value_from_leases_file
2019-08-01 11:19:01,903 - azure.py[ERROR]: Failed to read /var/lib/dhcp/dhclient.eth0.leases: [Errno 2] No such file or directory: /var/lib/dhcp/dhclient.eth0.leases
2019-08-01 11:19:01,903 - handlers.py[DEBUG]: finish: azure-ds/_get_value_from_leases_file: SUCCESS: _get_value_from_leases_file
2019-08-01 11:19:01,903 - azure.py[WARNING]: No lease found
2019-08-01 11:19:01,903 - azure.py[DEBUG]: Azure endpoint found at 168.63.129.16
2019-08-01 11:19:01,903 - handlers.py[DEBUG]: finish: azure-ds/find_endpoint: SUCCESS: find_endpoint
2019-08-01 11:19:01,904 - url_helper.py[DEBUG]: [0/11] open http://168.63.129.16/machine/?comp=goalstate with {url: http://168.63.129.16/machine/?comp=goalstate, allow_redirects: True, method: GET, timeout: 5.0, headers: {User-Agent: Cloud-Init/18.5, x-ms-agent-name: WALinuxAgent, x-ms-version: 2012-11-30}} configuration
2019-08-01 11:19:01,942 - url_helper.py[DEBUG]: Please wait 1 seconds while we wait to try again
================================================================================

Expected results:
================================yujiangrtfinal13================================
2019-08-01 11:21:52,651 - azure.py[INFO]: Registering with Azure...
2019-08-01 11:21:52,652 - handlers.py[DEBUG]: start: azure-ds/find_endpoint: find_endpoint
2019-08-01 11:21:52,652 - azure.py[DEBUG]: Finding Azure endpoint from networkd...
2019-08-01 11:21:52,652 - handlers.py[DEBUG]: start: azure-ds/_networkd_get_value_from_leases: _networkd_get_value_from_leases
2019-08-01 11:21:52,652 - handlers.py[DEBUG]: finish: azure-ds/_networkd_get_value_from_leases: SUCCESS: _networkd_get_value_from_leases
2019-08-01 11:21:52,652 - azure.py[DEBUG]: Finding Azure endpoint from hook json...
2019-08-01 11:21:52,652 - handlers.py[DEBUG]: start: azure-ds/_load_dhclient_json: _load_dhclient_json
2019-08-01 11:21:52,653 - util.py[DEBUG]: Read 1238 bytes from /etc/cloud/cloud.cfg
2019-08-01 11:21:52,682 - util.py[DEBUG]: Read 2057 bytes from /etc/cloud/cloud.cfg.d/05_logging.cfg
2019-08-01 11:21:52,696 - util.py[DEBUG]: loaded blob returned None, returning default.
2019-08-01 11:21:52,698 - util.py[DEBUG]: Read 1159 bytes from /run/cloud-init/dhclient.hooks/eth0.json
2019-08-01 11:21:52,698 - handlers.py[DEBUG]: finish: azure-ds/_load_dhclient_json: SUCCESS: _load_dhclient_json
2019-08-01 11:21:52,698 - handlers.py[DEBUG]: start: azure-ds/_get_value_from_dhcpoptions: _get_value_from_dhcpoptions
2019-08-01 11:21:52,698 - azure.py[DEBUG]: Endpoint server found in dhclient options
2019-08-01 11:21:52,699 - handlers.py[DEBUG]: finish: azure-ds/_get_value_from_dhcpoptions: SUCCESS: _get_value_from_dhcpoptions
2019-08-01 11:21:52,699 - azure.py[DEBUG]: Azure endpoint found at 168.63.129.16
2019-08-01 11:21:52,699 - handlers.py[DEBUG]: finish: azure-ds/find_endpoint: SUCCESS: find_endpoint
2019-08-01 11:21:52,699 - url_helper.py[DEBUG]: [0/11] open http://168.63.129.16/machine/?comp=goalstate with {url: http://168.63.129.16/machine/?comp=goalstate, allow_redirects: True, method: GET, timeout: 5.0, headers: {User-Agent: Cloud-Init/18.5, x-ms-agent-name: WALinuxAgent, x-ms-version: 2012-11-30}} configuration


Additional info:

Comment 3 RHEL Program Management 2021-02-02 07:30:08 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.


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