Skip to content

Commit

Permalink
MAIN-2538 openshift groups fixes (#1633)
Browse files Browse the repository at this point in the history
* skip role binding without subjects

* allow none labels and annotations

* assert open shift groups only if there are results.

---------

Co-authored-by: arik <alon.arik@gmail.com>
  • Loading branch information
RoiGlinik and arikalon1 authored Nov 17, 2024
1 parent 0dc25a9 commit a58fee3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/robusta/core/discovery/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def discovery_process() -> DiscoveryResults:
for role_binding in role_bindings.items:
ns = role_binding.metadata.namespace

if not role_binding.subjects:
logging.info(f"Skipping role binding: {role_binding.metadata.name} in ns: {role_binding.metadata.namespace}")
continue

for subject in role_binding.subjects:
if subject.kind == "Group":
groupname_to_namespaces[subject.name].append(ns)
Expand Down
6 changes: 3 additions & 3 deletions src/robusta/core/model/openshift_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict
from typing import Dict, Optional

from pydantic import BaseModel

Expand All @@ -9,8 +9,8 @@ class OpenshiftGroup(BaseModel):
namespace: str = ""
users: list[str] = []
namespaces: list[str] = []
labels: Dict[str, str]
annotations: Dict[str, str]
labels: Optional[Dict[str, str]] = None
annotations: Optional[Dict[str, str]] = None
deleted: bool = False

def get_service_key(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/robusta/core/sinks/robusta/robusta_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ def __discover_resources(self) -> DiscoveryResults:

self.__pods_running_count = results.pods_running_count

self.__assert_openshift_groups_cache_initialized()
if results.openshift_groups:
self.__assert_openshift_groups_cache_initialized()
self.__publish_new_openshift_groups(results.openshift_groups)

# save the cached services for the resolver.
Expand Down

0 comments on commit a58fee3

Please sign in to comment.