Marvin Froeder created FLINK-41820:
--------------------------------------
Summary: Operator reports running BATCH jobs as CREATED until they
finish
Key: FLINK-41820
URL: https://issues.apache.org/jira/browse/FLINK-41820
Project: Flink
Issue Type: Bug
Components: Kubernetes Operator
Affects Versions: kubernetes-operator-1.16.1
Reporter: Marvin Froeder
h3. Problem
{{status.jobStatus.state}} of a FlinkDeployment running a BATCH job stays
{{CREATED}} for the whole run, while the JobManager reports the job as
{{RUNNING}}. The CR goes straight from {{CREATED}} to {{FINISHED}} and never
shows {{RUNNING}}; {{lifecycleState}} stays {{DEPLOYED}} instead of {{STABLE}}.
The cause is {{JobStatusUtils#getEffectiveStatus}} (flink-autoscaler), used by
{{AbstractFlinkService#getJobStatus}}:
{code:java}
boolean allRunningOrFinished = details.getNumTasks() == (numRunning +
numFinished);
if (JobStatus.RUNNING.equals(effectiveStatus) && !allRunningOrFinished) {
return JobStatus.CREATED;
}
{code}
This was added in FLINK-34906 so the autoscaler does not act while some tasks
of a streaming job are not yet running. In BATCH mode with blocking exchanges,
downstream tasks are only scheduled after their upstream finishes, so a running
batch job almost always has tasks in {{CREATED}}. The condition does not hold
until the end, and the downgrade applies to the CR status, not just to the
autoscaler.
h3. Observed
Flink 2.3.0, operator 1.16.1, application mode, {{execution.runtime-mode:
BATCH}}, adaptive batch scheduler, {{execution.batch-shuffle-mode:
ALL_EXCHANGES_BLOCKING}}.
At the same moment:
* Flink Web UI: job {{RUNNING}}; tasks 18 total = 16 FINISHED, 1 RUNNING, 1
CREATED
* {{kubectl get flinkdeployment}}: {{JOB STATUS: CREATED}}, {{LIFECYCLE STATE:
DEPLOYED}}
The JobManager's {{runningTime}} metric keeps increasing for the whole run,
confirming Flink considers the job RUNNING. The operator logs no
{{JOBSTATUSCHANGED}} event until {{CREATED to FINISHED}}. An 84 minute job was
reported {{CREATED}} for all 84 minutes.
h3. Reproduce
Any multi-stage bounded job in BATCH mode, e.g. a bounded source followed by a
{{GROUP BY}} or {{ORDER BY}}, running long enough to observe. While it runs,
the Web UI shows RUNNING and the CR shows CREATED.
h3. Impact
Anything that waits for {{jobStatus.state == RUNNING}} (deployment pipelines,
health checks, the printer column) treats a healthy batch job as not started,
and times out or reports a failed start, although the job completes normally.
h3. Possible fix
Report the JobManager's status in {{status.jobStatus.state}} as is, and keep
the "all tasks running" check inside the autoscaler, where FLINK-34906 needs
it. Alternatively, skip the downgrade when the job runs in BATCH mode
({{execution.runtime-mode}}).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)