|
| 1 | +From e69a88745e37061e0ab0a1e67ad11015cca610c1 Mon Sep 17 00:00:00 2001 |
| 2 | +From: James Falcon < [email protected]> |
| 3 | +Date: Fri, 3 Sep 2021 12:57:20 -0500 |
| 4 | +Subject: [PATCH] Set Azure to only update metadata on BOOT_NEW_INSTANCE |
| 5 | + (#1006) |
| 6 | + |
| 7 | +In #834, we refactored the handling of events for fetching new metadata. |
| 8 | +Previously, in Azure's __init__, the BOOT event was added to the |
| 9 | +update_events, so it was assumed that Azure required the standard BOOT |
| 10 | +behavior, which is to apply metadata twice every boot: once during |
| 11 | +local-init, then again during standard init phase. |
| 12 | +https://github.com/canonical/cloud-init/blob/21.2/cloudinit/sources/DataSourceAzure.py#L356 |
| 13 | + |
| 14 | +However, this line was effectively meaningless. After the metadata was |
| 15 | +fetched in local-init, it was then pickled out to disk. Because |
| 16 | +"update_events" was a class variable, the EventType.BOOT was not |
| 17 | +persisted into the pickle. When the pickle was then unpickled in the |
| 18 | +init phase, metadata did not get re-fetched because EventType.BOOT was |
| 19 | +not present, so Azure is effectely only BOOT_NEW_INSTANCE. |
| 20 | + |
| 21 | +Fetching metadata twice during boot causes some issue for |
| 22 | +pre-provisioning on Azure because updating metadata during |
| 23 | +re-provisioning will cause cloud-init to poll for reprovisiondata again |
| 24 | +in DataSourceAzure, which will infinitely return 404(reprovisiondata |
| 25 | +is deleted from IMDS after health signal was sent by cloud-init during |
| 26 | +init-local). This makes cloud-init stuck in 'init' |
| 27 | + |
| 28 | +Signed-off-by: Henry Beberman < [email protected]> |
| 29 | + |
| 30 | +--- |
| 31 | + cloudinit/sources/DataSourceAzure.py | 9 +-------- |
| 32 | + 1 file changed, 1 insertion(+), 8 deletions(-) |
| 33 | + |
| 34 | +diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py |
| 35 | +index caffa944f3..3fb564c8dd 100755 |
| 36 | +--- a/cloudinit/sources/DataSourceAzure.py |
| 37 | ++++ b/cloudinit/sources/DataSourceAzure.py |
| 38 | +@@ -22,7 +22,7 @@ |
| 39 | + from cloudinit import dmi |
| 40 | + from cloudinit import log as logging |
| 41 | + from cloudinit import net |
| 42 | +-from cloudinit.event import EventScope, EventType |
| 43 | ++from cloudinit.event import EventType |
| 44 | + from cloudinit.net import device_driver |
| 45 | + from cloudinit.net.dhcp import EphemeralDHCPv4 |
| 46 | + from cloudinit import sources |
| 47 | +@@ -339,13 +339,6 @@ def temporary_hostname(temp_hostname, cfg, hostname_command='hostname'): |
| 48 | + class DataSourceAzure(sources.DataSource): |
| 49 | + |
| 50 | + dsname = 'Azure' |
| 51 | +- # Regenerate network config new_instance boot and every boot |
| 52 | +- default_update_events = {EventScope.NETWORK: { |
| 53 | +- EventType.BOOT_NEW_INSTANCE, |
| 54 | +- EventType.BOOT, |
| 55 | +- EventType.BOOT_LEGACY |
| 56 | +- }} |
| 57 | +- |
| 58 | + _negotiated = False |
| 59 | + _metadata_imds = sources.UNSET |
| 60 | + _ci_pkl_version = 1 |
0 commit comments