Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleted namespace after test #1436

Merged
merged 3 commits into from
May 22, 2024
Merged
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
19 changes: 18 additions & 1 deletion src/robusta/core/sinks/robusta/dal/supabase_dal.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,24 @@ def remove_deleted_job(self, job: JobInfo):
.execute()
)
except Exception as e:
logging.error(f"Failed to delete job {job} error: {e}")
logging.exception(f"Failed to delete job {job} error: {e}")
raise

def remove_deleted_namespace(self, namespace_name: str):
if not namespace_name:
return

try:
(
self.client.table(NAMESPACES_TABLE)
.delete(returning=ReturnMethod.minimal)
.filter("account_id", "eq", self.account_id)
.filter("cluster_id", "eq", self.cluster)
.eq("name", namespace_name)
.execute()
)
except Exception as e:
logging.exception(f"Failed to delete namespace {namespace_name} error: {e}")
raise

# helm release
Expand Down
12 changes: 5 additions & 7 deletions src/robusta/core/sinks/robusta/robusta_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,12 @@ def __publish_new_namespaces(self, namespaces: List[NamespaceInfo]):

# handle deleted namespaces
updated_namespaces: List[NamespaceInfo] = []
for namespace_name, namespace in self.__namespaces_cache.items():
cache_keys = list(self.__namespaces_cache.keys())
for namespace_name in cache_keys:
if namespace_name not in curr_namespaces:
namespace.deleted = True
updated_namespaces.append(namespace)

for update in updated_namespaces:
if update.deleted:
del self.__namespaces_cache[update.name]
# namespace was deleted from cluster
self.__namespaces_cache.pop(namespace_name, None)
self.dal.remove_deleted_namespace(namespace_name)

# new or changed namespaces
for namespace_name, updated_namespace in curr_namespaces.items():
Expand Down
Loading