mirror of https://github.com/docker/docs.git
Add MESOS_OFFER_REFUSE_SECONDS environment configuration
Signed-off-by: Klaus Ma <klaus.ma@outlook.com>
This commit is contained in:
parent
b2739245ce
commit
a23ce43337
|
@ -9,6 +9,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -470,7 +471,21 @@ func (c *Cluster) scheduleTask(t *task) bool {
|
||||||
|
|
||||||
t.build(n.ID, c.agents[n.ID].offers)
|
t.build(n.ID, c.agents[n.ID].offers)
|
||||||
|
|
||||||
if _, err := c.driver.LaunchTasks(offerIDs, []*mesosproto.TaskInfo{&t.TaskInfo}, &mesosproto.Filters{}); err != nil {
|
// Set Mesos refuse seconds by environment variables.
|
||||||
|
var offerFilters *mesosproto.Filters;
|
||||||
|
var refuseSecondsStr string;
|
||||||
|
|
||||||
|
offerFilters = &mesosproto.Filters{};
|
||||||
|
refuseSecondsStr = os.Getenv("MESOS_OFFER_REFUSE_SECONDS");
|
||||||
|
|
||||||
|
if refuseSecondsStr != "" {
|
||||||
|
refuseSeconds, err := strconv.ParseFloat(refuseSecondsStr, 64);
|
||||||
|
if !err {
|
||||||
|
offerFilters.RefuseSeconds = &refuseSeconds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := c.driver.LaunchTasks(offerIDs, []*mesosproto.TaskInfo{&t.TaskInfo}, offerFilters); err != nil {
|
||||||
// TODO: Do not erase all the offers, only the one used
|
// TODO: Do not erase all the offers, only the one used
|
||||||
for _, offer := range s.offers {
|
for _, offer := range s.offers {
|
||||||
c.removeOffer(offer)
|
c.removeOffer(offer)
|
||||||
|
|
Loading…
Reference in New Issue