zhisheng17/flink-learning · error · KubernetesException
ConfigMap {configMapName} does not exists. It may be deleted
Error message
ConfigMap {configMapName} does not exists. It may be deleted externally. What it means
KubernetesStateHandleStore.getAndLock throws getConfigMapNotExistException when kubeClient.getConfigMap(configMapName) returns empty, meaning the entire HA ConfigMap is gone — the message warns it may have been deleted externally. Flink's HA relies on this ConfigMap persisting job state handles; its absence breaks leader election/recovery assumptions. Callers get a distinct error from key-missing so they can react to total storage loss.
Source
Thrown at flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesStateHandleStore.java:243
*
* @throws IOException if the method failed to deserialize the stored state handle
* @throws NotExistException when the name does not exist
* @throws Exception if get state handle from ConfigMap failed
*/
@Override
public RetrievableStateHandle<T> getAndLock(String key) throws Exception {
checkNotNull(key, "Key in ConfigMap.");
final Optional<KubernetesConfigMap> optional = kubeClient.getConfigMap(configMapName);
if (optional.isPresent()) {
final KubernetesConfigMap configMap = optional.get();
if (configMap.getData().containsKey(key)) {
return deserializeObject(configMap.getData().get(key));
} else {
throw getKeyNotExistException(key);
}
} else {
throw getConfigMapNotExistException();
}
}
/**
* Gets all available state handles from Kubernetes.
*
* @return All state handles from ConfigMap.
*/
@Override
public List<Tuple2<RetrievableStateHandle<T>, String>> getAllAndLock() {
return kubeClient.getConfigMap(configMapName)
.map(
configMap -> {
final List<Tuple2<RetrievableStateHandle<T>, String>> stateHandles = new ArrayList<>();
configMap.getData().entrySet().stream()
.filter(entry -> configMapKeyFilter.test(entry.getKey()))
.forEach(entry -> {View on GitHub (pinned to d731cee761)
Solutions
- Confirm the ConfigMap exists in the expected namespace: kubectl -n <ns> get configmap <configMapName>
- Check high-availability configuration (namespace, cluster-id) hasn't changed between savepoint and recovery
- Recreate the ConfigMap from backup or restore HA metadata from an alternative storage backend
- Investigate external deletion (TTL controllers, cleanup scripts, RBAC-restricted operators) and disable or reconfigure it
Example fix
// before kubectl delete configmap flink-cluster-ha --namespace flink // after kubectl -n flink get configmap flink-cluster-ha # verify before any cleanup; exclude *-ha configmaps from TTL/cleanup policies
Defensive patterns
Strategy: try-catch
Validate before calling
if (!kubeClient.getConfigMap(configMapName).isPresent()) {
LOG.error("HA ConfigMap {} missing — state handles unavailable", configMapName);
return Optional.empty();
} Try / catch
try {
return stateHandleStore.getAndLock(configMapName, key);
} catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("does not exists")) {
LOG.error("HA ConfigMap {} was deleted externally; manual restore required", configMapName);
}
throw e;
} Prevention
- Exclude Flink HA ConfigMaps from TTL controllers and cleanup scripts
- Pin high-availability.namespace/cluster-id config so lookups never drift
- Alert on ConfigMap deletion events in the Flink namespace
When it happens
Trigger: Calling getAndLock(configMapName, key) where the Kubernetes API returns no ConfigMap for configMapName — it was never created, deleted manually/by a GC controller, or the client is pointed at the wrong namespace.
Common situations: Someone ran kubectl delete on HA ConfigMaps, a namespace-scoped cleanup job (or TTL controller) removed them, or the Flink configuration's namespace/cluster-id changed so the store looks in the wrong place.
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
- Failed to update ConfigMap {} since current KubernetesCheckp
- Failed to clear job state in ConfigMap {} for job {}
- Failed to set {} state in ConfigMap {} for job {}
- {} already exists in ConfigMap {}
- Could not find {} in ConfigMap {}
AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06).
Data as JSON: /api/errors/c7f53ae5cb4cbb7d.
Report an issue: GitHub.