Metadata fetched twice if cache invalid and BOOT event enabled
Any datasource that doesn't override check_instance_id will have cache invalidated every boot. This causes cloud-init to fetch IMDS data every boot. Any datasource whose default_update_events include EventType.BOOT will also fetch IMDS data every boot.
If both conditions are true for a datasource, the datasource will fetch IMDS data twice every boot. We should instead ensure that it is only fetched once.
We should also consider if we can have a better default implementation of check_instance_id. There's a bit of a chicken and egg problem in that we don't know for sure if cache should be invalidated until we get a new instance id, but we often can't know the instance id without querying the IMDS. check_instance_id allows us to define an IMDS-less way of checking this, but for datasources that can't rely on a local machine id, invalidating the entire cache every boot is a fairly heavy hammer.
Tracking this on Jira https://warthogs.atlassian.net/browse/SC-1775.
If this gets fixed, we should reconsider https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/2059317 to enable network updates on every boot on EC2.