From b478192c2163aa0f166c5a7549610cf480ba6bc7 Mon Sep 17 00:00:00 2001
From: Karl Rister <krister@redhat.com>
Date: Mon, 29 Jul 2024 09:20:50 -0500
Subject: [PATCH] prevent an invalid state from crashing the remotehosts.py
 remote_image_manager

---
 endpoints/remotehosts/remotehosts.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/endpoints/remotehosts/remotehosts.py b/endpoints/remotehosts/remotehosts.py
index 8c56e90a..fea19ab3 100755
--- a/endpoints/remotehosts/remotehosts.py
+++ b/endpoints/remotehosts/remotehosts.py
@@ -2100,6 +2100,10 @@ def remote_image_manager(thread_name, remote_name, connection, image_max_cache_s
     thread_logger(thread_name, "images[rickshaw]:\n%s" % (endpoints.dump_json(images["rickshaw"])), remote_name = remote_name, log_prefix = log_prefix)
     thread_logger(thread_name, "images[podman]:\n%s" % (endpoints.dump_json(images["podman"])), remote_name = remote_name, log_prefix = log_prefix)
 
+    if len(images["rickshaw"]) == 0 or len(images["podman"]) == 0:
+        thread_logger(thread_name, "Invalid state, exiting image manager", remote_name = remote_name, log_prefix = log_prefix)
+        return
+
     cache_size = 0
 
     if cache_size < image_max_cache_size: