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

fix(storage-network): incompatible with Multus version above 4.0.0 #2247

Merged
merged 1 commit into from
Oct 26, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions datastore/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,10 +835,18 @@ func (s *DataStore) GetStorageIPFromPod(pod *corev1.Pod) string {
return pod.Status.PodIP
}

// Check if the network-status annotation exists.
status, ok := pod.Annotations[string(types.CNIAnnotationNetworkStatus)]
if !ok {
logrus.Warnf("Missing %v annotation, use %v pod IP %v", types.CNIAnnotationNetworkStatus, pod.Name, pod.Status.PodIP)
return pod.Status.PodIP
// If the network-status annotation is missing, check the deprecated annotation.
logrus.Debugf("Missing %v annotation, checking deprecated %v annotation", types.CNIAnnotationNetworkStatus, types.CNIAnnotationNetworksStatus)
status, ok = pod.Annotations[string(types.CNIAnnotationNetworksStatus)]

// If the deprecated annotation is also missing, use the pod IP.
if !ok {
logrus.Warnf("Missing %v annotation, use %v pod IP %v", types.CNIAnnotationNetworkStatus, pod.Name, pod.Status.PodIP)
return pod.Status.PodIP
}
}

nets := []types.CniNetwork{}
Expand Down
7 changes: 6 additions & 1 deletion types/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,12 @@ type CNIAnnotation string

const (
CNIAnnotationNetworks = CNIAnnotation("k8s.v1.cni.cncf.io/networks")
CNIAnnotationNetworkStatus = CNIAnnotation("k8s.v1.cni.cncf.io/networks-status")
CNIAnnotationNetworkStatus = CNIAnnotation("k8s.v1.cni.cncf.io/network-status")

// CNIAnnotationNetworksStatus is deprecated since Multus v3.6 and completely removed in v4.0.0.
// This exists to support older Multus versions.
// Ref: https://github.com/longhorn/longhorn/issues/6953
CNIAnnotationNetworksStatus = CNIAnnotation("k8s.v1.cni.cncf.io/networks-status")
)

const (
Expand Down