Purushottam Sinha created FLINK-40542:
-----------------------------------------

             Summary: Kubernetes Operator: session cluster deleted when running 
jobs can't be queried
                 Key: FLINK-40542
                 URL: https://issues.apache.org/jira/browse/FLINK-40542
             Project: Flink
          Issue Type: Bug
          Components: Kubernetes Operator
            Reporter: Purushottam Sinha


Problem
When a session FlinkDeployment with block-on-unmanaged-jobs enabled (default) 
is deleted while the JobManager is unreachable, the operator can't enumerate 
running jobs but deletes the cluster anyway, stopping unmanaged jobs without a 
checkpoint — only a WARN is logged. The safety guard fails open exactly when it 
can't be evaluated.

Evidence
 - SessionReconciler.getNonTerminalJobs returns Set.of() in its catch (main @ 
38a9f197, line 171); cleanupInternal treats an empty set as "no running jobs, 
safe to delete".
 - Live minikube repro on unpatched main: JM scaled to 0 + delete → Stopping 
session cluster → cluster deleted (finalizer removed).

Proposed fix
 - Return Optional<Set<JobID>>; empty Optional (query failed) is distinct from 
present empty set (no jobs).
 - On the indeterminate case, block deletion and emit a CleanupFailed event, 
mirroring the block-on-session-jobs branch; reschedule so it lifts once the JM 
is reachable.
 - Close RestClusterClient via try-with-resources; bound the jobs request with 
the Flink client timeout.

Acceptance
 - With the JM unreachable at delete time, the cluster is not deleted and a 
CleanupFailed event is emitted.
 - Deletion proceeds once the JM is reachable and the cluster is empty.
 - Does not reintroduce the FLINK-39618 deadlock (block reschedules and lifts).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to