Skip to content

Commit

Permalink
operator: fix panic for non existing CEPs
Browse files Browse the repository at this point in the history
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x118 pc=0x1dcb219]
goroutine 161 [running]:
main.enableUnmanagedKubeDNSController.func1(0x28aa1a0, 0xc00069e880, 0x3d3d0a0, 0xd9fc43ebeec50347)
	/go/src/github.com/cilium/cilium/operator/k8s_pod_controller.go:67 +0xa69
github.com/cilium/cilium/pkg/controller.(*Controller).runController(0xc000789a00)
	/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xa2a
created by github.com/cilium/cilium/pkg/controller.(*Manager).updateController
	/go/src/github.com/cilium/cilium/pkg/controller/manager.go:120 +0xb09
```

Fixes: 26e7451 ("operator: use watcher to track unmanaged pods")
Reported-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed May 28, 2020
1 parent 2e55195 commit 1439b27
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions operator/k8s_pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ func enableUnmanagedKubeDNSController() {
continue
}
cep, exists, err := watchers.HasCE(pod.Namespace, pod.Name)
if err != nil {
log.WithError(err).Errorf("unexpected error when getting CiliumEndpoint %s/%s", pod.Namespace, pod.Name)
continue
}
podID := fmt.Sprintf("%s/%s", pod.Namespace, pod.Name)
switch {
case err == nil:
if exists {
log.Debugf("Found kube-dns pod %s with identity %d", podID, cep.Status.ID)
case !exists:
} else {
log.Debugf("Found unmanaged kube-dns pod %s", podID)
if startTime := pod.Status.StartTime; startTime != nil {
if age := time.Since((*startTime).Time); age > unmanagedKubeDnsMinimalAge {
Expand All @@ -88,8 +91,6 @@ func enableUnmanagedKubeDNSController() {

}
}
default:
return err
}
}

Expand Down

0 comments on commit 1439b27

Please sign in to comment.