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

handle cases where pod has ipv6 #2791

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog.d/2788.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle cases where pod has IPv6
9 changes: 8 additions & 1 deletion mirrord/kube/src/api/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ impl KubernetesAPI {
let pod_ips = runtime_data
.as_ref()
.filter(|runtime_data| !runtime_data.pod_ips.is_empty())
.map(|runtime_data| runtime_data.pod_ips.join(","));
aviramha marked this conversation as resolved.
Show resolved Hide resolved
.map(|runtime_data| {
runtime_data
.pod_ips
.iter()
.map(|ip| ip.to_string())
.collect::<Vec<_>>()
.join(",")
});

let params = ContainerParams::new(tls_cert, pod_ips);

Expand Down
12 changes: 10 additions & 2 deletions mirrord/kube/src/api/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{
collections::BTreeMap,
convert::Infallible,
fmt::{self, Display, Formatter},
net::Ipv4Addr,
ops::FromResidual,
str::FromStr,
};
Expand Down Expand Up @@ -70,7 +71,7 @@ impl Display for ContainerRuntime {
#[derive(Debug)]
pub struct RuntimeData {
pub pod_name: String,
pub pod_ips: Vec<String>,
pub pod_ips: Vec<Ipv4Addr>,
pub pod_namespace: Option<String>,
pub node_name: String,
pub container_id: String,
Expand Down Expand Up @@ -125,7 +126,14 @@ impl RuntimeData {
.ok_or_else(|| KubeApiError::missing_field(pod, ".status.podIPs"))?
.iter()
.filter_map(|pod_ip| pod_ip.ip.as_ref())
.cloned()
.filter_map(|pod_ip| {
pod_ip
.parse::<Ipv4Addr>()
.inspect_err(|e| {
tracing::warn!("failed to parse pod IP {pod_ip}: {e:?}");
})
.ok()
})
.collect();

let container_statuses = pod
Expand Down
Loading