zhisheng17/flink-learning · error · ResourceManagerException

Error to parse KubernetesWorkerNode from ${resourceID}.

Error message

Error to parse KubernetesWorkerNode from ${resourceID}.

What it means

KubernetesWorkerNode.getAttempt parses the attempt number from a TaskManager pod name matching the pattern \S+-taskmanager-([\d]+)-([\d]+). If the ResourceID does not match the expected TaskManager pod naming scheme, a ResourceManagerException is thrown.

Source

Thrown at flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/KubernetesWorkerNode.java:55

	 * This pattern should be updated when {@link KubernetesResourceManagerDriver#TASK_MANAGER_POD_FORMAT} changed.
	 */
	private static final Pattern TASK_MANAGER_POD_PATTERN = Pattern.compile("\\S+-taskmanager-([\\d]+)-([\\d]+)");

	KubernetesWorkerNode(ResourceID resourceID) {
		this.resourceID = checkNotNull(resourceID);
	}

	@Override
	public ResourceID getResourceID() {
		return resourceID;
	}

	public long getAttempt() throws ResourceManagerException {
		Matcher matcher = TASK_MANAGER_POD_PATTERN.matcher(resourceID.toString());
		if (matcher.find()) {
			return Long.parseLong(matcher.group(1));
		} else {
			throw new ResourceManagerException("Error to parse KubernetesWorkerNode from " + resourceID + ".");
		}
	}
}

View on GitHub (pinned to d731cee761)

Solutions

  1. Ensure TaskManager pods are created by the KubernetesResourceManagerDriver so names follow the taskmanager-<attempt>-<index> format.
  2. If you changed kubernetes.taskmanager.pod naming/prefix, revert it or update TASK_MANAGER_POD_PATTERN to match (the code comments require keeping them in sync).
  3. Log/inspect resourceID.toString() to see the offending value and compare it against the expected pattern.
  4. Do not pass hand-crafted ResourceIDs to KubernetesWorkerNode; construct via KubernetesResourceManagerDriver's worker creation path.

Example fix

// before: arbitrary resource id
new KubernetesWorkerNode(ResourceID.generate()).getAttempt(); // throws
// after: id derived from an actual TM pod name
String podName = "flink-cluster-taskmanager-3-1";
new KubernetesWorkerNode(new ResourceID(podName)).getAttempt(); // 3
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern TM = Pattern.compile("\\S+-taskmanager-([\\d]+)-([\\d]+)");
boolean isParseableKubernetesWorker(ResourceID id) { return TM.matcher(id.toString()).find(); }

Type guard

boolean isTaskManagerPodName(ResourceID id) {
    return id != null && Pattern.compile("\\S+-taskmanager-([\\d]+)-([\\d]+)").matcher(id.toString()).find();
}

Try / catch

try {
    long attempt = workerNode.getAttempt();
} catch (ResourceManagerException e) {
    LOG.warn("Non-standard worker id: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling getAttempt (used by attempt()) with a ResourceID whose string does not end with '<something>-taskmanager-<num>-<num>' — e.g. a manually built ResourceID, a renamed pod, or an ID produced by a different TASK_MANAGER_POD_FORMAT.

Common situations: Custom pod name templates configured via KubernetesResourceManagerDriver pod format changed without updating the parser; pods created outside the driver (hand-spun TaskManagers); mixing worker IDs from another resource manager (YARN) into Kubernetes code; attempting-based recovery enabled with mismatched naming.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06). Data as JSON: /api/errors/d655eae0ac00db9a. Report an issue: GitHub.