Skip to content

Commit ac31111

Browse files
committed
Fixes the problem
Essentially when merging property lists, should only take the old data when setting the channel to be inactive. Otherwise only the new data owned by the recceiver is relevant
1 parent 70dba4f commit ac31111

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

server/recceiver/cfstore.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _startServiceWithLock(self):
124124
self.client.set(property={"name": cf_property, "owner": owner})
125125

126126
self.record_property_names_list = set(record_property_names_list)
127+
self.managed_properties = required_properties.union(set(record_property_names_list))
127128
_log.debug("record_property_names_list = {}".format(self.record_property_names_list))
128129
except ConnectionError:
129130
_log.exception("Cannot connect to Channelfinder service")
@@ -213,6 +214,7 @@ def _commitWithThread(self, transaction):
213214

214215
"""The unique identifier for a particular IOC"""
215216
iocid = host + ":" + str(port)
217+
_log.debug("transaction: {s}".format(s=repr(transaction)))
216218

217219
recordInfo = {}
218220
for record_id, (record_name, record_type) in transaction.records_to_add.items():
@@ -274,8 +276,6 @@ def _commitWithThread(self, transaction):
274276
)
275277
continue
276278
recordInfoByName[info["pvName"]] = info
277-
_log.debug("Add record: {record_id}: {info}".format(record_id=record_id, info=info))
278-
_log.debug("Add record: {record_id}: {info}".format(record_id=record_id, info=info))
279279

280280
if transaction.initial:
281281
"""Add IOC to source list """
@@ -494,6 +494,7 @@ def __updateCF__(
494494
cf_channel["properties"] = __merge_property_lists(
495495
create_default_properties(owner, iocTime, recceiverid, channels_dict, iocs, cf_channel),
496496
cf_channel,
497+
processor.managed_properties,
497498
)
498499
if conf.get("recordType"):
499500
cf_channel["properties"] = __merge_property_lists(
@@ -503,6 +504,7 @@ def __updateCF__(
503504
)
504505
),
505506
cf_channel,
507+
processor.managed_properties,
506508
)
507509
channels.append(cf_channel)
508510
_log.debug("Add existing channel to previous IOC: {s}".format(s=channels[-1]))
@@ -522,6 +524,7 @@ def __updateCF__(
522524
cf_channel,
523525
),
524526
alias,
527+
processor.managed_properties,
525528
)
526529
if conf.get("recordType"):
527530
cf_channel["properties"] = __merge_property_lists(
@@ -532,6 +535,7 @@ def __updateCF__(
532535
)
533536
),
534537
cf_channel,
538+
processor.managed_properties,
535539
)
536540
channels.append(alias)
537541
_log.debug("Add existing alias to previous IOC: {s}".format(s=channels[-1]))
@@ -577,6 +581,7 @@ def __updateCF__(
577581
create_time_property(owner, iocTime),
578582
],
579583
cf_channel,
584+
processor.managed_properties,
580585
)
581586
channels.append(cf_channel)
582587
_log.debug("Add existing channel with same IOC: {s}".format(s=channels[-1]))
@@ -594,6 +599,7 @@ def __updateCF__(
594599
create_time_property(owner, iocTime),
595600
],
596601
alias,
602+
processor.managed_properties,
597603
)
598604
channels.append(alias)
599605
new_channels.remove(alias["name"])
@@ -609,6 +615,7 @@ def __updateCF__(
609615
),
610616
],
611617
cf_channel,
618+
processor.managed_properties,
612619
)
613620
channels.append(
614621
create_channel(
@@ -660,7 +667,11 @@ def __updateCF__(
660667
)
661668

662669
existingChannel = existingChannels[channel_name]
663-
existingChannel["properties"] = __merge_property_lists(newProps, existingChannel)
670+
existingChannel["properties"] = __merge_property_lists(
671+
newProps,
672+
existingChannel,
673+
processor.managed_properties,
674+
)
664675
channels.append(existingChannel)
665676
_log.debug("Add existing channel with different IOC: {s}".format(s=channels[-1]))
666677
"""in case, alias exists, update their properties too"""
@@ -672,7 +683,11 @@ def __updateCF__(
672683
for alias in recordInfoByName[channel_name]["aliases"]:
673684
if alias in existingChannels:
674685
ach = existingChannels[alias]
675-
ach["properties"] = __merge_property_lists(alProps, ach)
686+
ach["properties"] = __merge_property_lists(
687+
alProps,
688+
ach,
689+
processor.managed_properties,
690+
)
676691
channels.append(ach)
677692
else:
678693
channels.append(create_channel(alias, owner, alProps))
@@ -724,15 +739,17 @@ def create_default_properties(owner, iocTime, recceiverid, channels_dict, iocs,
724739
)
725740

726741

727-
def __merge_property_lists(newProperties: list[dict[str, str]], channel: dict[str, list[dict[str, str]]]):
742+
def __merge_property_lists(
743+
newProperties: list[dict[str, str]], channel: dict[str, list[dict[str, str]]], managed_properties=set()
744+
) -> list[dict[str, str]]:
728745
"""
729746
Merges two lists of properties ensuring that there are no 2 properties with
730747
the same name In case of overlap between the new and old property lists the
731748
new property list wins out
732749
"""
733750
newPropNames = [p["name"] for p in newProperties]
734751
for oldProperty in channel["properties"]:
735-
if oldProperty["name"] not in newPropNames:
752+
if oldProperty["name"] not in newPropNames and (oldProperty["name"] not in managed_properties):
736753
newProperties = newProperties + [oldProperty]
737754
return newProperties
738755

0 commit comments

Comments
 (0)