Skip to content

Commit

Permalink
Disable lxc by default
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Oct 13, 2016
1 parent af8a20b commit 1566b97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/driver/lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (
)

const (
// The option that enables this driver in the Config.Options map.
lxcConfigOption = "driver.lxc.enable"

// containerMonitorIntv is the interval at which the driver checks if the
// container is still alive
containerMonitorIntv = 2 * time.Second
Expand Down Expand Up @@ -143,6 +146,10 @@ func (d *LxcDriver) Validate(config map[string]interface{}) error {

// Fingerprint fingerprints the lxc driver configuration
func (d *LxcDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
enabled := cfg.ReadBoolDefault(lxcConfigOption, false)
if !enabled {
return false, nil
}
version := lxc.Version()
if version == "" {
return false, nil
Expand Down
10 changes: 9 additions & 1 deletion client/driver/lxc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ func TestLxcDriver_Fingerprint(t *testing.T) {
if err != nil {
t.Fatalf("err: %v", err)
}
if apply {
t.Fatalf("should not apply by default")
}

apply, err = d.Fingerprint(&config.Config{Options: map[string]string{lxcConfigOption: "1"}}, node)
if err != nil {
t.Fatalf("err: %v", err)
}
if !apply {
t.Fatalf("should apply")
t.Fatalf("should apply with config")
}
if node.Attributes["driver.lxc"] == "" {
t.Fatalf("missing driver")
Expand Down

0 comments on commit 1566b97

Please sign in to comment.