-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
WIP: Dynamic function filter #13087
WIP: Dynamic function filter #13087
Conversation
cf5aebd
to
87423c6
Compare
controller/appcontroller.go
Outdated
@@ -222,16 +232,42 @@ func NewApplicationController( | |||
return &ctrl, nil | |||
} | |||
|
|||
func computeClusterToShardsPlacement(db db.ArgoDB) error { |
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 this function used ?
ctrl.projByNameCache.Delete(key) | ||
return true | ||
}) | ||
if ctrl != nil { |
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 is this nil
check required after this change ?
controller/sharding/sharding.go
Outdated
} | ||
|
||
return func(c *v1alpha1.Cluster) int { | ||
return clusterIndexdByClusterId[c.ID] % replicas |
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.
Just a thought, can we do the mod
operation in a common place ? The distribution function can just perform the hashing function returning the hash value for the cluster and the cluster filter can then do hash_value % replicas == shard
to return the boolean value.
db9bbcf
to
26f52fe
Compare
replicas := env.ParseNumFromEnv(common.EnvControllerReplicas, 0, 0, math.MaxInt32) | ||
shard := env.ParseNumFromEnv(common.EnvControllerShard, -1, -math.MaxInt32, math.MaxInt32) | ||
shard := int32(env.ParseNumFromEnv(common.EnvControllerShard, -1, -math.MaxInt32, math.MaxInt32)) |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types
@@ -23,31 +33,79 @@ | |||
if err != nil { | |||
return 0, fmt.Errorf("hostname should ends with shard number separated by '-' but got: %s", hostname) | |||
} | |||
return shard, nil | |||
return int32(shard), nil |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types
26f52fe
to
f6486da
Compare
…nctions for it Signed-off-by: Akram Ben Aissi <[email protected]>
f6486da
to
97f0af3
Compare
/close closing in favor of #13018 13018 |
} else { | ||
h := fnv.New32a() | ||
_, _ = h.Write([]byte(id)) | ||
shard := int32(h.Sum32() % uint32(replicas)) |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types
Alright, closing because you said so 😄 |
Passes a distribution function to the cluster filter function to allow sorting and distribution in a custom manner.
Please see Contribution FAQs if you have questions about your pull-request.