From 81e0142768f56fbc5c4f0864a4f264f05b48242b Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 1 Jun 2018 15:48:14 -0700 Subject: [PATCH 1/3] Disable Exec on non-linux platforms This PR disables exec on non-linux platforms --- client/driver/exec_default.go | 2 +- client/driver/exec_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/client/driver/exec_default.go b/client/driver/exec_default.go index 05a609e9d4c..3344727a5a5 100644 --- a/client/driver/exec_default.go +++ b/client/driver/exec_default.go @@ -9,6 +9,6 @@ import ( func (d *ExecDriver) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error { d.fingerprintSuccess = helper.BoolToPtr(false) - resp.Detected = true + resp.Detected = false return nil } diff --git a/client/driver/exec_test.go b/client/driver/exec_test.go index 3fab5c8cf5c..326c1de39e0 100644 --- a/client/driver/exec_test.go +++ b/client/driver/exec_test.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "path/filepath" "reflect" + "runtime" "strings" "testing" "time" @@ -20,6 +21,30 @@ import ( ctestutils "github.com/hashicorp/nomad/client/testutil" ) +// Test that we do not enable exec on non-linux machines +func TestExecDriver_Fingerprint_NonLinux(t *testing.T) { + if !testutil.IsTravis() { + t.Parallel() + } + if runtime.GOOS == "linux" { + t.Skip("Test only available not on Linux") + } + + d := NewExecDriver(&DriverContext{}) + node := &structs.Node{} + + request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node} + var response cstructs.FingerprintResponse + err := d.Fingerprint(request, &response) + if err != nil { + t.Fatalf("err: %v", err) + } + + if response.Detected { + t.Fatalf("expected response to be applicable") + } +} + func TestExecDriver_Fingerprint(t *testing.T) { if !testutil.IsTravis() { t.Parallel() From 55c183beb919e6823f0cac1ffd23891c493fdb75 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 1 Jun 2018 15:50:34 -0700 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4438f221ec..6cbeaca653a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ BUG FIXES: Consul agent [GH-4365] * driver/docker: Fix docker credential helper support [[GH-4266](https://github.com/hashicorp/nomad/issues/4266)] * driver/docker: Fix panic when docker client configuration options are invalid [[GH-4303](https://github.com/hashicorp/nomad/issues/4303)] + * driver/exec: Disable exec on non-linux platforms [GH-4366] * rpc: Fix RPC tunneling when running both client/server on one machine [[GH-4317](https://github.com/hashicorp/nomad/issues/4317)] * ui: Track the method in XHR tracking to prevent errant ACL error dialogs when stopping a job [[GH-4319](https://github.com/hashicorp/nomad/issues/4319)] * ui: Use Polling instead of Streaming for logs in Safari [[GH-4335](https://github.com/hashicorp/nomad/issues/4335)] From 034262d889e43db2fcc00ee1501302426bbd1127 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 1 Jun 2018 15:51:54 -0700 Subject: [PATCH 3/3] fix test message --- client/driver/exec_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/driver/exec_test.go b/client/driver/exec_test.go index 326c1de39e0..3dcbddd2a46 100644 --- a/client/driver/exec_test.go +++ b/client/driver/exec_test.go @@ -41,7 +41,7 @@ func TestExecDriver_Fingerprint_NonLinux(t *testing.T) { } if response.Detected { - t.Fatalf("expected response to be applicable") + t.Fatalf("Should not be detected on non-linux platforms") } }