Skip to content

Commit

Permalink
Add resync period option for probes
Browse files Browse the repository at this point in the history
Signed-off-by: Bartosz Zurkowski <zurkowski.bartosz@gmail.com>
  • Loading branch information
bzurkowski committed Mar 21, 2020
1 parent e7aa5a4 commit aaeab66
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions helm/orca/config/orca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ neo4j:

prometheus:
url: http://prometheus-prometheus-oper-prometheus.monitoring:9090
resync_period: 300

kiali:
url: http://kiali.istio-system:20001
username: admin
password: admin
resync_period: 300
6 changes: 4 additions & 2 deletions orca/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ def parse(self, config_path):
'prometheus': {
'type': 'dict',
'schema': {
'url': {'type': 'string'}
'url': {'type': 'string'},
'resync_period': {'type': 'integer', 'default': 300}
}
},
'kiali': {
'type': 'dict',
'schema': {
'url': {'type': 'string'},
'username': {'type': 'string'},
'password': {'type': 'string'}
'password': {'type': 'string'},
'resync_period': {'type': 'integer', 'default': 300}
}
},
'neo4j': {
Expand Down
3 changes: 2 additions & 1 deletion orca/topology/alerts/prometheus/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def initialize_probes(graph):
graph=graph,
upstream_proxy=upstream.UpstreamProxy(prom_client),
extractor=prom_extractor.AlertExtractor(source_mapper),
synchronizer=utils.NodeSynchronizer(graph)
synchronizer=utils.NodeSynchronizer(graph),
resync_period=CONFIG.prometheus.resync_period
)
]

Expand Down
8 changes: 7 additions & 1 deletion orca/topology/infra/kiali/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ def initialize_probes(graph):
url=CONFIG.kiali.url,
username=CONFIG.kiali.username,
password=CONFIG.kiali.password)
return [probe.Probe(graph=graph, kiali_client=kiali_client)]
return [
probe.Probe(
graph=graph,
kiali_client=kiali_client,
resync_period=CONFIG.kiali.resync_period
)
]


def initialize_linkers(graph):
Expand Down
5 changes: 3 additions & 2 deletions orca/topology/infra/kiali/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ class Probe(probe.Probe):

"""Probe for synchronizing service graph from Kiali."""

def __init__(self, graph, kiali_client):
def __init__(self, graph, kiali_client, resync_period=60):
super().__init__(graph)
self._kiali_client = kiali_client
self._resync_period = resync_period

def run(self):
while True:
LOG.info("Starting sync for Kiali service graph")
self._synchronize()
LOG.info("Finished sync for Kiali service graph")
time.sleep(60)
time.sleep(self._resync_period)

def _synchronize(self):
namespaces = self._get_namespaces()
Expand Down
5 changes: 3 additions & 2 deletions orca/topology/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ class PullProbe(Probe):

"""Periodically pulls all entities from the upstream into the graph."""

def __init__(self, graph, upstream_proxy, extractor, synchronizer):
def __init__(self, graph, upstream_proxy, extractor, synchronizer, resync_period=60):
super().__init__(graph)
self._upstream_proxy = upstream_proxy
self._extractor = extractor
self._synchronizer = synchronizer
self._resync_period = resync_period

def run(self):
while True:
extended_kind = self._extractor.get_extended_kind()
LOG.info("Starting sync for entity: %s", extended_kind)
self._synchronize()
LOG.info("Finished sync for entity: %s", extended_kind)
time.sleep(60)
time.sleep(self._resync_period)

def _synchronize(self):
nodes_in_graph = self._get_nodes_in_graph()
Expand Down

0 comments on commit aaeab66

Please sign in to comment.