File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ Extend the feature of streaming k8s events to AWS CloudWatch logs.
9
9
10
10
Streams k8s events from k8s namespace to Slack channel as a Slack bot using incoming web hooks. No tokens needed.
11
11
12
+ # Known issue
13
+
14
+ * Model objects should tolerate None in place of empty lists https://github.com/kubernetes-client/python/issues/376 .<br />
15
+ For now we have to patch the class in our code to workaround this issue.
16
+
12
17
# Configuration
13
18
14
19
Configuration is done via env variables that you set in deployment or configmap.
Original file line number Diff line number Diff line change 10
10
import kubernetes
11
11
from dateutil .tz import tzlocal
12
12
13
+ # Workaround for https://github.com/kubernetes-client/python/issues/376
14
+ from kubernetes .client .models .v1_event import V1Event
15
+
16
+
17
+ def set_involved_object (self , involved_object ):
18
+ if involved_object is None :
19
+ involved_object = {}
20
+ self ._involved_object = involved_object
21
+
22
+
23
+ setattr (V1Event , 'involved_object' , property (
24
+ fget = V1Event .involved_object .fget , fset = set_involved_object ))
25
+ # End of workaround
26
+
13
27
logger = logging .getLogger ()
14
28
logger .setLevel (logging .INFO )
15
29
@@ -121,6 +135,11 @@ def main():
121
135
logger .info ("Processing events..." )
122
136
for event in k8s_watch .stream (v1 .list_namespaced_event , k8s_namespace_name ):
123
137
logger .debug (str (event ))
138
+ if not event ['object' ].involved_object :
139
+ logger .debug (
140
+ 'Found empty involved_object in the event. Skip this one.'
141
+ )
142
+ continue
124
143
if is_message_type_delete (event ) and skip_delete_events != False :
125
144
logger .debug (
126
145
'Event type DELETED and skip deleted events is enabled. Skip this one.' )
You can’t perform that action at this time.
0 commit comments