Skip to content

Commit b008590

Browse files
committed
DeleteFunc could recieve a DeletedFinalStateUnknown
It's possibel the DeleteFunc could recieve an object of type DeleteFinalStateUnknown. https://godoc.org/k8s.io/client-go/tools/cache#DeletedFinalStateUnknown If we do recieve one, just ignore it.
1 parent 61af7cb commit b008590

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pkg/gameservers/controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ func NewController(
127127
// track pod deletions, for when GameServers are deleted
128128
kubeInformerFactory.Core().V1().Pods().Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
129129
DeleteFunc: func(obj interface{}) {
130-
pod := obj.(*corev1.Pod)
131-
if stablev1alpha1.GameServerRolePodSelector.Matches(labels.Set(pod.ObjectMeta.Labels)) {
130+
// Could be a DeletedFinalStateUnknown, in which case, just ignore it
131+
pod, ok := obj.(*corev1.Pod)
132+
if ok && stablev1alpha1.GameServerRolePodSelector.Matches(labels.Set(pod.ObjectMeta.Labels)) {
132133
if owner := metav1.GetControllerOf(pod); owner != nil {
133134
c.workerqueue.Enqueue(cache.ExplicitKey(pod.ObjectMeta.Namespace + "/" + owner.Name))
134135
}

0 commit comments

Comments
 (0)