5.4.2
This commit is contained in:
parent
c20c53f9ce
commit
d29bf01ece
2
.gitignore
vendored
2
.gitignore
vendored
@ -20,3 +20,5 @@
|
|||||||
/afterburn-5.3.0-vendor.tar.gz
|
/afterburn-5.3.0-vendor.tar.gz
|
||||||
/afterburn-5.4.0.crate
|
/afterburn-5.4.0.crate
|
||||||
/afterburn-5.4.0-vendor.tar.gz
|
/afterburn-5.4.0-vendor.tar.gz
|
||||||
|
/afterburn-5.4.2.crate
|
||||||
|
/afterburn-5.4.2-vendor.tar.gz
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
From f6799a3852ab6145a7bb62b2ec8bc8cd657623b1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Gilbert <bgilbert@redhat.com>
|
|
||||||
Date: Mon, 20 Mar 2023 01:08:04 -0400
|
|
||||||
Subject: [PATCH 1/6] providers/packet: use stored client for boot checkin
|
|
||||||
|
|
||||||
Store the retry::Client on the PacketProvider and use it for boot checkin
|
|
||||||
to ease testing.
|
|
||||||
---
|
|
||||||
src/providers/packet/mock_tests.rs | 7 +++++--
|
|
||||||
src/providers/packet/mod.rs | 6 +++---
|
|
||||||
2 files changed, 8 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/providers/packet/mock_tests.rs b/src/providers/packet/mock_tests.rs
|
|
||||||
index d22543ceda92..ef26be4c7759 100644
|
|
||||||
--- a/src/providers/packet/mock_tests.rs
|
|
||||||
+++ b/src/providers/packet/mock_tests.rs
|
|
||||||
@@ -3,6 +3,7 @@ use mockito::{self, Matcher};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_boot_checkin() {
|
|
||||||
+ let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
let data = packet::PacketData {
|
|
||||||
id: String::new(),
|
|
||||||
hostname: String::new(),
|
|
||||||
@@ -19,7 +20,10 @@ fn test_boot_checkin() {
|
|
||||||
error: None,
|
|
||||||
phone_home_url: mockito::server_url(),
|
|
||||||
};
|
|
||||||
- let provider = packet::PacketProvider { data };
|
|
||||||
+ let provider = packet::PacketProvider {
|
|
||||||
+ client: client.clone(),
|
|
||||||
+ data,
|
|
||||||
+ };
|
|
||||||
|
|
||||||
let mock = mockito::mock("POST", "/")
|
|
||||||
.match_header(
|
|
||||||
@@ -37,7 +41,6 @@ fn test_boot_checkin() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
packet::PacketProvider::fetch_content(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/providers/packet/mod.rs b/src/providers/packet/mod.rs
|
|
||||||
index be180a546583..98a4018581b4 100644
|
|
||||||
--- a/src/providers/packet/mod.rs
|
|
||||||
+++ b/src/providers/packet/mod.rs
|
|
||||||
@@ -90,6 +90,7 @@ struct PacketAddressInfo {
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct PacketProvider {
|
|
||||||
+ client: retry::Client,
|
|
||||||
data: PacketData,
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ impl PacketProvider {
|
|
||||||
.send()?
|
|
||||||
.ok_or_else(|| anyhow!("metadata endpoint unreachable"))?;
|
|
||||||
|
|
||||||
- Ok(Self { data })
|
|
||||||
+ Ok(Self { client, data })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
@@ -386,9 +387,8 @@ impl MetadataProvider for PacketProvider {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn boot_checkin(&self) -> Result<()> {
|
|
||||||
- let client = retry::Client::try_new()?;
|
|
||||||
let url = self.data.phone_home_url.clone();
|
|
||||||
- client.post(retry::Json, url, None).dispatch_post()?;
|
|
||||||
+ self.client.post(retry::Json, url, None).dispatch_post()?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
|||||||
From 29c4681ccdb7f8b09e4fc12bc98d184c63e1d0b4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Gilbert <bgilbert@redhat.com>
|
|
||||||
Date: Mon, 20 Mar 2023 01:33:10 -0400
|
|
||||||
Subject: [PATCH 2/6] providers/microsoft: use stored client for all fetches
|
|
||||||
|
|
||||||
Be sure to use any custom settings on the stored client.
|
|
||||||
---
|
|
||||||
src/providers/microsoft/azure/mod.rs | 8 ++++++--
|
|
||||||
src/providers/microsoft/azurestack/mod.rs | 7 ++++---
|
|
||||||
2 files changed, 10 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/providers/microsoft/azure/mod.rs b/src/providers/microsoft/azure/mod.rs
|
|
||||||
index a3582ae68be7..1d2803c797c3 100644
|
|
||||||
--- a/src/providers/microsoft/azure/mod.rs
|
|
||||||
+++ b/src/providers/microsoft/azure/mod.rs
|
|
||||||
@@ -338,7 +338,9 @@ impl Azure {
|
|
||||||
const NAME_URL: &str = "metadata/instance/compute/name?api-version=2017-08-01&format=text";
|
|
||||||
let url = format!("{}/{}", Self::metadata_endpoint(), NAME_URL);
|
|
||||||
|
|
||||||
- let name = retry::Client::try_new()?
|
|
||||||
+ let name = self
|
|
||||||
+ .client
|
|
||||||
+ .clone()
|
|
||||||
.header(
|
|
||||||
HeaderName::from_static("metadata"),
|
|
||||||
HeaderValue::from_static("true"),
|
|
||||||
@@ -354,7 +356,9 @@ impl Azure {
|
|
||||||
"metadata/instance/compute/vmSize?api-version=2017-08-01&format=text";
|
|
||||||
let url = format!("{}/{}", Self::metadata_endpoint(), VMSIZE_URL);
|
|
||||||
|
|
||||||
- let vmsize = retry::Client::try_new()?
|
|
||||||
+ let vmsize = self
|
|
||||||
+ .client
|
|
||||||
+ .clone()
|
|
||||||
.header(
|
|
||||||
HeaderName::from_static("metadata"),
|
|
||||||
HeaderValue::from_static("true"),
|
|
||||||
diff --git a/src/providers/microsoft/azurestack/mod.rs b/src/providers/microsoft/azurestack/mod.rs
|
|
||||||
index a0552fbc6a69..04974398ee40 100644
|
|
||||||
--- a/src/providers/microsoft/azurestack/mod.rs
|
|
||||||
+++ b/src/providers/microsoft/azurestack/mod.rs
|
|
||||||
@@ -168,10 +168,11 @@ impl AzureStack {
|
|
||||||
.ok_or_else(|| anyhow!("failed to get goal state: not found response"))
|
|
||||||
}
|
|
||||||
|
|
||||||
- fn fetch_identity() -> Result<InstanceMetadata> {
|
|
||||||
+ fn fetch_identity(&self) -> Result<InstanceMetadata> {
|
|
||||||
const NAME_URL: &str = "Microsoft.Compute/identity?api-version=2019-03-11";
|
|
||||||
let url = format!("{}/{}", Self::metadata_endpoint(), NAME_URL);
|
|
||||||
- retry::Client::try_new()?
|
|
||||||
+ self.client
|
|
||||||
+ .clone()
|
|
||||||
.header(
|
|
||||||
HeaderName::from_static("metadata"),
|
|
||||||
HeaderValue::from_static("true"),
|
|
||||||
@@ -306,7 +307,7 @@ impl AzureStack {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fetch_hostname(&self) -> Result<Option<String>> {
|
|
||||||
- let instance_metadata = AzureStack::fetch_identity()?;
|
|
||||||
+ let instance_metadata = self.fetch_identity()?;
|
|
||||||
Ok(Some(instance_metadata.vm_name))
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
|||||||
From 1e46b818717d250dc3e0a43a0680e919f7c1c3df Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Gilbert <bgilbert@redhat.com>
|
|
||||||
Date: Mon, 20 Mar 2023 02:32:15 -0400
|
|
||||||
Subject: [PATCH 3/6] providers/microsoft: import crate::retry
|
|
||||||
|
|
||||||
---
|
|
||||||
src/providers/microsoft/azure/mock_tests.rs | 7 ++++---
|
|
||||||
src/providers/microsoft/azurestack/mock_tests.rs | 7 ++++---
|
|
||||||
2 files changed, 8 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/providers/microsoft/azure/mock_tests.rs b/src/providers/microsoft/azure/mock_tests.rs
|
|
||||||
index 93682012554b..476555dc6368 100644
|
|
||||||
--- a/src/providers/microsoft/azure/mock_tests.rs
|
|
||||||
+++ b/src/providers/microsoft/azure/mock_tests.rs
|
|
||||||
@@ -1,4 +1,5 @@
|
|
||||||
use crate::providers::{microsoft::azure, MetadataProvider};
|
|
||||||
+use crate::retry;
|
|
||||||
use mockito::{self, Matcher};
|
|
||||||
|
|
||||||
/// Response body for goalstate (with certificates endpoint).
|
|
||||||
@@ -135,7 +136,7 @@ fn test_boot_checkin() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
+ let client = retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
azure::Azure::with_client(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ fn test_hostname() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
+ let client = retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
azure::Azure::with_client(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ fn test_vmsize() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
+ let client = retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
azure::Azure::with_client(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/providers/microsoft/azurestack/mock_tests.rs b/src/providers/microsoft/azurestack/mock_tests.rs
|
|
||||||
index 8c5a0d26399e..655908237337 100644
|
|
||||||
--- a/src/providers/microsoft/azurestack/mock_tests.rs
|
|
||||||
+++ b/src/providers/microsoft/azurestack/mock_tests.rs
|
|
||||||
@@ -1,4 +1,5 @@
|
|
||||||
use crate::providers::{microsoft::azurestack, MetadataProvider};
|
|
||||||
+use crate::retry;
|
|
||||||
use mockito::{self, Matcher};
|
|
||||||
|
|
||||||
/// Response body for goalstate (with certificates endpoint).
|
|
||||||
@@ -135,7 +136,7 @@ fn test_boot_checkin() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
+ let client = retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
azurestack::AzureStack::with_client(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -164,7 +165,7 @@ fn test_identity() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
+ let client = retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
azurestack::AzureStack::with_client(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -193,7 +194,7 @@ fn test_hostname() {
|
|
||||||
mockito::reset();
|
|
||||||
|
|
||||||
// Check error logic, but fail fast without re-trying.
|
|
||||||
- let client = crate::retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
+ let client = retry::Client::try_new().unwrap().max_retries(0);
|
|
||||||
azurestack::AzureStack::with_client(Some(client)).unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
From feda37277c361a29a67ab2549f8fe292c35429dd Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Gilbert <bgilbert@redhat.com>
|
|
||||||
Date: Sun, 19 Mar 2023 23:55:38 -0400
|
|
||||||
Subject: [PATCH 4/6] retry/client: move URL parsing into helper function
|
|
||||||
|
|
||||||
---
|
|
||||||
src/retry/client.rs | 10 +++++++---
|
|
||||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/retry/client.rs b/src/retry/client.rs
|
|
||||||
index a94c4ec7f09b..e113fe4bc69a 100644
|
|
||||||
--- a/src/retry/client.rs
|
|
||||||
+++ b/src/retry/client.rs
|
|
||||||
@@ -213,7 +213,7 @@ where
|
|
||||||
where
|
|
||||||
T: for<'de> serde::Deserialize<'de>,
|
|
||||||
{
|
|
||||||
- let url = reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")?;
|
|
||||||
+ let url = self.parse_url()?;
|
|
||||||
let mut req = blocking::Request::new(Method::GET, url);
|
|
||||||
req.headers_mut().extend(self.headers.clone().into_iter());
|
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ where
|
|
||||||
where
|
|
||||||
T: for<'de> serde::Deserialize<'de>,
|
|
||||||
{
|
|
||||||
- let url = reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")?;
|
|
||||||
+ let url = self.parse_url()?;
|
|
||||||
|
|
||||||
self.retry.clone().retry(|attempt| {
|
|
||||||
let mut builder = blocking::Client::new()
|
|
||||||
@@ -254,7 +254,7 @@ where
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dispatch_post(self) -> Result<reqwest::StatusCode> {
|
|
||||||
- let url = reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")?;
|
|
||||||
+ let url = self.parse_url()?;
|
|
||||||
|
|
||||||
self.retry.clone().retry(|attempt| {
|
|
||||||
let mut builder = blocking::Client::new()
|
|
||||||
@@ -308,6 +308,10 @@ where
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ fn parse_url(&self) -> Result<reqwest::Url> {
|
|
||||||
+ reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reqwests Request struct doesn't implement `Clone`,
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
--- afterburn-5.4.0/Cargo.toml 1970-01-01T00:00:01+00:00
|
|
||||||
+++ afterburn-5.4.0/Cargo.toml 2023-05-18T13:18:10.533797+00:00
|
|
||||||
@@ -132,4 +132,4 @@
|
|
||||||
version = ">= 2.3, < 4"
|
|
||||||
|
|
||||||
[dev-dependencies.mockito]
|
|
||||||
-version = ">= 0.29, < 0.32"
|
|
||||||
+version = "1"
|
|
@ -6,8 +6,8 @@
|
|||||||
%global crate afterburn
|
%global crate afterburn
|
||||||
|
|
||||||
Name: rust-afterburn
|
Name: rust-afterburn
|
||||||
Version: 5.4.0
|
Version: 5.4.2
|
||||||
Release: 4%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Simple cloud provider agent
|
Summary: Simple cloud provider agent
|
||||||
|
|
||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
@ -15,18 +15,6 @@ URL: https://crates.io/crates/afterburn
|
|||||||
Source0: %{crates_source}
|
Source0: %{crates_source}
|
||||||
# not used on Fedora
|
# not used on Fedora
|
||||||
Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz
|
Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz
|
||||||
# Manually created patch for downstream crate metadata changes
|
|
||||||
# * bump mockito dev-dependency to v1
|
|
||||||
Patch: afterburn-fix-metadata.diff
|
|
||||||
|
|
||||||
# Use rust-mockito 1.0 API
|
|
||||||
# Based on https://github.com/coreos/afterburn/pull/894, fixing merge conflicts
|
|
||||||
Patch: 0001-providers-packet-use-stored-client-for-boot-checkin.patch
|
|
||||||
Patch: 0002-providers-microsoft-use-stored-client-for-all-fetche.patch
|
|
||||||
Patch: 0003-providers-microsoft-import-crate-retry.patch
|
|
||||||
Patch: 0004-retry-client-move-URL-parsing-into-helper-function.patch
|
|
||||||
Patch: 0005-providers-move-endpoint-mocking-into-retry-Client.patch
|
|
||||||
Patch: 0006-Update-mockito-to-1.0.patch
|
|
||||||
|
|
||||||
%if 0%{?rhel} && !0%{?eln}
|
%if 0%{?rhel} && !0%{?eln}
|
||||||
BuildRequires: rust-toolset
|
BuildRequires: rust-toolset
|
||||||
@ -163,6 +151,9 @@ cp -a dracut/* %{buildroot}%{dracutmodulesdir}
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon May 22 2023 Steven Presti <spresti@redhat.com> - 5.4.2-1
|
||||||
|
- Update to 5.4.2
|
||||||
|
|
||||||
* Fri May 19 2023 Fabio Valentini <decathorpe@gmail.com> - 5.4.0-4
|
* Fri May 19 2023 Fabio Valentini <decathorpe@gmail.com> - 5.4.0-4
|
||||||
- Refresh for latest Rust package template; update license tag for SPDX
|
- Refresh for latest Rust package template; update license tag for SPDX
|
||||||
|
|
||||||
|
4
sources
4
sources
@ -1,2 +1,2 @@
|
|||||||
SHA512 (afterburn-5.4.0.crate) = 9d310c8dace47ecb9cad77bfd5b6507f668758ebdbb18ba4f52a8574cec72052cddd6c8be52256a0c4117d37b619776f2b94feed6d35e46abd25cd7d67ac5033
|
SHA512 (afterburn-5.4.2.crate) = 8facf3e620ff0f835e605cd309bce36a536c4afb4e94dd005fc9af7611cbea22f2557e2f64bea9dedfa2ebf8ea30bff5d57a8ca316c37b4e171d10f28f78cf6a
|
||||||
SHA512 (afterburn-5.4.0-vendor.tar.gz) = 4f0c8b4fa21abfe2fdeb2194e79ccc22b1326f9d802865df53e3b4ffd5c54a35476324fd4fd640b40517ee616d260247f5288691c28b7eca456e5fedcc14bd83
|
SHA512 (afterburn-5.4.2-vendor.tar.gz) = 86d327c9b2de0b4987643d00b100197fbbbe259cc6dec6015b5878f607049a86b66825460890725d3216633e046aea6ac3bdf7daa4ef72c2fb7b7f0fed52d578
|
||||||
|
Loading…
Reference in New Issue
Block a user