Skip to content

Commit 51df4b9

Browse files
author
Jeny Sadadia
committed
Remove re-subscription logic from pipeline services
When API helper functions `receive_event_node` or `receive_event_data` fails, there must be some issue with extracting node data from the event rather than an issue with the subscription. Hence, remove the re-subscription logic. Fixes: f04f6d0 ("(events): Add re-subscribe mechanism") Signed-off-by: Jeny Sadadia <[email protected]>
1 parent 7a007b4 commit 51df4b9

File tree

4 files changed

+4
-37
lines changed

4 files changed

+4
-37
lines changed

src/monitor.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,13 @@ def _run(self, sub_id):
5353
self.log.info("Monitor: Listening for events... ")
5454
self.log.info("Press Ctrl-C to stop.")
5555
print(self._log_titles, flush=True)
56-
subscribe_retries = 0
5756
while True:
5857
event = None
5958
try:
6059
event = self._api.receive_event(sub_id)
6160
except Exception as e:
62-
self.log.error(f"Error receiving event: {e}, re-subscribing in 10 seconds")
63-
time.sleep(10)
64-
sub_id = self._api.subscribe('node')
65-
subscribe_retries += 1
66-
if subscribe_retries > 3:
67-
self.log.error("Failed to re-subscribe to node events")
68-
return False
61+
self.log.error(f"Error receiving event: {e}")
6962
continue
70-
subscribe_retries = 0
7163
obj = event.data
7264
dt = datetime.datetime.fromisoformat(event['time'])
7365
try:

src/scheduler.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,26 +374,18 @@ def _verify_architecture_filter(self, job, node):
374374
def _run(self, sub_id):
375375
self.log.info("Listening for available checkout events")
376376
self.log.info("Press Ctrl-C to stop.")
377-
subscribe_retries = 0
378377

379378
while True:
380379
last_heartbeat['time'] = time.time()
381380
event = None
382381
try:
383382
event = self._api_helper.receive_event_data(sub_id, block=False)
384383
except Exception as e:
385-
self.log.error(f"Error receiving event: {e}, re-subscribing in 10 seconds")
386-
time.sleep(10)
387-
sub_id = self._api.subscribe('node')
388-
subscribe_retries += 1
389-
if subscribe_retries > 3:
390-
self.log.error("Failed to re-subscribe to node events")
391-
return False
384+
self.log.error(f"Error receiving event: {e}")
392385
continue
393386
if not event:
394387
# If we received a keep-alive event, just continue
395388
continue
396-
subscribe_retries = 0
397389
for job, runtime, platform, rules in self._sched.get_schedule(event):
398390
input_node = self._api.node.get(event['id'])
399391
jobfilter = event.get('jobfilter')

src/send_kcidb.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ def _run(self, context):
688688
self.log.info("Listening for events... Press Ctrl-C to stop.")
689689

690690
chunksize = 500
691-
subscribe_retries = 0
692691
while True:
693692
is_hierarchy = False
694693

@@ -702,15 +701,8 @@ def _run(self, context):
702701
try:
703702
node, is_hierarchy = self._api_helper.receive_event_node(context['sub_id'])
704703
except Exception as e:
705-
self.log.error(f"Error receiving event: {e}, re-subscribing in 10 seconds")
706-
time.sleep(10)
707-
context['sub_id'] = self._api_helper.subscribe_filters(self._filters, promiscuous=True)
708-
subscribe_retries += 1
709-
if subscribe_retries > 3:
710-
self.log.error("Failed to re-subscribe to node events")
711-
return False
704+
self.log.error(f"Error receiving event: {e}")
712705
continue
713-
subscribe_retries = 0
714706
self.log.info(f"Processing event node: {node['id']}")
715707
nodes = [node]
716708
else:

src/tarball.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,23 +208,14 @@ def _stop(self, sub_id):
208208
def _run(self, sub_id):
209209
self.log.info("Listening for new trigger events")
210210
self.log.info("Press Ctrl-C to stop.")
211-
subscribe_retries = 0
212211

213212
while True:
214213
checkout_node = None
215214
try:
216215
checkout_node, _ = self._api_helper.receive_event_node(sub_id)
217216
except Exception as e:
218-
self.log.error(f"Error receiving event: {e}, re-subscribing in 10 seconds")
219-
time.sleep(10)
220-
# try to resubscribe
221-
sub_id = self._api_helper.subscribe_filters(self._filters)
222-
subscribe_retries += 1
223-
if subscribe_retries > 3:
224-
self.log.error("Failed to re-subscribe to checkout events")
225-
return False
217+
self.log.error(f"Error receiving event: {e}")
226218
continue
227-
subscribe_retries = 0
228219

229220
build_config = self._find_build_config(checkout_node)
230221
if build_config is None:

0 commit comments

Comments
 (0)