Skip to content

Commit b1462c7

Browse files
committed
[core] Fix logic bug in attributes.Satisfy(Constraints)
1 parent d7fa8f6 commit b1462c7

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

core/scheduler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ func resourceOffers(state *internalState, fidStore store.Singleton) events.Handl
474474
}
475475
continue
476476
}
477+
log.WithPrefix("scheduler").Debug("offer attributes satisfy constraints")
477478

478479
wants := state.taskman.GetWantsForDescriptor(descriptor)
479480
if wants == nil {

core/task/constraint/attributes.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,20 @@ func (attrs Attributes) Get(attributeName string) (value string, ok bool) {
5858
func (attrs Attributes) Satisfy(cts Constraints) (ok bool) {
5959
if len(cts) == 0 {
6060
ok = true
61+
log.Debug("no constraints to satisfy, defaulting to true")
6162
return
6263
}
6364
if attrs == nil {
65+
log.Debug("no attributes but non-null constraints, defaulting to false")
6466
return
6567
}
6668

6769
for _, constraint := range cts {
70+
log.WithField("constraint", constraint.String()).Debug("processing constraint")
6871
switch constraint.Operator {
6972
case Equals:
70-
if value, ok := attrs.Get(constraint.Attribute); ok {
73+
var value string
74+
if value, ok = attrs.Get(constraint.Attribute); ok {
7175
if value == constraint.Value {
7276
ok = true
7377
continue
@@ -76,6 +80,7 @@ func (attrs Attributes) Satisfy(cts Constraints) (ok bool) {
7680
break
7781
}
7882
} else { //at least 1 constraint not satisfiable, bailing out
83+
log.WithField("constraint", constraint.Attribute).Warning("at least 1 constraint not satisfiable (cannot get attribute)")
7984
ok = false
8085
break
8186
}

0 commit comments

Comments
 (0)