This commit is contained in:
Benjamin Gilbert 2023-02-03 15:12:23 -05:00
parent ba99fe3acc
commit 25e1eb391b
4 changed files with 9 additions and 78 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@
/afterburn-5.2.0-vendor.tar.gz
/afterburn-5.3.0.crate
/afterburn-5.3.0-vendor.tar.gz
/afterburn-5.4.0.crate
/afterburn-5.4.0-vendor.tar.gz

View File

@ -1,72 +0,0 @@
From ba87d66582f4a3a5b25dcd1f810c477ad27feb87 Mon Sep 17 00:00:00 2001
From: Abhinav Dahiya <adahiya@lyft.com>
Date: Mon, 9 May 2022 09:42:56 -0700
Subject: [PATCH] providers/aws: expose instance availability-zone-id as
AWS_AVAILABILITY_ZONE_ID
ec2 instance metadata exposes the physical id for availability zone. Physical zone ids are useful
because they are same across AWS accounts and helpful when trying to decide if instances are actually
in the same zone when reconciling that between instances in different accounts.
See doc:
> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
```
placement/availability-zone-id The static Availability Zone ID in which the instance is launched. The Availability Zone ID is consistent across accounts. However, it might be different from the Availability Zone, which can vary by account. 2020-08-24
```
This is available in api versions starting 2020-08-24, and afterbun already uses 2021-01-03 [1].
[1]: https://github.com/coreos/afterburn/blob/640ce9790c4f2d56aa75d1e3ad63f8011bec4255/src/providers/aws/mod.rs#L83
---
src/providers/aws/mock_tests.rs | 3 +++
src/providers/aws/mod.rs | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/src/providers/aws/mock_tests.rs b/src/providers/aws/mock_tests.rs
index fc8d3c0..97bcfc5 100644
--- a/src/providers/aws/mock_tests.rs
+++ b/src/providers/aws/mock_tests.rs
@@ -48,6 +48,7 @@ fn aws_get_maps() -> (
let ipv4_public = "test-ipv4-public";
let ipv6 = "test-ipv6";
let availability_zone = "test-availability-zone";
+ let availability_zone_id = "test-availability-zone-id";
let hostname = "test-hostname";
let public_hostname = "test-public-hostname";
let instance_id_doc = r#"{"region": "test-region"}"#;
@@ -61,6 +62,7 @@ fn aws_get_maps() -> (
"/meta-data/public-ipv4" => ipv4_public,
"/meta-data/ipv6" => ipv6,
"/meta-data/placement/availability-zone" => availability_zone,
+ "/meta-data/placement/availability-zone-id" => availability_zone_id,
"/meta-data/hostname" => hostname,
"/meta-data/public-hostname" => public_hostname,
"/dynamic/instance-identity/document" => instance_id_doc,
@@ -72,6 +74,7 @@ fn aws_get_maps() -> (
"AWS_IPV4_PUBLIC".to_string() => ipv4_public.to_string(),
"AWS_IPV6".to_string() => ipv6.to_string(),
"AWS_AVAILABILITY_ZONE".to_string() => availability_zone.to_string(),
+ "AWS_AVAILABILITY_ZONE_ID".to_string() => availability_zone_id.to_string(),
"AWS_HOSTNAME".to_string() => hostname.to_string(),
"AWS_PUBLIC_HOSTNAME".to_string() => public_hostname.to_string(),
"AWS_REGION".to_string() => region.to_string(),
diff --git a/src/providers/aws/mod.rs b/src/providers/aws/mod.rs
index 3ced742..60e78be 100644
--- a/src/providers/aws/mod.rs
+++ b/src/providers/aws/mod.rs
@@ -169,6 +169,11 @@ impl MetadataProvider for AwsProvider {
"AWS_AVAILABILITY_ZONE",
"meta-data/placement/availability-zone",
)?;
+ add_value(
+ &mut out,
+ "AWS_AVAILABILITY_ZONE_ID",
+ "meta-data/placement/availability-zone-id",
+ )?;
add_value(&mut out, "AWS_HOSTNAME", "meta-data/hostname")?;
add_value(&mut out, "AWS_PUBLIC_HOSTNAME", "meta-data/public-hostname")?;
--
2.35.1

View File

@ -7,8 +7,8 @@
%global crate afterburn
Name: rust-%{crate}
Version: 5.3.0
Release: 4%{?dist}
Version: 5.4.0
Release: 1%{?dist}
Summary: Simple cloud provider agent
# Upstream license specification: Apache-2.0
@ -17,8 +17,6 @@ URL: https://crates.io/crates/afterburn
Source0: %{crates_source}
# not used on Fedora
Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz
# https://github.com/coreos/afterburn/pull/748
Patch0: 0001-providers-aws-expose-instance-availability-zone-id-a.patch
ExclusiveArch: %{rust_arches}
%if 0%{?rhel} && !0%{?eln}
@ -145,6 +143,9 @@ cp -a dracut/* %{buildroot}%{dracutmodulesdir}
%endif
%changelog
* Fri Feb 03 2023 Benjamin Gilbert <bgilbert@redhat.com> - 5.4.0-1
- Update to 5.4.0
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

View File

@ -1,2 +1,2 @@
SHA512 (afterburn-5.3.0.crate) = 1e110cda36d2258cbde27b8cd151b98b99e0877bdf6aa04d8706c139d4acc3d2405670b940cf3b63389213676f5a3b79ad36988e0090b282cf643cd7df050354
SHA512 (afterburn-5.3.0-vendor.tar.gz) = 3ff99b18240b592f79fcf9226c1d6994d36e5aeabce442fc053d9ac270ab63e93803b2908ad5ed8de84cdda62b839bd884417d4b65aa64a4793caeaa62cb48f7
SHA512 (afterburn-5.4.0.crate) = 9d310c8dace47ecb9cad77bfd5b6507f668758ebdbb18ba4f52a8574cec72052cddd6c8be52256a0c4117d37b619776f2b94feed6d35e46abd25cd7d67ac5033
SHA512 (afterburn-5.4.0-vendor.tar.gz) = 4f0c8b4fa21abfe2fdeb2194e79ccc22b1326f9d802865df53e3b4ffd5c54a35476324fd4fd640b40517ee616d260247f5288691c28b7eca456e5fedcc14bd83