-
Notifications
You must be signed in to change notification settings - Fork 187
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
fix: bug with repeated alias for service [NET-434] #1536
Conversation
NET-434 Fix aliases duplication
|
@@ -73,7 +73,9 @@ pub struct Service { | |||
|
|||
impl Service { | |||
pub fn remove_alias(&mut self, alias: &str) { | |||
self.aliases.retain(|a| a.ne(alias)); | |||
if let Some(pos) = self.aliases.iter().position(|x| *x == alias) { | |||
self.aliases.remove(pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can make self.aliases
a set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think about that, but we must decide which alias we can use in metrics. Now it's just the first element of vec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point.
Also, we should decide for which services with aliases to collect metrics. In the current model, where we create aliases for every deal, it's just too many services, and an uncontrollable amount of services for metrics collection in prometheus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can collect metrics per-worker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Difficult question. Guess we can discuss it later when we start reworking metrics for spells/workers/so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to allow several aliases per service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't know
@@ -73,7 +73,9 @@ pub struct Service { | |||
|
|||
impl Service { | |||
pub fn remove_alias(&mut self, alias: &str) { | |||
self.aliases.retain(|a| a.ne(alias)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why retain wasn't enough? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more than enough, I did add_alias and remove_alias symmetrically. Now add_alias adds 1 alias, and remove_alias removes exactly one alias
+ a little bit of refactoring