hashicorp/nomad · info

ErrTaskNotFound

ErrTaskNotFound

Error message

task not found for given id

What it means

drivers.ErrTaskNotFound (plugins/drivers/errors.go:8) is the sentinel error returned by driver handles when the task no longer exists inside the driver plugin (e.g. the task already exited or the plugin was restarted). In Nomad's task runner (client/allocrunner/taskrunner/task_runner.go:1109,1134) it is treated as success: a missing task during restore or Kill means there is nothing left to stop.

Source

Thrown at plugins/drivers/errors.go:8

// Copyright IBM Corp. 2015, 2026
// SPDX-License-Identifier: MPL-2.0

package drivers

import "errors"

var ErrTaskNotFound = errors.New("task not found for given id")

var ErrChannelClosed = errors.New("channel closed")

var DriverRequiresRootMessage = "Driver must run as root"

var NoCgroupMountMessage = "Failed to discover cgroup mount point"

var CgroupMountEmpty = "Cgroup mount point unavailable"

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Nothing to fix in most cases — treat ErrTaskNotFound as task-already-stopped (Nomad does: returns nil)
  2. If seen unexpectedly, check driver health and task state (nomad alloc status) to confirm the task truly exited
  3. If restores persistently miss tasks, restart the client or driver plugin so state resyncs, and check driver logs for task table loss

Example fix

// before
if err := handle.Kill(); err != nil {
    return err
}
// after
if err := handle.Kill(); err != nil {
    if errors.Is(err, drivers.ErrTaskNotFound) {
        return nil // task already gone
    }
    return err
}
Defensive patterns

Strategy: type-guard

Type guard

func isTaskNotFound(err error) bool { return errors.Is(err, drivers.ErrTaskNotFound) }

Try / catch

if err := handle.Kill(); err != nil {
    if errors.Is(err, drivers.ErrTaskNotFound) {
        return nil // already stopped
    }
    return fmt.Errorf("kill failed: %w", err)
}

Prevention

When it happens

Trigger: Calling handle.Kill() or restore/recover logic for a task whose process the driver no longer tracks — the task already terminated, the exec plugin lost its task table, or the driver plugin process was restarted and lost state.

Common situations: Node crash/restart recovery where Nomad tries to restore running tasks but drivers have no record; killing a task that exited concurrently; docker/exec driver cleanup racing with the kill path.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/49ebbb3d76ae81a4. Report an issue: GitHub.