From 461e4c3374a2c9c45ff469a4c0de805f7cce2873 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Wed, 27 Mar 2024 14:24:45 -0500 Subject: [PATCH] feat(ec2): Fetch metadata every boot Following 7f87fa33, we'll setup networking first boot and also respond to hotplug events, but if network is modified while an instance is powered off, updates won't be visible to the instance upon next boot. This commit ensures that on ec2, networking information is fetched every boot. Salesforce case #00378972 --- cloudinit/sources/DataSourceAliYun.py | 7 +++++++ cloudinit/sources/DataSourceEc2.py | 1 + 2 files changed, 8 insertions(+) diff --git a/cloudinit/sources/DataSourceAliYun.py b/cloudinit/sources/DataSourceAliYun.py index 8db89e467cd..c7966093e27 100644 --- a/cloudinit/sources/DataSourceAliYun.py +++ b/cloudinit/sources/DataSourceAliYun.py @@ -23,6 +23,13 @@ class DataSourceAliYun(EC2.DataSourceEc2): min_metadata_version = "2016-01-01" extended_metadata_versions: List[str] = [] + default_update_events = { + EventScope.NETWORK: { + EventType.BOOT_NEW_INSTANCE, + EventType.HOTPLUG, + } + } + # Aliyun metadata server security enhanced mode overwrite @property def imdsv2_token_put_header(self): diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py index 1b49ad16525..507ade42158 100644 --- a/cloudinit/sources/DataSourceEc2.py +++ b/cloudinit/sources/DataSourceEc2.py @@ -108,6 +108,7 @@ class DataSourceEc2(sources.DataSource): default_update_events = { EventScope.NETWORK: { EventType.BOOT_NEW_INSTANCE, + EventType.BOOT, EventType.HOTPLUG, } }