@@ -138,7 +138,13 @@ func (e *Scheduler) getOffer(offers *mesosproto.Event_Offers, cmd *cfg.Command)
138138 continue
139139 }
140140
141- // if the ressources of this offer does not matched what the command need, the skip
141+ // if the attributes of this offer does not matched what the command need, then skip
142+ if ! e .matchAttributes (cmd , offer ) {
143+ logrus .WithField ("func" , "scheduler.getOffer" ).Debug ("Could not found any matched attributes, get next offer" )
144+ continue
145+ }
146+
147+ // if the ressources of this offer does not matched what the command need, then skip
142148 if ! e .Mesos .IsRessourceMatched (offer .Resources , cmd ) {
143149 logrus .WithField ("func" , "scheduler.getOffer" ).Debug ("Could not found any matched ressources, get next offer" )
144150 continue
@@ -155,6 +161,22 @@ func (e *Scheduler) getOffer(offers *mesosproto.Event_Offers, cmd *cfg.Command)
155161 return offerret , offerIds
156162}
157163
164+ // search matched mesos attributes. if cmd does not has any attributes,
165+ // then the result would be true.
166+ func (e * Scheduler ) matchAttributes (cmd * cfg.Command , offer * mesosproto.Offer ) bool {
167+ if len (cmd .Attributes ) <= 0 {
168+ return true
169+ }
170+
171+ ret := false ;
172+ for _ , attribute := range cmd .Attributes {
173+ if strings .EqualFold ("true" , e .getAttributes (* attribute .Key , offer )) {
174+ ret = ret && true
175+ }
176+ }
177+ return ret
178+ }
179+
158180// search matched mesos attributes
159181func (e * Scheduler ) getAttributes (name string , offer * mesosproto.Offer ) string {
160182 for _ , attribute := range offer .Attributes {
0 commit comments