@@ -45,9 +45,14 @@ import (
45
45
)
46
46
47
47
const (
48
+ // portsPerTask: rpcPort, clientPort, httpPort
48
49
portsPerTask = 3
49
50
notReseeding = 0
50
51
reseedUnderway = 1
52
+
53
+ executorWantsCpus = 0.1
54
+ executorWantsMem = 32
55
+ executorWantsPorts = 1
51
56
)
52
57
53
58
// State represents the mutability of the scheduler.
@@ -221,6 +226,11 @@ func (s *EtcdScheduler) ResourceOffers(
221
226
driver scheduler.SchedulerDriver ,
222
227
offers []* mesos.Offer ,
223
228
) {
229
+ var (
230
+ cpusWanted = s .cpusPerTask + executorWantsCpus
231
+ memWanted = s .memPerTask + executorWantsMem
232
+ portsWanted = uint64 (portsPerTask + executorWantsPorts )
233
+ )
224
234
for _ , offer := range offers {
225
235
resources := parseOffer (offer )
226
236
@@ -262,25 +272,25 @@ func (s *EtcdScheduler) ResourceOffers(
262
272
log .V (2 ).Infoln ("-single-instance-per-slave is false, continuing." )
263
273
}
264
274
265
- if resources .cpus < s . cpusPerTask {
275
+ if resources .cpus < cpusWanted {
266
276
log .V (1 ).Infoln ("Offer cpu is insufficient." )
267
277
}
268
278
269
- if resources .mems < s . memPerTask {
279
+ if resources .mems < memWanted {
270
280
log .V (1 ).Infoln ("Offer memory is insufficient." )
271
281
}
272
282
273
- if totalPorts < portsPerTask {
283
+ if totalPorts < portsWanted {
274
284
log .V (1 ).Infoln ("Offer ports are insuffient." )
275
285
}
276
286
277
287
if resources .disk < s .diskPerTask {
278
288
log .V (1 ).Infoln ("Offer disk is insufficient." )
279
289
}
280
290
281
- if resources .cpus >= s . cpusPerTask &&
282
- resources .mems >= s . memPerTask &&
283
- totalPorts >= portsPerTask &&
291
+ if resources .cpus >= cpusWanted &&
292
+ resources .mems >= memWanted &&
293
+ totalPorts >= portsWanted &&
284
294
resources .disk >= s .diskPerTask &&
285
295
s .offerCache .Push (offer ) {
286
296
@@ -884,12 +894,15 @@ func (s *EtcdScheduler) launchOne(driver scheduler.SchedulerDriver) {
884
894
return
885
895
}
886
896
887
- // TODO(tyler) this is a broken hack
888
- resources := parseOffer (offer )
889
- lowest := * resources .ports [0 ].Begin
890
- rpcPort := lowest
891
- clientPort := lowest + 1
892
- httpPort := lowest + 2
897
+ // TODO(tyler) this is a broken hack; task gets low ports, executor gets high ports
898
+ var (
899
+ resources = parseOffer (offer )
900
+ lowest = * resources .ports [0 ].Begin
901
+ rpcPort = lowest
902
+ clientPort = lowest + 1
903
+ httpPort = lowest + 2
904
+ libprocessPort = lowest + 3
905
+ )
893
906
894
907
s .mut .Lock ()
895
908
var clusterType string
@@ -928,7 +941,7 @@ func (s *EtcdScheduler) launchOne(driver scheduler.SchedulerDriver) {
928
941
929
942
configSummary := node .String ()
930
943
taskID := & mesos.TaskID {Value : & configSummary }
931
- executor := s .newExecutorInfo (node , s .executorUris )
944
+ executor := s .newExecutorInfo (node , s .executorUris , libprocessPort )
932
945
task := & mesos.TaskInfo {
933
946
Data : serializedNodes ,
934
947
Name : proto .String ("etcd-server" ),
@@ -940,7 +953,7 @@ func (s *EtcdScheduler) launchOne(driver scheduler.SchedulerDriver) {
940
953
util .NewScalarResource ("mem" , s .memPerTask ),
941
954
util .NewScalarResource ("disk" , s .diskPerTask ),
942
955
util .NewRangesResource ("ports" , []* mesos.Value_Range {
943
- util .NewValueRange (uint64 (rpcPort ), uint64 (httpPort )),
956
+ util .NewValueRange (uint64 (rpcPort ), uint64 (rpcPort + portsPerTask - 1 )),
944
957
}),
945
958
},
946
959
Discovery : & mesos.DiscoveryInfo {
@@ -1198,22 +1211,33 @@ func ServeExecutorArtifact(path, address string, artifactPort int) (*string, err
1198
1211
func (s * EtcdScheduler ) newExecutorInfo (
1199
1212
node * config.Node ,
1200
1213
executorURIs []* mesos.CommandInfo_URI ,
1214
+ libprocessPort uint64 ,
1201
1215
) * mesos.ExecutorInfo {
1202
1216
1203
- _ , bin := filepath .Split (s .ExecutorPath )
1204
- execmd := fmt .Sprintf ("./%s -log_dir=./" , bin )
1205
-
1217
+ var (
1218
+ _ , bin = filepath .Split (s .ExecutorPath )
1219
+ execmd = fmt .Sprintf ("./" + bin )
1220
+ ci = & mesos.CommandInfo {
1221
+ Value : proto .String (execmd ),
1222
+ Shell : proto .Bool (false ),
1223
+ Uris : executorURIs ,
1224
+ }
1225
+ )
1226
+ ci .Arguments = append (ci .Arguments , execmd )
1227
+ ci .Arguments = append (ci .Arguments , "-log_dir=./" )
1228
+ ci .Arguments = append (ci .Arguments , "-driver-port=" + strconv .Itoa (int (libprocessPort )))
1206
1229
return & mesos.ExecutorInfo {
1207
1230
ExecutorId : util .NewExecutorID (node .Name ),
1208
1231
Name : proto .String ("etcd" ),
1209
- Source : proto .String ("go_test" ),
1210
- Command : & mesos.CommandInfo {
1211
- Value : proto .String (execmd ),
1212
- Uris : executorURIs ,
1213
- },
1232
+ Source : proto .String (s .FrameworkName ),
1233
+ Command : ci ,
1214
1234
Resources : []* mesos.Resource {
1215
- util .NewScalarResource ("cpus" , 0.1 ),
1216
- util .NewScalarResource ("mem" , 32 ),
1235
+ util .NewScalarResource ("cpus" , executorWantsCpus ),
1236
+ util .NewScalarResource ("mem" , executorWantsMem ),
1237
+ util .NewRangesResource ("ports" , []* mesos.Value_Range {
1238
+ // see hack in launchOne(), libprocessPort is the base of the executor port resource range
1239
+ util .NewValueRange (libprocessPort , libprocessPort + executorWantsPorts - 1 ),
1240
+ }),
1217
1241
},
1218
1242
}
1219
1243
}
0 commit comments