open-nomad/drivers/java/driver_pre09.go
2019-01-16 21:52:31 -05:00

37 lines
991 B
Go

package java
import (
"fmt"
"time"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/plugins/drivers"
)
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))
if err != nil {
d.logger.Error("failed to reattach to executor", "error", err, "task_name", config.Name)
return fmt.Errorf("failed to reattach to executor: %v", err)
}
h := &taskHandle{
exec: exec,
pid: reattach.Pid,
pluginClient: pluginClient,
taskConfig: config,
procState: drivers.TaskStateRunning,
startedAt: time.Now(),
exitResult: &drivers.ExitResult{},
}
d.tasks.Set(config.ID, h)
go h.run()
return nil
}