mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #120375 from pegasas/proxy
Improve logging on kube-proxy exit
This commit is contained in:
commit
0ee315b94c
@ -57,7 +57,7 @@ func (n *NodePodCIDRHandler) OnNodeAdd(node *v1.Node) {
|
||||
if !reflect.DeepEqual(n.podCIDRs, podCIDRs) {
|
||||
klog.ErrorS(nil, "Using NodeCIDR LocalDetector mode, current PodCIDRs are different than previous PodCIDRs, restarting",
|
||||
"node", klog.KObj(node), "newPodCIDRs", podCIDRs, "oldPodCIDRs", n.podCIDRs)
|
||||
panic("Current Node PodCIDRs are different than previous PodCIDRs, restarting")
|
||||
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ func (n *NodePodCIDRHandler) OnNodeUpdate(_, node *v1.Node) {
|
||||
if !reflect.DeepEqual(n.podCIDRs, podCIDRs) {
|
||||
klog.ErrorS(nil, "Using NodeCIDR LocalDetector mode, current PodCIDRs are different than previous PodCIDRs, restarting",
|
||||
"node", klog.KObj(node), "newPodCIDRs", podCIDRs, "oldPODCIDRs", n.podCIDRs)
|
||||
panic("Current Node PodCIDRs are different than previous PodCIDRs, restarting")
|
||||
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,21 @@ limitations under the License.
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func TestNodePodCIDRHandlerAdd(t *testing.T) {
|
||||
oldKlogOsExit := klog.OsExit
|
||||
defer func() {
|
||||
klog.OsExit = oldKlogOsExit
|
||||
}()
|
||||
klog.OsExit = customExit
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
oldNodePodCIDRs []string
|
||||
@ -71,12 +79,19 @@ func TestNodePodCIDRHandlerAdd(t *testing.T) {
|
||||
t.Errorf("The code did panic")
|
||||
}
|
||||
}()
|
||||
|
||||
n.OnNodeAdd(node)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodePodCIDRHandlerUpdate(t *testing.T) {
|
||||
oldKlogOsExit := klog.OsExit
|
||||
defer func() {
|
||||
klog.OsExit = oldKlogOsExit
|
||||
}()
|
||||
klog.OsExit = customExit
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
oldNodePodCIDRs []string
|
||||
@ -125,7 +140,12 @@ func TestNodePodCIDRHandlerUpdate(t *testing.T) {
|
||||
t.Errorf("The code did panic")
|
||||
}
|
||||
}()
|
||||
|
||||
n.OnNodeUpdate(oldNode, node)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func customExit(exitCode int) {
|
||||
panic(strconv.Itoa(exitCode))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user