-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MGMT-16796 Added new proxy option that sets the cluster proxy to the desired configuration. Proxy editing with recert is required because its inside machineconfigs, we need to avoid a reboot
- Loading branch information
Showing
10 changed files
with
564 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
pub(crate) mod args; | ||
|
||
use crate::{config::path::ConfigPath, k8s_etcd::InMemoryK8sEtcd}; | ||
use anyhow::{Context, Result}; | ||
use std::{path::Path, sync::Arc}; | ||
|
||
use self::args::Proxy; | ||
|
||
mod etcd_rename; | ||
mod filesystem_rename; | ||
mod utils; | ||
|
||
pub(crate) async fn rename_all( | ||
etcd_client: &Arc<InMemoryK8sEtcd>, | ||
proxy: &Proxy, | ||
static_dirs: &[ConfigPath], | ||
static_files: &[ConfigPath], | ||
) -> Result<(), anyhow::Error> { | ||
fix_etcd_resources(etcd_client, proxy).await.context("renaming etcd resources")?; | ||
|
||
fix_filesystem_resources(proxy, static_dirs, static_files) | ||
.await | ||
.context("renaming filesystem resources")?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn fix_filesystem_resources(proxy: &Proxy, static_dirs: &[ConfigPath], static_files: &[ConfigPath]) -> Result<()> { | ||
for dir in static_dirs { | ||
fix_dir_resources(proxy, dir).await?; | ||
} | ||
|
||
for file in static_files { | ||
fix_file_resources(proxy, file).await?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn fix_dir_resources(proxy: &Proxy, dir: &Path) -> Result<()> { | ||
filesystem_rename::rename_proxy_env_dir(proxy, dir) | ||
.await | ||
.context("fixing etcd static pods")?; | ||
|
||
filesystem_rename::fix_filesystem_currentconfig(proxy, dir) | ||
.await | ||
.context("renaming currentconfig")?; | ||
|
||
filesystem_rename::fix_pods_yaml(proxy, dir).await.context("renaming pod yaml")?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn fix_file_resources(proxy: &Proxy, file: &Path) -> Result<()> { | ||
filesystem_rename::rename_proxy_env_file(proxy, file) | ||
.await | ||
.context("fixing etcd static pods")?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn fix_etcd_resources(etcd_client: &Arc<InMemoryK8sEtcd>, proxy: &Proxy) -> Result<()> { | ||
etcd_rename::fix_machineconfigs(etcd_client, proxy) | ||
.await | ||
.context("fixing machineconfigs")?; | ||
|
||
etcd_rename::fix_proxy(etcd_client, proxy).await.context("fixing proxy")?; | ||
|
||
etcd_rename::fix_controllerconfigs(etcd_client, proxy) | ||
.await | ||
.context("fixing machineconfigs")?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use anyhow::{ensure, Result}; | ||
|
||
#[derive(Clone, serde::Serialize)] | ||
pub(crate) struct Proxy { | ||
pub(crate) http_proxy: String, | ||
pub(crate) https_proxy: String, | ||
pub(crate) no_proxy: String, | ||
} | ||
|
||
impl Proxy { | ||
pub(crate) fn parse(value: &str) -> Result<Self> { | ||
let parts = value.split('|').collect::<Vec<_>>(); | ||
|
||
ensure!( | ||
parts.len() == 3, | ||
"expected three parts separated by '|' in proxy argument, i.e. '<http_proxy>|<cluster-base-domain>|<infra-id>', found {}", | ||
parts.len() | ||
); | ||
|
||
let http_proxy = parts[0].to_string(); | ||
let https_proxy = parts[1].to_string(); | ||
let no_proxy = parts[2].to_string(); | ||
|
||
Ok(Self { | ||
http_proxy, | ||
https_proxy, | ||
no_proxy, | ||
}) | ||
} | ||
} |
Oops, something went wrong.