agent: Reflect AGENT_CONFIG change

AGENT_CONFIG was changed to not be a lazy type, so
we need to remove the .read().await calls on it

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
stevenhorsman 2023-07-11 20:12:50 +01:00
parent 15647a000e
commit 68a364abfa
2 changed files with 8 additions and 10 deletions

View File

@ -57,18 +57,17 @@ impl ImageService {
env::set_var("CC_IMAGE_WORK_DIR", KATA_CC_IMAGE_WORK_DIR); env::set_var("CC_IMAGE_WORK_DIR", KATA_CC_IMAGE_WORK_DIR);
let mut image_client = ImageClient::default(); let mut image_client = ImageClient::default();
let image_policy_file = &AGENT_CONFIG.read().await.image_policy_file; let image_policy_file = &AGENT_CONFIG.image_policy_file;
if !image_policy_file.is_empty() { if !image_policy_file.is_empty() {
image_client.config.file_paths.sigstore_config = image_policy_file.clone(); image_client.config.file_paths.sigstore_config = image_policy_file.clone();
} }
let simple_signing_sigstore_config = let simple_signing_sigstore_config = &AGENT_CONFIG.simple_signing_sigstore_config;
&AGENT_CONFIG.read().await.simple_signing_sigstore_config;
if !simple_signing_sigstore_config.is_empty() { if !simple_signing_sigstore_config.is_empty() {
image_client.config.file_paths.sigstore_config = simple_signing_sigstore_config.clone(); image_client.config.file_paths.sigstore_config = simple_signing_sigstore_config.clone();
} }
let image_registry_auth_file = &AGENT_CONFIG.read().await.image_registry_auth_file; let image_registry_auth_file = &AGENT_CONFIG.image_registry_auth_file;
if !image_registry_auth_file.is_empty() { if !image_registry_auth_file.is_empty() {
image_client.config.file_paths.auth_file = image_registry_auth_file.clone(); image_client.config.file_paths.auth_file = image_registry_auth_file.clone();
} }
@ -159,12 +158,12 @@ impl ImageService {
async fn pull_image(&self, req: &image::PullImageRequest) -> Result<String> { async fn pull_image(&self, req: &image::PullImageRequest) -> Result<String> {
env::set_var("OCICRYPT_KEYPROVIDER_CONFIG", OCICRYPT_CONFIG_PATH); env::set_var("OCICRYPT_KEYPROVIDER_CONFIG", OCICRYPT_CONFIG_PATH);
let https_proxy = &AGENT_CONFIG.read().await.https_proxy; let https_proxy = &AGENT_CONFIG.https_proxy;
if !https_proxy.is_empty() { if !https_proxy.is_empty() {
env::set_var("HTTPS_PROXY", https_proxy); env::set_var("HTTPS_PROXY", https_proxy);
} }
let no_proxy = &AGENT_CONFIG.read().await.no_proxy; let no_proxy = &AGENT_CONFIG.no_proxy;
if !no_proxy.is_empty() { if !no_proxy.is_empty() {
env::set_var("NO_PROXY", no_proxy); env::set_var("NO_PROXY", no_proxy);
} }
@ -179,7 +178,7 @@ impl ImageService {
return Ok(image.to_owned()); return Ok(image.to_owned());
} }
let aa_kbc_params = &AGENT_CONFIG.read().await.aa_kbc_params; let aa_kbc_params = &AGENT_CONFIG.aa_kbc_params;
if !aa_kbc_params.is_empty() { if !aa_kbc_params.is_empty() {
match self.attestation_agent_started.compare_exchange_weak( match self.attestation_agent_started.compare_exchange_weak(
false, false,
@ -200,8 +199,7 @@ impl ImageService {
self.image_client.lock().await.config.auth = !aa_kbc_params.is_empty(); self.image_client.lock().await.config.auth = !aa_kbc_params.is_empty();
// Read enable signature verification from the agent config and set it in the image_client // Read enable signature verification from the agent config and set it in the image_client
let enable_signature_verification = let enable_signature_verification = &AGENT_CONFIG.enable_signature_verification;
&AGENT_CONFIG.read().await.enable_signature_verification;
info!( info!(
sl!(), sl!(),
"enable_signature_verification set to: {}", enable_signature_verification "enable_signature_verification set to: {}", enable_signature_verification

View File

@ -229,7 +229,7 @@ impl AgentService {
let dev_major_minor = format!("{}:{}", specdev.major, specdev.minor); let dev_major_minor = format!("{}:{}", specdev.major, specdev.minor);
if specdev.path == TRUSTED_STORAGE_DEVICE { if specdev.path == TRUSTED_STORAGE_DEVICE {
let data_integrity = AGENT_CONFIG.read().await.data_integrity; let data_integrity = AGENT_CONFIG.data_integrity;
info!( info!(
sl!(), sl!(),
"trusted_store device major:min {}, enable data integrity {}", "trusted_store device major:min {}, enable data integrity {}",