From 37667bf6e697666100f40da26e2474a2835f559a Mon Sep 17 00:00:00 2001 From: ecpullen Date: Tue, 16 Jan 2024 17:53:25 +0000 Subject: [PATCH] sonobuoy: Delete namespace before attempting test --- bottlerocket/agents/src/bin/k8s-workload-agent/main.rs | 10 +++++++++- .../agents/src/bin/sonobuoy-test-agent/main.rs | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bottlerocket/agents/src/bin/k8s-workload-agent/main.rs b/bottlerocket/agents/src/bin/k8s-workload-agent/main.rs index 0c8a7cf6..3eafe476 100644 --- a/bottlerocket/agents/src/bin/k8s-workload-agent/main.rs +++ b/bottlerocket/agents/src/bin/k8s-workload-agent/main.rs @@ -40,7 +40,7 @@ use bottlerocket_agents::constants::TEST_CLUSTER_KUBECONFIG_PATH; use bottlerocket_agents::error::Error; use bottlerocket_agents::workload::{delete_workload, rerun_failed_workload, run_workload}; use bottlerocket_types::agent_config::{WorkloadConfig, AWS_CREDENTIALS_SECRET_NAME}; -use log::info; +use log::{info, warn}; use std::path::PathBuf; use test_agent::{ BootstrapData, ClientError, DefaultClient, DefaultInfoClient, InfoClient, Spec, TestAgent, @@ -86,6 +86,14 @@ where .await?; info!("Stored kubeconfig in {}", TEST_CLUSTER_KUBECONFIG_PATH); + match delete_workload(TEST_CLUSTER_KUBECONFIG_PATH).await { + Ok(_) => {} + Err(e) => warn!( + "Unable to delete sonobuoy namespace. It is possible it was already deleted. {}", + e + ), + }; + run_workload( TEST_CLUSTER_KUBECONFIG_PATH, &self.config, diff --git a/bottlerocket/agents/src/bin/sonobuoy-test-agent/main.rs b/bottlerocket/agents/src/bin/sonobuoy-test-agent/main.rs index ab353ed6..bc240e70 100644 --- a/bottlerocket/agents/src/bin/sonobuoy-test-agent/main.rs +++ b/bottlerocket/agents/src/bin/sonobuoy-test-agent/main.rs @@ -39,7 +39,7 @@ use bottlerocket_agents::constants::{E2E_REPO_CONFIG_PATH, TEST_CLUSTER_KUBECONF use bottlerocket_agents::error::Error; use bottlerocket_agents::sonobuoy::{delete_sonobuoy, rerun_failed_sonobuoy, run_sonobuoy}; use bottlerocket_types::agent_config::{SonobuoyConfig, AWS_CREDENTIALS_SECRET_NAME}; -use log::{debug, info}; +use log::{debug, info, warn}; use std::path::PathBuf; use test_agent::{ BootstrapData, ClientError, DefaultClient, DefaultInfoClient, InfoClient, Spec, TestAgent, @@ -94,6 +94,14 @@ where None => None, }; + match delete_sonobuoy(TEST_CLUSTER_KUBECONFIG_PATH).await { + Ok(_) => {} + Err(e) => warn!( + "Unable to delete sonobuoy namespace. It is possible it was already deleted. {}", + e + ), + }; + run_sonobuoy( TEST_CLUSTER_KUBECONFIG_PATH, e2e_repo_config,