Skip to content

Commit

Permalink
feat(helics): ensure HELICS nodes are labeled for searching and minim…
Browse files Browse the repository at this point in the history
…ega cc
  • Loading branch information
activeshadow committed Sep 25, 2024
1 parent 1f38dfb commit 87d6859
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/python/phenix_apps/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ def add_annotation(self, hostname, key, value):
annotations[key] = value
node['annotations'] = annotations

def add_label(self, hostname, key, value):
node = self.extract_node(hostname)

labels = node.get('labels', {})

# Could be a null entry in the JSON schema.
if not labels:
labels = {}

# This will override an existing label with the same key.
labels[key] = value
node['labels'] = labels

def add_inject(self, hostname, inject):
node = self.extract_node(hostname)

Expand Down
9 changes: 9 additions & 0 deletions src/python/phenix_apps/apps/helics/helics.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def pre_start(self):
if not self.is_booting(root_hostname):
logger.log('ERROR', f'root broker is marked do not boot: {root_hostname}')

self.add_label(root_hostname, 'group', 'helics')
self.add_label(root_hostname, 'helics', 'broker')

total_fed_count = 0

# broker hosts --> ip:port --> fed-count
Expand All @@ -61,6 +64,9 @@ def pre_start(self):
if not self.is_booting(fed.general.hostname):
continue

self.add_label(fed.general.hostname, 'group', 'helics')
self.add_label(fed.general.hostname, 'helics', 'federate')

configs = fed.annotations.get('helics/federate', [])

for config in configs:
Expand Down Expand Up @@ -96,6 +102,9 @@ def pre_start(self):
if not self.is_booting(hostname):
logger.log('ERROR', f'broker node is marked do not boot: {hostname}')

self.add_label(hostname, 'group', 'helics')
self.add_label(hostname, 'helics', 'broker')

entry = brokers.get(hostname, {broker_ip: 0})
entry[broker] += count

Expand Down

0 comments on commit 87d6859

Please sign in to comment.