Skip to content

Commit

Permalink
Add warning when using openshift (#1654)
Browse files Browse the repository at this point in the history
* Add warning when using openshift

* warnings

* imports

* using the warning kind

* Changelog

* imports

* lint

* .

* Merge main and fix

* CR

* Result

* Update Links

* CR

* /

* lint
  • Loading branch information
infiniteregrets authored Aug 18, 2023
1 parent 35e47bd commit cdc87c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1560.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Detect and warn when cluster is openshift
5 changes: 5 additions & 0 deletions mirrord/cli/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ where
.await
.map_err(CliError::KubernetesApiFailed)?;

let mut detect_openshift_task = progress.subtask("detecting OpenShift...");
if (k8s_api.detect_openshift(&mut detect_openshift_task).await).is_err() {
detect_openshift_task.warning("couldn't determine OpenShift");
};

let (pod_agent_name, agent_port) = tokio::time::timeout(
Duration::from_secs(config.agent.startup_timeout),
k8s_api.create_agent(progress),
Expand Down
18 changes: 17 additions & 1 deletion mirrord/kube/src/api/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{net::SocketAddr, time::Duration};
use k8s_openapi::api::core::v1::Pod;
use kube::{
config::{KubeConfigOptions, Kubeconfig},
Api, Client, Config,
Api, Client, Config, Discovery,
};
use mirrord_config::{agent::AgentConfig, target::TargetConfig, LayerConfig};
use mirrord_progress::Progress;
Expand Down Expand Up @@ -57,6 +57,22 @@ impl KubernetesAPI {
target,
}
}

pub async fn detect_openshift<P>(&self, progress: &mut P) -> Result<()>
where
P: Progress + Send + Sync,
{
if Discovery::new(self.client.clone())
.run()
.await?
.has_group("route.openshift.io")
{
progress.warning("mirrord has detected it's running on OpenShift. Due to the default PSP of OpenShift, mirrord may not be able to create the agent. Please refer to the documentation at https://mirrord.dev/docs/overview/faq/#can-i-use-mirrord-with-openshift");
} else {
progress.success(Some("OpenShift was not detected."))
}
Ok(())
}
}

impl AgentManagment for KubernetesAPI {
Expand Down

0 comments on commit cdc87c9

Please sign in to comment.