Skip to content

Commit

Permalink
Fixes #19675: Restart HTTP clients when configuration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Aug 6, 2021
1 parent c8cce28 commit 19fe6d0
Show file tree
Hide file tree
Showing 20 changed files with 484 additions and 255 deletions.
140 changes: 70 additions & 70 deletions relay/sources/relayd/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions relay/sources/relayd/Cargo.toml
@@ -1,5 +1,5 @@
[package]
name = "relayd"
name = "rudder-relayd"
version = "0.0.0-dev"
authors = ["Rudder developers <dev@rudder.io>"]
edition = "2018"
Expand All @@ -9,10 +9,6 @@ homepage = "https://www.rudder.io"
repository = "https://github.com/Normation/rudder"
license = "GPL-3.0-or-later"

[[bin]]
name = "rudder-relayd"
path = "src/relayd.rs"

[[bench]]
harness = false
name = "benches"
Expand Down
3 changes: 2 additions & 1 deletion relay/sources/relayd/src/api/remote_run.rs
Expand Up @@ -278,7 +278,7 @@ impl RemoteRun {
params.insert("nodes", nodes.join(","));
}

let client = match job_config.downstream_clients.get(&id) {
let client = match job_config.downstream_clients.read().await.get(&id) {
Some(c) => c.clone(),
None => {
error!("unknown sub-relay '{}'", id);
Expand All @@ -287,6 +287,7 @@ impl RemoteRun {
};

let response = client
.client()
.post(&format!(
"https://{}:{}/rudder/relay-api/remote-run/{}",
hostname,
Expand Down
11 changes: 5 additions & 6 deletions relay/sources/relayd/src/api/shared_files.rs
Expand Up @@ -160,9 +160,8 @@ async fn put_forward(
job_config: Arc<JobConfig>,
body: Bytes,
) -> Result<StatusCode, Error> {
job_config
.upstream_client
.clone()
let client = job_config.upstream_client.read().await.client().clone();
client
.put(&format!(
"{}/{}/{}",
job_config.cfg.upstream_url(),
Expand Down Expand Up @@ -299,9 +298,9 @@ async fn head_forward(
params: SharedFilesHeadParams,
job_config: Arc<JobConfig>,
) -> Result<StatusCode, Error> {
job_config
.upstream_client
.clone()
let client = job_config.upstream_client.read().await.client().clone();

client
.head(&format!(
"{}/{}/{}",
job_config.cfg.upstream_url(),
Expand Down
12 changes: 11 additions & 1 deletion relay/sources/relayd/src/configuration/main.rs
Expand Up @@ -121,6 +121,16 @@ impl Configuration {
})
}

pub fn peer_authentication(&self) -> PeerAuthentication {
// compute actual model
if !self.output.upstream.verify_certificates {
warn!("output.upstream.verify_certificates parameter is deprecated, use general.peer_authentication instead");
PeerAuthentication::DangerousNone
} else {
self.general.peer_authentication
}
}

/// Gives current url of the upstream relay API
/// Can be removed once upstream.url is removed
pub fn upstream_url(&self) -> String {
Expand Down Expand Up @@ -175,7 +185,7 @@ pub struct GeneralConfig {
pub https_port: u16,
/// Which certificate validation model to use
#[serde(default = "GeneralConfig::default_peer_authentication")]
pub peer_authentication: PeerAuthentication,
peer_authentication: PeerAuthentication,
}

impl GeneralConfig {
Expand Down

0 comments on commit 19fe6d0

Please sign in to comment.