From c0c7dc663053eb1757c0cc1b99d3655480fc506c Mon Sep 17 00:00:00 2001 From: ikethecoder Date: Wed, 8 May 2024 12:00:14 -0700 Subject: [PATCH] fix schedule route sync --- microservices/kubeApi/routers/routes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/microservices/kubeApi/routers/routes.py b/microservices/kubeApi/routers/routes.py index e1f80a2..d582f0d 100644 --- a/microservices/kubeApi/routers/routes.py +++ b/microservices/kubeApi/routers/routes.py @@ -150,9 +150,8 @@ async def verify_and_create_routes(namespace: str, request: Request): } ) - insert_batch = [x for x in source_routes if x not in existing_routes] - - delete_batch = [y for y in existing_routes if y not in source_routes] + insert_batch = [x for x in source_routes if not in_list(x, existing_routes)] + delete_batch = [y for y in existing_routes if not in_list(y, source_routes)] logger.debug("insert batch: " + str(insert_batch)) @@ -210,3 +209,9 @@ def get_data_plane(ns_attributes): def get_template_version(ns_attributes): return ns_attributes.get('template-version', ["v2"])[0] + +def in_list (match, list): + for item in list: + if item['name'] == match['name']: + return True + return False