Rename attributes to labels.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2014-11-21 13:57:03 -08:00
parent bf04e484f9
commit 1dead64e11
3 changed files with 7 additions and 8 deletions

View File

@ -75,7 +75,7 @@ func manage(c *cli.Context) {
s := scheduler.NewScheduler( s := scheduler.NewScheduler(
cluster, cluster,
&strategy.BinPackingPlacementStrategy{OvercommitRatio: 0.05}, &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)) log.Fatal(api.ListenAndServe(cluster, s, c.String("addr"), c.App.Version))

View File

@ -8,12 +8,11 @@ import (
"github.com/samalba/dockerclient" "github.com/samalba/dockerclient"
) )
// AttributeFilter selects only nodes that match certain attributes. Attributes // LabelFilter selects only nodes that match certain labels.
// include storagedriver, executiondriver and so on. type LabelFilter struct {
type AttributeFilter struct {
} }
func (f *AttributeFilter) extractConstraints(env []string) map[string]string { func (f *LabelFilter) extractConstraints(env []string) map[string]string {
constraints := make(map[string]string) constraints := make(map[string]string)
for _, e := range env { for _, e := range env {
if strings.HasPrefix(e, "constraint:") { if strings.HasPrefix(e, "constraint:") {
@ -25,7 +24,7 @@ func (f *AttributeFilter) extractConstraints(env []string) map[string]string {
return constraints 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) constraints := f.extractConstraints(config.Env)
for k, v := range constraints { for k, v := range constraints {
candidates := []*cluster.Node{} candidates := []*cluster.Node{}

View File

@ -8,9 +8,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestAttributeFilter(t *testing.T) { func TestLabeleFilter(t *testing.T) {
var ( var (
f = AttributeFilter{} f = LabelFilter{}
nodes = []*cluster.Node{ nodes = []*cluster.Node{
cluster.NewNode("node-1"), cluster.NewNode("node-1"),
cluster.NewNode("node-2"), cluster.NewNode("node-2"),