Skip to content

Commit

Permalink
sonobuoy: Delete namespace before attempting test
Browse files Browse the repository at this point in the history
  • Loading branch information
ecpullen committed Jan 16, 2024
1 parent fad39d2 commit 37667bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bottlerocket/agents/src/bin/k8s-workload-agent/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion bottlerocket/agents/src/bin/sonobuoy-test-agent/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 37667bf

Please sign in to comment.