Skip to content

Commit

Permalink
trigger a POD event when IP allocation fails in case of IP range exha…
Browse files Browse the repository at this point in the history
…ustion

Signed-off-by: Yun Zhou <[email protected]>
  • Loading branch information
cathy-zhou committed Jun 19, 2020
1 parent 17c0feb commit d95a8a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions go-controller/pkg/ovn/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
util "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util"
kapi "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes/scheme"
ref "k8s.io/client-go/tools/reference"
"k8s.io/klog"
utilnet "k8s.io/utils/net"
)
Expand Down Expand Up @@ -270,6 +272,14 @@ func (oc *Controller) addLogicalPort(pod *kapi.Pod) error {
if podMac == nil || podIfAddrs == nil {
podMac, podIfAddrs, err = oc.assignPodAddresses(logicalSwitch)
if err != nil {
podRef, err := ref.GetReference(scheme.Scheme, pod)
if err != nil {
klog.Errorf("Couldn't make a ref to pod %s/%s: '%v'", pod.Namespace, pod.Name, err)
} else {
klog.V(5).Infof("Sending a IPRangeFull event for Pod %s in namespace %s.", pod.Name, pod.Namespace)
oc.recorder.Eventf(podRef, kapi.EventTypeWarning, "IPRangeFull",
"No IP address available for pod %s/%s", pod.Namespace, pod.Name)
}
return fmt.Errorf("failed to assign pod addresses for pod %s on node: %s, err: %v",
portName, logicalSwitch, err)
}
Expand Down

0 comments on commit d95a8a9

Please sign in to comment.