Skip to content

Commit

Permalink
ambassador/ir: fix cluster name collision
Browse files Browse the repository at this point in the history
  • Loading branch information
dethi committed Oct 17, 2022
1 parent 00aedd8 commit a6076e1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/ambassador/ir/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Any, Callable, Dict, Iterable, List, Optional, Union, ValuesView
from typing import cast as typecast

import json
import hashlib
import logging
import os

Expand Down Expand Up @@ -325,7 +325,11 @@ def __init__(self, aconf: Config,
if len(name) > 60:
# Too long. Gather this cluster by name prefix and normalize
# its name below.
short_name = name[0:40]
h = hashlib.new("sha1")
h.update(name.encode("utf-8"))
hd = h.hexdigest()[0:16].upper()

short_name = name[0:40] + "-" + hd

cluster = self.clusters[name]
self.logger.debug(f"COLLISION: compress {name} to {short_name}")
Expand Down

0 comments on commit a6076e1

Please sign in to comment.