Add weighted address strategy for multi-key listeners (#2394)#2405
Add weighted address strategy for multi-key listeners (#2394)#2405gabordozsa wants to merge 3 commits intoskupperproject:mainfrom
Conversation
1f3766e to
e0d2c99
Compare
…#2394) Signed-off-by: Gabor Dozsa <gabor.dozsa@ibm.com>
e0d2c99 to
4a3197f
Compare
| WeightedStrategySpec specifies a map of routing keys to route traffic to. | ||
| Each routingKey has a weight value. | ||
|
|
||
| With this strategy traffic is distributed randomly among the reachable |
There was a problem hiding this comment.
Consider following rewrite:
The listener distributes traffic among reachable routing keys according to their weights. Routing keys with higher weights receive a larger portion of the traffic. If all keys are assigned the same weight, traffic is split equally between them.
There was a problem hiding this comment.
Changed the comment as suggested.
| type: object | ||
| weighted: | ||
| description: |- | ||
| WeightedStrategySpec specifies a map of routing keys to route traffic to. |
There was a problem hiding this comment.
| WeightedStrategySpec specifies a map of routing keys to route traffic to. | |
| WeightedStrategySpec defines a mapping of routing keys to weights. |
There was a problem hiding this comment.
Changed as suggested.
| weighted: | ||
| description: |- | ||
| WeightedStrategySpec specifies a map of routing keys to route traffic to. | ||
| Each routingKey has a weight value. |
There was a problem hiding this comment.
not necessary if prev comment accepted.
| additionalProperties: | ||
| type: integer | ||
| description: |- | ||
| routingKeysReachable is a map of routingKeys with at least one |
There was a problem hiding this comment.
| routingKeysReachable is a map of routingKeys with at least one | |
| routingKeysReachable is a mapping of routingKeys to weights with at least one |
There was a problem hiding this comment.
Changed as suggested.
| RoutingKeys []string `json:"routingKeys"` | ||
| } | ||
|
|
||
| // WeightedStrategySpec specifies a map of routing keys to route traffic to. |
There was a problem hiding this comment.
depending on comments above, might need to change these comments
There was a problem hiding this comment.
All previous comments are generated from this file. I made the changes in this file and generated the yaml again.
fgiorgetti
left a comment
There was a problem hiding this comment.
It is working great on both kubernetes with system sites. Nice job @gabordozsa.
One thing that we need to consider, is whether the strategy field should be immutable or not. If we allow it to change, we should cleanup the status.strategy field and update it with the new strategy.
| return fmt.Errorf("invalid multikeylistener: %s - routingKey must not be empty", mkl.Name) | ||
| } | ||
| if weight <= 0 { | ||
| return fmt.Errorf("invalid multikeylistener: %s - weight value must not be positive", mkl.Name) |
There was a problem hiding this comment.
must be positive (remove the not).
| return true | ||
|
|
||
| if m.Spec.Strategy.Priority != nil { | ||
| if m.Status.Strategy.Priority == nil { |
There was a problem hiding this comment.
Should it force Status.Strategy.Weighted = nil (and the opposite when using Weighted) to clean up old status in case the strategy has changed?
@fgiorgetti I think the |
Agreed. The CRD validation could be enhanced to guarantee that the field is immutable. |
|
Help me understand immutable in this context. |
Correct. |
Add weighted address strategy for multi-key listeners
Fixes #2394