From 6f0e881847822223fb96925b229322120772fa94 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Thu, 20 Jan 2022 17:46:49 -0500 Subject: sources/azure: drop unused case in _report_failure() (#1200) According to the documentation in the tests: ``` We expect 3 calls to report_failure_to_fabric, because we try 3 different methods of calling report failure. The different methods are attempted in the following order: 1. Using cached ephemeral dhcp context to report failure to Azure 2. Using new ephemeral dhcp to report failure to Azure 3. Using fallback lease to report failure to Azure ``` Case 1 and 2 make sense. If networking is established, use it. Should failure occur using current network configuration, retry with fresh DHCP. Case 3 suggests that we can fall back to a lease file and retry. Given that: 1. The wireserver address has never changed to date. 2. The wireserver address should be in the DHCP lease. 3. Parsing the lease file does not improve connectivity over the prior attempts. ...we can safely remove this case without regression. Signed-off-by: Chris Patterson --- cloudinit/sources/DataSourceAzure.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index 81ab88a9..4e88c22b 100755 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -14,6 +14,7 @@ from collections import namedtuple from enum import Enum from functools import partial from time import sleep, time +from typing import Optional from xml.dom import minidom import requests @@ -1315,7 +1316,7 @@ class DataSourceAzure(sources.DataSource): return return_val @azure_ds_telemetry_reporter - def _report_failure(self, description=None) -> bool: + def _report_failure(self, description: Optional[str] = None) -> bool: """Tells the Azure fabric that provisioning has failed. @param description: A description of the error encountered. @@ -1364,21 +1365,6 @@ class DataSourceAzure(sources.DataSource): logger_func=LOG.debug, ) - try: - report_diagnostic_event( - "Using fallback lease to report failure to Azure" - ) - report_failure_to_fabric( - fallback_lease_file=self.dhclient_lease_file, - description=description, - ) - return True - except Exception as e: - report_diagnostic_event( - "Failed to report failure using fallback lease: %s" % e, - logger_func=LOG.debug, - ) - return False def _report_ready(self, lease: dict) -> bool: -- cgit v1.2.3