Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-5702 - Multiple duplicate mappings for single mapping resource fixed #5705

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ it will be removed; but as it won't be user-visible this isn't considered a brea
- Change: Upgraded Emissary-ingress to the latest release of Golang as part of our general
dependency upgrade process.

- Bugfix: Emissary creating duplicate mapping in ir.json and econf.json while adding weight for canary
release. This leads to getting IR MISMATCH & ENVOY CONFIG MISMATCH error frequently in the logs and
also consumes more cpu. We have introduced a condition that, it will add the mapping only if the mapping
is not already present in the group.

[#5702]: https://github.com/emissary-ingress/emissary/issues/5702

## [3.9.0] November 13, 2023
[3.9.0]: https://github.com/emissary-ingress/emissary/compare/v3.8.0...v3.9.0

Expand Down
11 changes: 10 additions & 1 deletion python/ambassador/ir/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,16 @@ def add_mapping(self, aconf: Config, mapping: IRBaseMapping) -> Optional[IRBaseM
else:
self.logger.debug(f"IR: already have group for {mapping.name}")
group = self.groups[mapping.group_id]
group.add_mapping(aconf, mapping)
is_mapping_present = False
try:
existing_mapping_keys = [ group_mapping["rkey"] for group_mapping in group["mappings"] ]
is_mapping_present = True if mapping["rkey"] in existing_mapping_keys else False
except Exception as e:
self.logger.error(f"IR: Exception occurred {e} when checking {mapping.name} already presents in {mapping.group_id}")

if not is_mapping_present:
self.logger.debug(f"IR: mapping {mapping.name} is not exists. adding it into the group.")
group.add_mapping(aconf, mapping)

self.cache_add(mapping)
self.cache_add(group)
Expand Down
2 changes: 1 addition & 1 deletion python/ambassador_diag/diagd.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def check_cache(self) -> bool:
result = False
self.logger.error("CACHE: ENVOY CONFIG MISMATCH")
errors += "econf diffs:\n"
errors += self.json_diff("econf", i1, i2)
errors += self.json_diff("econf", e1, e2)

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