Skip to content

Commit 9a8fcbe

Browse files
refactor: use reqwest for cert fetcher (#1064)
* refact: Use reqwest for cert fetcher * remove unused deps
1 parent 46810ef commit 9a8fcbe

File tree

12 files changed

+85
-288
lines changed

12 files changed

+85
-288
lines changed

Cargo.lock

Lines changed: 0 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ tracing-test = "0.2.4"
2424
assert_cmd = "2.0.14"
2525
assert_fs = "1.1.1"
2626
assert_matches = "1.5.0"
27-
bollard = "0.18.1"
2827
tower-test = "0.4.0"
2928
serde_yaml = "0.9.34"
3029
schemars = "0.8.21"
3130
http = "1.2.0"
3231
mockall_double = "0.3.1"
3332
predicates = "3.1.0"
34-
hyper = "1.3.1"
3533
konst = "0.3.9"
3634
semver = "1.0.23"
3735
chrono = "0.4"

agent-control/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ ctrlc = { version = "3.4.5", features = ["termination"] }
2121
serde_yaml = { workspace = true }
2222
regex = { workspace = true }
2323
futures = { version = "0.3.31", optional = true }
24-
async-trait = { version = "0.1.83", optional = true }
2524
tokio = { version = "1.41.1", features = ["rt-multi-thread", "macros", "sync"] }
2625
console-subscriber = { version = "0.4.1", optional = true }
2726
uuid = { version = "1.8.0", features = ["serde", "v7"] }
@@ -63,19 +62,15 @@ http-serde = "2.1.1"
6362
paste = "1.0"
6463
config = { version = "0.15.7", features = ["yaml"] }
6564
rustls = { version = "0.23.18", features = ["ring"] }
66-
rustls-pemfile = { version = "2.1.3" }
67-
rustls-native-certs = "0.8.1"
6865
webpki = { version = "0.22.4", features = ["alloc"] }
6966
x509-parser = "0.17.0"
7067
ring = "0.17.8"
7168

7269
[dev-dependencies]
7370
assert_cmd = { workspace = true }
7471
assert_fs = { workspace = true }
75-
bollard = { workspace = true }
7672
predicates = { workspace = true }
7773
tower-test = { workspace = true }
78-
hyper = { workspace = true }
7974
tempfile = { workspace = true }
8075
mockall = { workspace = true }
8176
schemars = { workspace = true }
@@ -93,6 +88,7 @@ httpmock = { version = "0.8.0-alpha.1", features = ["proxy"] }
9388
serial_test = "3.1.1"
9489
futures = "0.3.30"
9590
rcgen = { version = "0.13.2", features = ["crypto"] }
91+
rustls-pemfile = { version = "2.1.3" }
9692

9793

9894
[build-dependencies]
@@ -114,7 +110,6 @@ k8s = [
114110
"dep:k8s-openapi",
115111
"dep:either",
116112
"dep:futures",
117-
"dep:async-trait",
118113
]
119114
# feature ci allows calling --all-features (needed on the test pipelines) and not failing to compile
120115
ci = []

agent-control/src/agent_control/run.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use crate::event::{
1414
use crate::http::proxy::ProxyConfig;
1515
use crate::opamp::auth::token_retriever::TokenRetrieverImpl;
1616
use crate::opamp::http::builder::OpAMPHttpClientBuilder;
17+
use crate::opamp::remote_config::validators::signature::validator::{
18+
build_signature_validator, SignatureValidator,
19+
};
1720
use std::error::Error;
1821
use std::path::PathBuf;
1922
use std::sync::Arc;
@@ -69,6 +72,7 @@ pub struct AgentControlRunner {
6972
opamp_poll_interval: Duration,
7073
agent_control_publisher: EventPublisher<AgentControlEvent>,
7174
sub_agent_publisher: EventPublisher<SubAgentEvent>,
75+
signature_validator: SignatureValidator,
7276
base_paths: BasePaths,
7377
#[cfg(feature = "k8s")]
7478
k8s_config: super::config::K8sConfig,
@@ -135,6 +139,12 @@ impl AgentControlRunner {
135139
.join(DYNAMIC_AGENT_TYPE_FILENAME),
136140
);
137141

142+
let signature_validator = config
143+
.opamp
144+
.map(|fleet_config| build_signature_validator(fleet_config.signature_validation))
145+
.transpose()?
146+
.unwrap_or(SignatureValidator::Noop);
147+
138148
Ok(AgentControlRunner {
139149
_http_server_runner,
140150
runtime,
@@ -149,6 +159,7 @@ impl AgentControlRunner {
149159
agent_control_publisher,
150160
sub_agent_publisher,
151161
base_paths: config.base_paths,
162+
signature_validator,
152163
})
153164
}
154165
}

agent-control/src/agent_control/run/k8s.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ use crate::opamp::effective_config::loader::DefaultEffectiveConfigLoaderBuilder;
1414
use crate::opamp::instance_id::getter::InstanceIDWithIdentifiersGetter;
1515
use crate::opamp::instance_id::Identifiers;
1616
use crate::opamp::operations::build_opamp_with_channel;
17-
use crate::opamp::remote_config::validators::signature::validator::{
18-
build_signature_validator, SignatureValidator,
19-
};
2017
use crate::sub_agent::effective_agents_assembler::LocalEffectiveAgentsAssembler;
2118
use crate::{
2219
agent_control::error::AgentError,
@@ -96,16 +93,6 @@ impl AgentControlRunner {
9693

9794
let hash_repository = Arc::new(HashRepositoryConfigMap::new(k8s_store.clone()));
9895

99-
let signature_validator = agent_control_config
100-
.fleet_control
101-
.map(|fleet_config| {
102-
build_signature_validator(fleet_config.signature_validation).map_err(|e| {
103-
AgentError::ExternalError(format!("initializing signature validator: {}", e))
104-
})
105-
})
106-
.transpose()?
107-
.unwrap_or(SignatureValidator::Noop);
108-
10996
info!("Creating the k8s sub_agent builder");
11097
let sub_agent_builder = K8sSubAgentBuilder::new(
11198
opamp_client_builder.as_ref(),
@@ -115,7 +102,7 @@ impl AgentControlRunner {
115102
agents_assembler,
116103
self.k8s_config.clone(),
117104
yaml_config_repository.clone(),
118-
Arc::new(signature_validator),
105+
Arc::new(self.signature_validator),
119106
);
120107

121108
let additional_identifying_attributes =

agent-control/src/agent_control/run/on_host.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ use crate::opamp::effective_config::loader::DefaultEffectiveConfigLoaderBuilder;
1414
use crate::opamp::instance_id::getter::InstanceIDWithIdentifiersGetter;
1515
use crate::opamp::instance_id::{Identifiers, Storer};
1616
use crate::opamp::operations::build_opamp_with_channel;
17-
use crate::opamp::remote_config::validators::signature::validator::{
18-
build_signature_validator, SignatureValidator,
19-
};
2017
use crate::sub_agent::effective_agents_assembler::LocalEffectiveAgentsAssembler;
2118
use crate::{agent_control::error::AgentError, opamp::client_builder::DefaultOpAMPClientBuilder};
2219
use crate::{
@@ -107,24 +104,14 @@ impl AgentControlRunner {
107104
template_renderer,
108105
));
109106

110-
let signature_validator = config
111-
.fleet_control
112-
.map(|fleet_config| {
113-
build_signature_validator(fleet_config.signature_validation).map_err(|e| {
114-
AgentError::ExternalError(format!("initializing signature validator: {}", e))
115-
})
116-
})
117-
.transpose()?
118-
.unwrap_or(SignatureValidator::Noop);
119-
120107
let sub_agent_builder = OnHostSubAgentBuilder::new(
121108
opamp_client_builder.as_ref(),
122109
&instance_id_getter,
123110
sub_agent_hash_repository,
124111
agents_assembler,
125112
self.base_paths.log_dir.join(SUB_AGENT_DIR),
126113
yaml_config_repository.clone(),
127-
Arc::new(signature_validator),
114+
Arc::new(self.signature_validator),
128115
);
129116

130117
let (maybe_client, maybe_sa_opamp_consumer) = opamp_client_builder

agent-control/src/http/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct HttpConfig {
66
pub(crate) timeout: Duration,
77
pub(crate) conn_timeout: Duration,
88
pub(crate) proxy: ProxyConfig,
9+
pub(crate) tls_info: bool,
910
}
1011

1112
impl HttpConfig {
@@ -14,6 +15,13 @@ impl HttpConfig {
1415
timeout,
1516
conn_timeout,
1617
proxy,
18+
tls_info: false,
19+
}
20+
}
21+
pub fn with_tls_info(self) -> Self {
22+
Self {
23+
tls_info: true,
24+
..self
1725
}
1826
}
1927
}

0 commit comments

Comments
 (0)