Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature #369 add steps to Cleanup on bootstrap fail #705

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/krustlet-wasi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use k8s_openapi::api::certificates::v1::CertificateSigningRequest;
use kube::{
api::{Api, DeleteParams},
Client,
};
use kubelet::config::Config;
use kubelet::plugin_watcher::PluginRegistry;
use kubelet::resources::DeviceManager;
Expand All @@ -20,7 +25,20 @@ async fn main() -> anyhow::Result<()> {
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();

let kubeconfig = kubelet::bootstrap(&config, &config.bootstrap_file, notify_bootstrap).await?;
let kubeconfig =
match kubelet::bootstrap(&config, &config.bootstrap_file, notify_bootstrap).await {
Ok(it) => it,
Err(err) => {
let client = Client::try_default().await?;
let csrs: Api<CertificateSigningRequest> = Api::all(client);
let csr_name = format!("{}-tls", config.node_name);
csrs.delete(&csr_name, &DeleteParams::default())
.await?
.map_left(|o| println!("Deleting CSR : {:?}", o.status))
.map_right(|s| println!("Deleted CSR : {:?}", s));
return Err(anyhow::anyhow!("{}", err));
}
};

let store = make_store(&config);
let plugin_registry = Arc::new(PluginRegistry::new(&config.plugins_dir));
Expand Down