Closed huahuiyang closed 5 years ago
this is to support multiple master api urls when start the framework, support multiple mesos api urls failover in attempts. And does not break current c.url logic.
@jdef would you like to take a look when you get a chance?
@tsenart @vladimirvivien @jdef any ideas? does this repo still in maintaining? seems it has been a long time after this pr was created.
Thanks for the PR! This repo is maintained, and I'm basically the only maintainer at this point .. so sometimes it takes me while to get around to reviewing PRs. Thanks for being patient.
It looks like the use case you're trying to address is this:
Does that sound about right?
These candidates are more like "bootstrap" endpoints, right? Because in a cloudy environment where servers come and go, it's possible that the initial nodes might cycle out (unless you were using floating IPs that remaining the same across recycled instances).
I'm interested in the specifics if your use case. Please elaborate in the PR description.
@jdef Thanks for looking at this pr, and the items you listed in the comment above are pretty much correct! Setup a load balancer in front of mesos masters, providing a non-changed endpoint is a solution, but having some drawbacks:
In our case, we choose to use mesos masters raw ip/dns directly (akka. candidates in this pr), we are aware of mesos master addresses could be changed totally, but in a high availability, fault tolerant mesos scheduler, the active/standby schedulers could easily rolling restart to load the latest mesos master candidates in case. So we propose another candidates option in this pr to initiate the mesos framework, which is not breaking origin single url register way, to let developer make the choice according to their use case.
OK. Let me then suggest the following changes to this PR:
httpcli
package at all since what you really want are changes to the httpsched
client; create an Option
func in httpsched
handles candidate selectionfunc() string
. then you could define a "static candidate selector" that cycles over some fixed slice of candidate strings. but a user could invent a new implementation that was more dynamic and not limited to an initial, fixed set of strings. let me know if you need/want me to elaborate on this idea more.e.g.
type CandidateSelector func() string
func FixedCandidateSelector(s []string) CandidateSelector { ... } // cycles over s
@jdef fair enough, i've changed the pr according to your comments. In this pr, if the mesos framework specify a candidate selector(could be dynamic func), the framework will gain the ability to failover across multiple mesos masters. otherwise, it will only rely on the url as an initial configuration.
an example might be as follows:
masters := "http://master1:5050/api/v1/scheduler," +
"http://master2:5050/api/v1/scheduler," +
"http://master3:5050/api/v1/scheduler"
candidateIndex := 0
candidatesRoundRobinSelector := func() string {
if len(strings.Split(masters, ",")) == 0 {
return ""
}
if candidateIndex >= len(strings.Split(cfg.Masters, ",")) {
candidateIndex = 0
}
res := strings.Split(cfg.Masters, ",")[candidateIndex]
candidateIndex++
return res
}
httpsched.NewCaller(cli,
httpsched.AllowReconnection(true),
httpsched.MasterCandidates(candidatesRoundRobinSelector))
great, after upstream this change, our prod system do not need to maintain a forked mesos-go repo for multiple candidates purpose in our organization. i will think of the unit test part in another pr.
@huahuiyang please rebase so that I can merge this
@jdef rebased.
ping @jdef
@jdef any chance for you to take a look and get this pr merged? thanks
LGTM, thanks
In this pr, if the mesos framework specify a candidate selector(could be dynamic func), the framework will gain the ability to failover across multiple mesos masters. otherwise, it will only rely on the url as an initial configuration.