-
Notifications
You must be signed in to change notification settings - Fork 36
feat(rkl): Add the container probe functionality. #249
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ use std::{env, fs, net::SocketAddr, path::Path, sync::Arc, time::Duration}; | |
| use tokio::time; | ||
|
|
||
| use crate::commands::pod; | ||
| use crate::daemon::probe::{build_probe_registrations, deregister_pod_probes, register_pod_probes}; | ||
| use crate::network::receiver::{NetworkConfigMessage, NetworkReceiver}; | ||
| use crate::task::TaskRunner; | ||
| use chrono::Utc; | ||
|
|
@@ -22,6 +23,7 @@ use rustls::crypto::CryptoProvider; | |
| use rustls::pki_types::{CertificateDer, ServerName, UnixTime}; | ||
| use rustls::{ClientConfig as RustlsClientConfig, RootCertStore, SignatureScheme}; | ||
| use std::collections::HashMap; | ||
| use tracing::info; | ||
|
|
||
| use sysinfo::{Disks, System}; | ||
|
|
||
|
|
@@ -333,10 +335,37 @@ pub async fn run_once( | |
| }; | ||
|
|
||
| match pod::run_pod_from_taskrunner(runner) { | ||
| Ok(podip) => { | ||
| Ok(result) => { | ||
| let pod_name = result.pod_task.metadata.name.clone(); | ||
|
|
||
| match build_probe_registrations( | ||
| &result.pod_task, | ||
| &result.pod_ip, | ||
| ) { | ||
| Ok(registrations) => { | ||
| if let Err(err) = | ||
| register_pod_probes(&pod_name, registrations) | ||
| { | ||
| eprintln!( | ||
| "[worker] registering probes for pod {} failed: {err:?}", | ||
| pod_name | ||
| ); | ||
|
Comment on lines
+349
to
+352
|
||
| } | ||
| } | ||
| Err(err) => { | ||
| eprintln!( | ||
| "[worker] building probe registrations for pod {} failed: {err:?}", | ||
| pod_name | ||
| ); | ||
|
Comment on lines
+356
to
+359
|
||
| } | ||
| } | ||
|
|
||
| let _ = send_uni( | ||
| &connection, | ||
| &RksMessage::SetPodip((pod.metadata.name.clone(), podip)), | ||
| &RksMessage::SetPodip(( | ||
| pod.metadata.name.clone(), | ||
| result.pod_ip.clone(), | ||
| )), | ||
| ) | ||
| .await; | ||
| } | ||
|
|
@@ -357,6 +386,15 @@ pub async fn run_once( | |
| println!("[worker] DeletePod {name}"); | ||
| match pod::standalone::delete_pod(&name) { | ||
| Ok(_) => { | ||
| // Ensure probe deregistration completes before sending the Ack. | ||
| // Previously this was spawned as a detached task which could | ||
| // panic or fail silently. Awaiting here surfaces errors and | ||
| // ensures cleanup has finished when the controller receives | ||
| // the acknowledgement. | ||
| info!(pod = %name, "deregistering probes for pod"); | ||
| deregister_pod_probes(&name).await; | ||
| info!(pod = %name, "probes deregistered for pod"); | ||
|
|
||
| let _ = send_uni(&connection, &RksMessage::Ack).await; | ||
| } | ||
| Err(e) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
pod_sandbox_idandcontainer_namesfields are marked with#[allow(unused)]. Since this is a public API, consider removing these fields if they are truly unused, or remove the attribute if they will be used in the future. Keeping unused public fields in a struct makes the API unclear.