drivers: use consts for task handle version

This commit is contained in:
Nick Ethier
2019-01-16 21:52:31 -05:00
parent be81ecd5e6
commit 7d80fe286f
18 changed files with 80 additions and 33 deletions

View File

@@ -34,6 +34,10 @@ const (
// The key populated in Node Attributes to indicate presence of the Java driver
driverAttr = "driver.java"
driverVersionAttr = "driver.java.version"
// taskHandleVersion is the version of task handle which this driver sets
// and understands how to decode driver state
taskHandleVersion = 1
)
var (
@@ -255,7 +259,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
if err != nil {
return err
}
return d.recoverPre0_9Task(handle.Config, reattachConfig)
return d.recoverPre09task(handle.Config, reattachConfig)
}
// If already attached to handle there's nothing to recover.
@@ -325,7 +329,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
d.logger.Info("starting java task", "driver_cfg", hclog.Fmt("%+v", driverConfig), "args", args)
handle := drivers.NewTaskHandle(1)
handle := drivers.NewTaskHandle(taskHandleVersion)
handle.Config = cfg
pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out")

View File

@@ -10,7 +10,7 @@ import (
"github.com/hashicorp/nomad/plugins/drivers"
)
func (d *Driver) recoverPre0_9Task(config *drivers.TaskConfig, reattach *plugin.ReattachConfig) error {
func (d *Driver) recoverPre09task(config *drivers.TaskConfig, reattach *plugin.ReattachConfig) error {
config.ID = fmt.Sprintf("pre09-%s", uuid.Generate())
exec, pluginClient, err := executor.ReattachToPre09Executor(reattach,
d.logger.With("task_name", config.Name, "alloc_id", config.AllocID))