In the fabric8 Kubernetes client events() API, what does Watcher.Action indicate?

4/26/2017

I have successfully used the Fabric8 Kubernetes client events() API to subscribe to a bunch of events emitted by my minikube installation. It's very cool!

The (undocumented) Watcher class has an (undocumented) eventReceived() method whose first parameter is a Watcher.Action (an enum with values of ADDED, MODIFIED, DELETED and ERROR). Its second parameter is (I've found out in another question) an Event, which represents a Kubernetes Event resource (I guess).

What I'm noticing in my event stream is useful information, but the "action" doesn't seem to line up with the event. For example, here is some arbitrary output from my implementation of eventReceived() (I've printed out +++ action: to show the action my stuff was notified with):

+++ action: DELETED
Event(apiVersion=v1, count=1, firstTimestamp=2017-04-25T23:41:54Z, involvedObject=ObjectReference(apiVersion=v1, fieldPath=spec.containers{controller-manager}, kind=Pod, name=catalog-catalog-controller-manager-1242994143-ddl0l, namespace=catalog, resourceVersion=462865, uid=11fc24bf-2a05-11e7-a27a-080027117396, additionalProperties={}), kind=Event, lastTimestamp=2017-04-25T23:41:54Z, message=Started container with id 7b51c389f153832e7719a99738706c2ff38aa28b298b80741f439b712f166262, metadata=ObjectMeta(annotations=null, clusterName=null, creationTimestamp=2017-04-25T23:41:54Z, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels=null, name=catalog-catalog-controller-manager-1242994143-ddl0l.14b8c87cc177fb77, namespace=catalog, ownerReferences=[], resourceVersion=472706, selfLink=/api/v1/namespaces/catalog/events/catalog-catalog-controller-manager-1242994143-ddl0l.14b8c87cc177fb77, uid=c3851fae-2a10-11e7-a27a-080027117396, additionalProperties={}), reason=Started, source=EventSource(component=kubelet, host=minikube, additionalProperties={}), type=Normal, additionalProperties={})

So you'll note that the action is DELETED, and the event seemingly describes the starting of a Pod (note the message=Started container with id… data).

What does this mean? Am I misinterpreting what the Action parameter is trying to tell me? Does this perhaps mean that the actual Event resource with uid=c3851fae-2a10-11e7-a27a-080027117396 has been DELETED (which is pretty useless information for most cases, but I can see, I guess, that if events are also resources you'd get, well, events indicating their deletion, I guess)?

-- Laird Nelson
event-handling
fabric8
java
kubernetes

1 Answer

6/14/2017

In fact, that is indeed exactly what it means. An Event is a resource that is represented in some cases by a WatchEvent. Certain kubectl actions concerning events report on a hybrid of the two, but an Event can be deleted (for example, when the thing it is notionally describing goes away), and the deletion of the Event in question is represented by a WatchEvent.

-- Laird Nelson
Source: StackOverflow