Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/k8s/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _create_nginx_config_map(analysis_name: str,
analysis_ip = pod_list_object.items[0].status.pod_ip
time.sleep(1)

# get the name of the hub adapter, kong proxy, and result service
# get the name of the hub adapter, kong proxy, and storage service
hub_adapter_service_name = get_k8s_resource_names('service',
'label',
'component=flame-hub-adapter',
Expand All @@ -394,9 +394,9 @@ def _create_nginx_config_map(analysis_name: str,
'app.kubernetes.io/name=kong',
manual_name_selector='proxy',
namespace=namespace)
result_service_name = get_k8s_resource_names('service',
storage_service_name = get_k8s_resource_names('service',
'label',
'component=flame-result-service',
'component=flame-storage-service',
namespace=namespace)

# generate config map
Expand Down Expand Up @@ -434,10 +434,10 @@ def _create_nginx_config_map(analysis_name: str,
}}


# egress: analysis deployment to result-service
# egress: analysis deployment to storage-service
location ~ ^/storage/(final|local|intermediate)/ {{
rewrite ^/storage(/.*) $1 break;
proxy_pass http://{result_service_name}:8080;
proxy_pass http://{storage_service_name}:8080;
allow {analysis_ip};
deny all;
}}
Expand Down
10 changes: 5 additions & 5 deletions src/resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ def cleanup(cleanup_type: str,
delete_resource(message_broker_pod_name, 'pod', namespace)
response_content[cleanup_type] = "Reset message broker"
if cleanup_type in ['all', 'services', 'rs']:
# reinitialize result-service pod
result_service_name = get_k8s_resource_names('pod',
# reinitialize storage-service pod
storage_service_name = get_k8s_resource_names('pod',
'label',
'component=flame-result-service',
'component=flame-storage-service',
namespace=namespace)
delete_resource(result_service_name, 'pod', namespace)
response_content[cleanup_type] = "Reset result service"
delete_resource(storage_service_name, 'pod', namespace)
response_content[cleanup_type] = "Reset storage service"
Comment on lines 215 to +222
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Handle multiple or missing storage-service pods during cleanup.

get_k8s_resource_names('pod', ...) can return None or list[str]. Passing either to delete_resource will fail. Consider normalizing to a list and skipping when empty.

🔧 Proposed fix
-                storage_service_name = get_k8s_resource_names('pod',
-                                                             'label',
-                                                             'component=flame-storage-service',
-                                                             namespace=namespace)
-                delete_resource(storage_service_name, 'pod', namespace)
-                response_content[cleanup_type] = "Reset storage service"
+                storage_service_names = get_k8s_resource_names('pod',
+                                                              'label',
+                                                              'component=flame-storage-service',
+                                                              namespace=namespace)
+                if storage_service_names is None:
+                    response_content[cleanup_type] = "No storage service pod found"
+                else:
+                    if isinstance(storage_service_names, str):
+                        storage_service_names = [storage_service_names]
+                    for pod_name in storage_service_names:
+                        delete_resource(pod_name, 'pod', namespace)
+                    response_content[cleanup_type] = "Reset storage service"
🤖 Prompt for AI Agents
In `@src/resources/utils.py` around lines 215 - 222, get_k8s_resource_names may
return None or a list; before calling delete_resource you must normalize
storage_service_name to a list, skip when empty/None, and call delete_resource
for each pod name. Specifically, in the block that handles cleanup_type (where
storage_service_name is assigned from get_k8s_resource_names), replace the
direct delete_resource call with logic that: (1) checks if storage_service_name
is truthy, (2) if it's a string convert it into a single-item list, (3) iterate
the list and call delete_resource(name, 'pod', namespace) for each entry, and
(4) set response_content[cleanup_type] only after performing deletions (or set a
helpful message if no pods were found). Ensure you reference the existing
symbols get_k8s_resource_names, delete_resource, storage_service_name,
cleanup_type, namespace, and response_content.

if cleanup_type in ['all', 'keycloak']:
# cleanup keycloak clients without corresponding analysis
# if all is all flame clients are deleted because ther are no analyzes in the db
Expand Down