diff --git a/manage.go b/manage.go index da80542f39..90074f9c5c 100644 --- a/manage.go +++ b/manage.go @@ -75,7 +75,7 @@ func manage(c *cli.Context) { s := scheduler.NewScheduler( cluster, &strategy.BinPackingPlacementStrategy{OvercommitRatio: 0.05}, - []filter.Filter{&filter.AttributeFilter{}, &filter.PortFilter{}}, + []filter.Filter{&filter.LabelFilter{}, &filter.PortFilter{}}, ) log.Fatal(api.ListenAndServe(cluster, s, c.String("addr"), c.App.Version)) diff --git a/scheduler/filter/attribute.go b/scheduler/filter/attribute.go index 248834345e..c5ccf361ea 100644 --- a/scheduler/filter/attribute.go +++ b/scheduler/filter/attribute.go @@ -8,12 +8,11 @@ import ( "github.com/samalba/dockerclient" ) -// AttributeFilter selects only nodes that match certain attributes. Attributes -// include storagedriver, executiondriver and so on. -type AttributeFilter struct { +// LabelFilter selects only nodes that match certain labels. +type LabelFilter struct { } -func (f *AttributeFilter) extractConstraints(env []string) map[string]string { +func (f *LabelFilter) extractConstraints(env []string) map[string]string { constraints := make(map[string]string) for _, e := range env { if strings.HasPrefix(e, "constraint:") { @@ -25,7 +24,7 @@ func (f *AttributeFilter) extractConstraints(env []string) map[string]string { return constraints } -func (f *AttributeFilter) Filter(config *dockerclient.ContainerConfig, nodes []*cluster.Node) ([]*cluster.Node, error) { +func (f *LabelFilter) Filter(config *dockerclient.ContainerConfig, nodes []*cluster.Node) ([]*cluster.Node, error) { constraints := f.extractConstraints(config.Env) for k, v := range constraints { candidates := []*cluster.Node{} diff --git a/scheduler/filter/attribute_test.go b/scheduler/filter/attribute_test.go index acebe3ab04..bd47b6c384 100644 --- a/scheduler/filter/attribute_test.go +++ b/scheduler/filter/attribute_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" ) -func TestAttributeFilter(t *testing.T) { +func TestLabeleFilter(t *testing.T) { var ( - f = AttributeFilter{} + f = LabelFilter{} nodes = []*cluster.Node{ cluster.NewNode("node-1"), cluster.NewNode("node-2"),