plugin/kubernetes: handle tombstones in default processor (#3890)

* handle deletion tombstones in default processor

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* fix terminating pod exclusion

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver 2020-05-15 12:47:29 -04:00 committed by GitHub
parent bb7ee5010e
commit a3aeb3d503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 25 deletions

View file

@ -1,6 +1,8 @@
package object
import (
"fmt"
api "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
@ -28,17 +30,16 @@ func ServiceKey(name, namespace string) string { return name + "." + namespace }
// ToService returns a function that converts an api.Service to a *Service.
func ToService(skipCleanup bool) ToFunc {
return func(obj interface{}) interface{} {
return toService(skipCleanup, obj)
return func(obj interface{}) (interface{}, error) {
svc, ok := obj.(*api.Service)
if !ok {
return nil, fmt.Errorf("unexpected object %v", obj)
}
return toService(skipCleanup, svc), nil
}
}
func toService(skipCleanup bool, obj interface{}) interface{} {
svc, ok := obj.(*api.Service)
if !ok {
return nil
}
func toService(skipCleanup bool, svc *api.Service) *Service {
s := &Service{
Version: svc.GetResourceVersion(),
Name: svc.GetName(),