Skip to content

Commit

Permalink
Remove unneeded TaskConfig attribute from TaskState struct
Browse files Browse the repository at this point in the history
When recovering a task via `RecoverTask` we can just decode the driver config
directly from the passed `TaskHandle` and do not need to encode it again inside
the `TaskState` struct.
  • Loading branch information
JanMa committed Oct 3, 2020
1 parent 07fa730 commit 9a578ff
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions nspawn/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ type Config struct {
// during recovery.
type TaskState struct {
ReattachConfig *pstructs.ReattachConfig
TaskConfig *drivers.TaskConfig
MachineName string
StartedAt time.Time
}
Expand Down Expand Up @@ -257,7 +256,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
}

var driverConfig drivers.TaskConfig
if err := taskState.TaskConfig.DecodeDriverConfig(&driverConfig); err != nil {
if err := handle.Config.DecodeDriverConfig(&driverConfig); err != nil {
return fmt.Errorf("failed to decode driver config: %v", err)
}

Expand All @@ -283,12 +282,12 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {

exec: execImpl,
pluginClient: pluginClient,
taskConfig: taskState.TaskConfig,
taskConfig: handle.Config,
procState: drivers.TaskStateRunning,
startedAt: taskState.StartedAt,
}

d.tasks.Set(taskState.TaskConfig.ID, h)
d.tasks.Set(handle.Config.ID, h)

go h.run()

Expand Down Expand Up @@ -564,7 +563,6 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
driverState := TaskState{
ReattachConfig: pstructs.ReattachConfigFromGoPlugin(pluginClient.ReattachConfig()),
MachineName: driverConfig.Machine,
TaskConfig: cfg,
StartedAt: h.startedAt,
}

Expand Down

0 comments on commit 9a578ff

Please sign in to comment.