fix old svc remain after pod recreate when using ali-lb models (#165)
Signed-off-by: ChrisLiu <chrisliu1995@163.com>
This commit is contained in:
parent
ba65115f08
commit
14e281dfa9
|
|
@ -155,6 +155,12 @@ func (n *NlbPlugin) OnPodUpdated(c client.Client, pod *corev1.Pod, ctx context.C
|
|||
return pod, cperrors.NewPluginError(cperrors.ApiCallError, err.Error())
|
||||
}
|
||||
|
||||
// old svc remain
|
||||
if svc.OwnerReferences[0].Kind == "Pod" && svc.OwnerReferences[0].UID != pod.UID {
|
||||
log.Infof("[%s] waitting old svc %s/%s deleted. old owner pod uid is %s, but now is %s", NlbNetwork, svc.Namespace, svc.Name, svc.OwnerReferences[0].UID, pod.UID)
|
||||
return pod, nil
|
||||
}
|
||||
|
||||
// update svc
|
||||
if util.GetHash(sc) != svc.GetAnnotations()[SlbConfigHashKey] {
|
||||
networkStatus.CurrentNetworkState = gamekruiseiov1alpha1.NetworkNotReady
|
||||
|
|
|
|||
|
|
@ -181,6 +181,12 @@ func (s *SlbPlugin) OnPodUpdated(c client.Client, pod *corev1.Pod, ctx context.C
|
|||
return pod, cperrors.NewPluginError(cperrors.ApiCallError, err.Error())
|
||||
}
|
||||
|
||||
// old svc remain
|
||||
if svc.OwnerReferences[0].Kind == "Pod" && svc.OwnerReferences[0].UID != pod.UID {
|
||||
log.Infof("[%s] waitting old svc %s/%s deleted. old owner pod uid is %s, but now is %s", SlbNetwork, svc.Namespace, svc.Name, svc.OwnerReferences[0].UID, pod.UID)
|
||||
return pod, nil
|
||||
}
|
||||
|
||||
// update svc
|
||||
if util.GetHash(sc) != svc.GetAnnotations()[SlbConfigHashKey] {
|
||||
networkStatus.CurrentNetworkState = gamekruiseiov1alpha1.NetworkNotReady
|
||||
|
|
|
|||
|
|
@ -55,6 +55,27 @@ func TestGetHash(t *testing.T) {
|
|||
objectB: nil,
|
||||
result: true,
|
||||
},
|
||||
{
|
||||
objectA: &corev1.Pod{
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: "containerA",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
objectB: &corev1.Pod{
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: "containerB",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
|
|||
Loading…
Reference in New Issue