From aa713a4d9fb3ebfc80b0d743daca2bbb0c11d7c3 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Wed, 30 Jan 2019 14:22:29 -0500 Subject: [PATCH] client: fix bug during 0.8 state up grade that causes external drivers to fail --- client/state/08types.go | 2 ++ drivers/docker/driver_pre09.go | 2 -- drivers/exec/driver_pre09.go | 2 -- drivers/java/driver_pre09.go | 2 -- drivers/qemu/driver_pre09.go | 2 -- drivers/rawexec/driver_pre09.go | 2 -- drivers/rkt/driver_pre09.go | 2 -- 7 files changed, 2 insertions(+), 12 deletions(-) diff --git a/client/state/08types.go b/client/state/08types.go index aaa839803..271fecf58 100644 --- a/client/state/08types.go +++ b/client/state/08types.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/hashicorp/nomad/client/allocrunner/taskrunner/state" + "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" @@ -98,6 +99,7 @@ func (t *taskRunnerState08) Upgrade(allocID, taskName string) (*state.LocalState // Add necessary fields to TaskConfig ls.TaskHandle = drivers.NewTaskHandle(drivers.Pre09TaskHandleVersion) ls.TaskHandle.Config = &drivers.TaskConfig{ + ID: fmt.Sprintf("pre09-%s", uuid.Generate()), Name: taskName, AllocID: allocID, } diff --git a/drivers/docker/driver_pre09.go b/drivers/docker/driver_pre09.go index 9de349492..ed06a956d 100644 --- a/drivers/docker/driver_pre09.go +++ b/drivers/docker/driver_pre09.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/drivers/docker/docklog" "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" ) @@ -22,7 +21,6 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error { return fmt.Errorf("failed to decode reattach config from pre09 handle: %v", err) } - h.Config.ID = fmt.Sprintf("pre09-%s", uuid.Generate()) exec, pluginClient, err := executor.ReattachToPre09Executor(reattach, d.logger.With("task_name", h.Config.Name, "alloc_id", h.Config.AllocID)) if err != nil { diff --git a/drivers/exec/driver_pre09.go b/drivers/exec/driver_pre09.go index a81835194..5b063ea24 100644 --- a/drivers/exec/driver_pre09.go +++ b/drivers/exec/driver_pre09.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" ) @@ -22,7 +21,6 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error { return fmt.Errorf("failed to decode reattach config from pre09 handle: %v", err) } - h.Config.ID = fmt.Sprintf("pre09-%s", uuid.Generate()) exec, pluginClient, err := executor.ReattachToPre09Executor(reattach, d.logger.With("task_name", h.Config.Name, "alloc_id", h.Config.AllocID)) if err != nil { diff --git a/drivers/java/driver_pre09.go b/drivers/java/driver_pre09.go index 6682f9fa1..80d1fc5ca 100644 --- a/drivers/java/driver_pre09.go +++ b/drivers/java/driver_pre09.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" ) @@ -22,7 +21,6 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error { return fmt.Errorf("failed to decode reattach config from pre09 handle: %v", err) } - h.Config.ID = fmt.Sprintf("pre09-%s", uuid.Generate()) exec, pluginClient, err := executor.ReattachToPre09Executor(reattach, d.logger.With("task_name", h.Config.Name, "alloc_id", h.Config.AllocID)) if err != nil { diff --git a/drivers/qemu/driver_pre09.go b/drivers/qemu/driver_pre09.go index 15ce5f39f..10d810ee0 100644 --- a/drivers/qemu/driver_pre09.go +++ b/drivers/qemu/driver_pre09.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" ) @@ -22,7 +21,6 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error { return fmt.Errorf("failed to decode reattach config from pre09 handle: %v", err) } - h.Config.ID = fmt.Sprintf("pre09-%s", uuid.Generate()) exec, pluginClient, err := executor.ReattachToPre09Executor(reattach, d.logger.With("task_name", h.Config.Name, "alloc_id", h.Config.AllocID)) if err != nil { diff --git a/drivers/rawexec/driver_pre09.go b/drivers/rawexec/driver_pre09.go index 0ed5d9a37..90001df34 100644 --- a/drivers/rawexec/driver_pre09.go +++ b/drivers/rawexec/driver_pre09.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" ) @@ -22,7 +21,6 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error { return fmt.Errorf("failed to decode reattach config from pre09 handle: %v", err) } - h.Config.ID = fmt.Sprintf("pre09-%s", uuid.Generate()) exec, pluginClient, err := executor.ReattachToPre09Executor(reattach, d.logger.With("task_name", h.Config.Name, "alloc_id", h.Config.AllocID)) if err != nil { diff --git a/drivers/rkt/driver_pre09.go b/drivers/rkt/driver_pre09.go index ed4f9adba..e974e9c09 100644 --- a/drivers/rkt/driver_pre09.go +++ b/drivers/rkt/driver_pre09.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/plugins/drivers" pstructs "github.com/hashicorp/nomad/plugins/shared/structs" ) @@ -22,7 +21,6 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error { return fmt.Errorf("failed to decode reattach config from pre09 handle: %v", err) } - h.Config.ID = fmt.Sprintf("pre09-%s", uuid.Generate()) exec, pluginClient, err := executor.ReattachToPre09Executor(reattach, d.logger.With("task_name", h.Config.Name, "alloc_id", h.Config.AllocID)) if err != nil {