Skip to content

Commit c142850

Browse files
issue-5702 - Multiple duplicate mappings generated for single mapping resource fixed
Signed-off-by: Sekar Saravanan <[email protected]>
1 parent 0d82d0e commit c142850

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

python/ambassador/ir/ir.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,13 @@ def add_mapping(self, aconf: Config, mapping: IRBaseMapping) -> Optional[IRBaseM
817817
else:
818818
self.logger.debug(f"IR: already have group for {mapping.name}")
819819
group = self.groups[mapping.group_id]
820-
group.add_mapping(aconf, mapping)
820+
821+
# Add mapping into the group only if the _cache_key doesn't exist in a group.
822+
existing_mapping_cache_keys = [ group_mapping["_cache_key"] for group_mapping in group["mappings"] if "_cache_key" in group_mapping ]
823+
if mapping["_cache_key"] in existing_mapping_cache_keys:
824+
self.logger.debug(f"IR: _cache_key for {mapping.name} is {mapping["_cache_key"]} already exists in a group.")
825+
else:
826+
group.add_mapping(aconf, mapping)
821827

822828
self.cache_add(mapping)
823829
self.cache_add(group)

python/ambassador_diag/diagd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def check_cache(self) -> bool:
551551
result = False
552552
self.logger.error("CACHE: ENVOY CONFIG MISMATCH")
553553
errors += "econf diffs:\n"
554-
errors += self.json_diff("econf", i1, i2)
554+
errors += self.json_diff("econf", e1, e2)
555555

556556
if not result:
557557
err_path = os.path.join(self.snapshot_path, "diff-tmp.txt")

0 commit comments

Comments
 (0)