Skip to content

Commit

Permalink
while true loop around stream
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhellander committed Apr 17, 2024
1 parent 0b98e41 commit 0ee8756
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,41 @@ def sync_all_statuses():

def init_event_listener():
resource_version = ""
for event in w.stream(
api.list_namespaced_pod,
namespace=namespace,
label_selector=label_selector,
timeout_seconds=20,
resource_version=resource_version,
):
pod = event["object"]
while True:
for event in w.stream(
api.list_namespaced_pod,
namespace=namespace,
label_selector=label_selector,
timeout_seconds=20,
resource_version=resource_version,
):
pod = event["object"]

resource_version = pod.metadata.resource_version
status = get_status(pod)
resource_version = pod.metadata.resource_version
status = get_status(pod)

logging.info(f"Synchronizing status: {status}")
logging.info(f"Synchronizing status: {status}")

# status = pod.status.phase
release = pod.metadata.labels["release"]
# status = pod.status.phase
release = pod.metadata.labels["release"]

event_type = event["type"]
event_type = event["type"]

if latest_status.get(release) == status:
logging.info("Status not changed, skipping...")
if latest_status.get(release) == status:
logging.info("Status not changed, skipping...")

latest_status[release] = status
latest_status[release] = status

if event_type != "DELETED":
logging.info(f"EVENT_TYPE: {event_type}")
logging.info(f"STATUS: {status}")
if event_type != "DELETED":
logging.info(f"EVENT_TYPE: {event_type}")
logging.info(f"STATUS: {status}")

data = {
"release": release,
"status": status,
}
data = {
"release": release,
"status": status,
}

post(APP_STATUS_URL, data=data)
post(APP_STATUS_URL, data=data)


def get_status(pod):
Expand Down

0 comments on commit 0ee8756

Please sign in to comment.