mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-13 07:04:58 +00:00
Merge pull request #5439 from jodh-intel/kata-ctl-s390x-disable-tls
kata-ctl: Disable network check on s390x
This commit is contained in:
commit
dd60a0298d
@ -12,9 +12,12 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.31"
|
anyhow = "1.0.31"
|
||||||
clap = { version = "3.2.20", features = ["derive", "cargo"] }
|
clap = { version = "3.2.20", features = ["derive", "cargo"] }
|
||||||
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
|
|
||||||
serde_json = "1.0.85"
|
serde_json = "1.0.85"
|
||||||
thiserror = "1.0.35"
|
thiserror = "1.0.35"
|
||||||
|
|
||||||
|
# See: https://github.com/kata-containers/kata-containers/issues/5438
|
||||||
|
[target.'cfg(not(target_arch = "s390x"))'.dependencies]
|
||||||
|
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
semver = "1.0.12"
|
semver = "1.0.12"
|
||||||
|
@ -7,36 +7,32 @@ use anyhow::Result;
|
|||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
pub mod aarch64;
|
pub mod aarch64;
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
pub use aarch64 as arch_specific;
|
||||||
|
|
||||||
#[cfg(target_arch = "powerpc64le")]
|
#[cfg(target_arch = "powerpc64le")]
|
||||||
pub mod powerpc64le;
|
pub mod powerpc64le;
|
||||||
|
#[cfg(target_arch = "powerpc64le")]
|
||||||
|
pub use powerpc64le as arch_specific;
|
||||||
|
|
||||||
#[cfg(target_arch = "s390x")]
|
#[cfg(target_arch = "s390x")]
|
||||||
pub mod s390x;
|
pub mod s390x;
|
||||||
|
#[cfg(target_arch = "s390x")]
|
||||||
|
pub use s390x as arch_specific;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub mod x86_64;
|
pub mod x86_64;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
pub use x86_64 as arch_specific;
|
||||||
|
|
||||||
pub fn check() -> Result<()> {
|
#[cfg(not(any(
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
let result = aarch64::check();
|
|
||||||
|
|
||||||
#[cfg(target_arch = "powerpc64le")]
|
|
||||||
let result = powerpc64le::check();
|
|
||||||
|
|
||||||
#[cfg(target_arch = "s390x")]
|
|
||||||
let result = s390x::check();
|
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
let result = x86_64::check();
|
|
||||||
|
|
||||||
#[cfg(not(any(
|
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "powerpc64le",
|
target_arch = "powerpc64le",
|
||||||
target_arch = "s390x",
|
target_arch = "s390x",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64"
|
||||||
)))]
|
)))]
|
||||||
compile_error!("unknown architecture");
|
compile_error!("unknown architecture");
|
||||||
|
|
||||||
result
|
pub fn check() -> Result<()> {
|
||||||
|
arch_specific::check()
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,19 @@
|
|||||||
// Contains checks that are not architecture-specific
|
// Contains checks that are not architecture-specific
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
// See: https://github.com/kata-containers/kata-containers/issues/5438
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
use reqwest::header::{CONTENT_TYPE, USER_AGENT};
|
use reqwest::header::{CONTENT_TYPE, USER_AGENT};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
@ -99,6 +110,11 @@ pub fn run_network_checks() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
fn get_kata_version_by_url(url: &str) -> std::result::Result<String, reqwest::Error> {
|
fn get_kata_version_by_url(url: &str) -> std::result::Result<String, reqwest::Error> {
|
||||||
let content = reqwest::blocking::Client::new()
|
let content = reqwest::blocking::Client::new()
|
||||||
.get(url)
|
.get(url)
|
||||||
@ -111,6 +127,11 @@ fn get_kata_version_by_url(url: &str) -> std::result::Result<String, reqwest::Er
|
|||||||
Ok(version.to_string())
|
Ok(version.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
fn handle_reqwest_error(e: reqwest::Error) -> anyhow::Error {
|
fn handle_reqwest_error(e: reqwest::Error) -> anyhow::Error {
|
||||||
if e.is_connect() {
|
if e.is_connect() {
|
||||||
return anyhow!(e).context("http connection failure: connection refused");
|
return anyhow!(e).context("http connection failure: connection refused");
|
||||||
@ -131,6 +152,11 @@ fn handle_reqwest_error(e: reqwest::Error) -> anyhow::Error {
|
|||||||
anyhow!(e).context("unknown http connection failure: {:?}")
|
anyhow!(e).context("unknown http connection failure: {:?}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
pub fn check_version() -> Result<()> {
|
pub fn check_version() -> Result<()> {
|
||||||
let version = get_kata_version_by_url(KATA_GITHUB_URL).map_err(handle_reqwest_error)?;
|
let version = get_kata_version_by_url(KATA_GITHUB_URL).map_err(handle_reqwest_error)?;
|
||||||
|
|
||||||
@ -164,6 +190,11 @@ mod tests {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_version_by_empty_url() {
|
fn check_version_by_empty_url() {
|
||||||
const TEST_URL: &str = "http:";
|
const TEST_URL: &str = "http:";
|
||||||
@ -172,6 +203,11 @@ mod tests {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_version_by_garbage_url() {
|
fn check_version_by_garbage_url() {
|
||||||
const TEST_URL: &str = "_localhost_";
|
const TEST_URL: &str = "_localhost_";
|
||||||
@ -180,6 +216,11 @@ mod tests {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_version_by_invalid_url() {
|
fn check_version_by_invalid_url() {
|
||||||
const TEST_URL: &str = "http://localhost :80";
|
const TEST_URL: &str = "http://localhost :80";
|
||||||
@ -188,6 +229,11 @@ mod tests {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_latest_version() {
|
fn check_latest_version() {
|
||||||
let version = get_kata_version_by_url(KATA_GITHUB_URL).unwrap();
|
let version = get_kata_version_by_url(KATA_GITHUB_URL).unwrap();
|
||||||
|
@ -32,7 +32,16 @@ pub fn handle_check(checkcmd: CheckArgument) -> Result<()> {
|
|||||||
|
|
||||||
CheckSubCommand::CheckVersionOnly => {
|
CheckSubCommand::CheckVersionOnly => {
|
||||||
// retrieve latest release
|
// retrieve latest release
|
||||||
|
#[cfg(any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "powerpc64le",
|
||||||
|
target_arch = "x86_64"
|
||||||
|
))]
|
||||||
check::check_version()?;
|
check::check_version()?;
|
||||||
|
|
||||||
|
// See: https://github.com/kata-containers/kata-containers/issues/5438
|
||||||
|
#[cfg(target_arch = "s390x")]
|
||||||
|
unimplemented!("Network check not implemented on s390x")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user