Skip to content

Commit 9c0c4b4

Browse files
committed
[core] Improve logging in constraint.Attributes
1 parent 4054fea commit 9c0c4b4

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

core/scheduler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ func resourceOffers(state *internalState, fidStore store.Singleton) events.Handl
406406
"constraints": descriptorConstraints[descriptor],
407407
"offerId": offer.ID.Value,
408408
"resources": remainingResources.String(),
409+
"attributes": offerAttributes.String(),
409410
}).
410-
Warn("descriptor constraints not satisfied by offer")
411+
Warn("descriptor constraints not satisfied by offer attributes")
411412
}
412413
continue
413414
}

core/task/constraint/attributes.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,26 @@
2424

2525
package constraint
2626

27-
import "github.com/mesos/mesos-go/api/v1/lib"
27+
import (
28+
"fmt"
29+
"strings"
30+
31+
"github.com/mesos/mesos-go/api/v1/lib"
32+
)
2833

2934
type Attributes []mesos.Attribute
3035

36+
func (attrs Attributes) String() string {
37+
if attrs == nil {
38+
return "[]"
39+
}
40+
strs := make([]string, len(attrs))
41+
for i, attr := range attrs {
42+
strs[i] = attr.String()
43+
}
44+
return fmt.Sprintf("[%s]", strings.Join(strs, "; "))
45+
}
46+
3147
func (attrs Attributes) Get(attributeName string) (value string, ok bool) {
3248
for _, a := range attrs {
3349
if a.Name == attributeName {

core/task/constraint/constraints.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (cts Constraints) String() string {
8181
for i, ct := range cts {
8282
strs[i] = ct.String()
8383
}
84-
return fmt.Sprintf("[%s]", strings.Join(strs, ", "))
84+
return fmt.Sprintf("[%s]", strings.Join(strs, "; "))
8585
}
8686

8787
func (cts Constraints) MergeParent(parentConstraints Constraints) (merged Constraints) {

0 commit comments

Comments
 (0)