apache/druid · error · IllegalArgumentException

Task [ ] requested pod template [ ] via context key, but no…

Error message

Task [%s] requested pod template [%s] via context key, but no such template is configured.

What it means

Thrown by DynamicConfigPodTemplateSelector.getPodTemplateForTask when a task sets the pod-template context key (DruidK8sConstants.TASK_CONTEXT_POD_TEMPLATE_SELECTION_KEY) to a template name that is not registered in the selector's podTemplates map, and task-side pod template selection is enabled via effectiveConfig.isAllowTaskPodTemplateSelection(). Druid rejects the task launch rather than silently falling back to the base template.

Solutions

  1. Define the missing template on the Overlord: druid.indexer.runner.k8s.podTemplate.<requested-name>=/path/to/template.yaml
  2. Correct the context value in the task/ingestion spec to match a configured template name exactly
  3. Verify template names are deployed to all Overlords the task may be routed to
  4. If context-driven selection is undesired, disable druid.indexer.runner.k8s.allowTaskPodTemplateSelection

Example fix

// before (task context)
"context": { "k8sPodTemplateSelection": "batchHeavy" }  // template not configured

// after (Overlord config)
druid.indexer.runner.k8s.podTemplate.batchHeavy=/etc/druid/k8s/batch-heavy.yaml
# task context stays as-is, template now exists
Defensive patterns

Strategy: validation

Validate before calling

// Before submitting a task with a pod template context override
String requested = task.getContextValue("k8sPodTemplateSelection");
if (requested != null) {
    String prop = "druid.indexer.runner.k8s.podTemplate." + requested;
    if (overlordProps.getProperty(prop) == null) {
        throw new IllegalArgumentException(
            "Pod template '" + requested + "' not configured on Overlord (missing " + prop + ")");
    }
}

Try / catch

try {
    PodTemplate t = selector.getPodTemplateForTask(task, effectiveConfig);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("no such template is configured")) {
        // log and fall back to default selection instead of failing the task
        return defaultPodTemplate;
    }
    throw e;
}

Prevention

When it happens

Trigger: A task's context contains e.g. {"k8sPodTemplateSelection": "myTemplate"} (context key value) while no druid.indexer.runner.k8s.podTemplate.myTemplate property is configured on the Overlord, and druid.indexer.runner.k8s.allowTaskPodTemplateSelection=true.

Common situations: Ingestion specs copied from examples referencing template names defined in another cluster; template renamed/removed on the Overlord while old task specs still reference it; allowTaskPodTemplateSelection enabled but the operator forgot to define every template tasks reference; typo in the context value.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/4943446354b6f63f. Report an issue: GitHub.

Appendix: source

Thrown at extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/taskadapter/DynamicConfigPodTemplateSelector.java:133

      throw new IAE(e, "Failed to load pod template file for [%s] at [%s]", property, podTemplateFile);
    }
  }

  @SuppressWarnings("ResultOfMethodCallIgnored")
  private void validateTemplateSupplier(Supplier<PodTemplate> templateSupplier) throws IAE
  {
    templateSupplier.get();
  }

  @Override
  public Optional<PodTemplateWithName> getPodTemplateForTask(Task task)
  {
    String requested = task.getContextValue(DruidK8sConstants.TASK_CONTEXT_POD_TEMPLATE_SELECTION_KEY);

    if (requested != null && effectiveConfig.isAllowTaskPodTemplateSelection()) {
      Supplier<PodTemplate> supplier = podTemplates.get(requested);
      if (supplier == null) {
        throw new IAE(
            "Task [%s] requested pod template [%s] via context key, but no such template is configured.",
            task.getId(), requested
        );
      }
      log.debug("Pod template [%s] selected for task [%s] via context override.", requested, task.getId());
      return Optional.of(new PodTemplateWithName(requested, supplier.get()));
    } else if (requested != null) {
      log.warn(
          "Task [%s] set context key [%s] but pod template override is disabled; ignoring.",
          task.getId(),
          DruidK8sConstants.TASK_CONTEXT_POD_TEMPLATE_SELECTION_KEY
      );
    }

    return Optional.of(effectiveConfig.getPodTemplateSelectStrategy().getPodTemplateForTask(task, podTemplates));
  }

  @Override

View on GitHub (pinned to 9b90983fd2)