Skip to content

Commit

Permalink
add routed check in circulation (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Apr 18, 2022
1 parent c4f5f4d commit 75383df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/daemon/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
var isDefaultRoute bool
var pod *v1.Pod
var err error
for i := 0; i < 15; i++ {
for i := 0; i < 20; i++ {
if pod, err = csh.Controller.podsLister.Pods(podRequest.PodNamespace).Get(podRequest.PodName); err != nil {
errMsg := fmt.Errorf("get pod %s/%s failed %v", podRequest.PodNamespace, podRequest.PodName, err)
klog.Error(errMsg)
Expand Down Expand Up @@ -133,6 +133,13 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
isDefaultRoute = ifName == "eth0"
}

if isDefaultRoute && pod.Annotations[fmt.Sprintf(util.RoutedAnnotationTemplate, podRequest.Provider)] != "true" {
klog.Infof("wait route ready for pod %s/%s provider %s", podRequest.PodNamespace, podRequest.PodName, podRequest.Provider)
cniWaitRouteResult.WithLabelValues(nodeName).Inc()
time.Sleep(1 * time.Second)
continue
}

if vmName != "" {
podRequest.PodName = vmName
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/daemon/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ var (
[]string{"node_name"},
)

cniWaitRouteResult = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cni_wait_route_seconds_total",
Help: "Latency that cni wait controller to add routed annotation to pod",
},
[]string{"node_name"},
)

cniConnectivityResult = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cni_wait_connectivity_seconds_total",
Expand Down

0 comments on commit 75383df

Please sign in to comment.