zhangshenghang opened a new pull request, #13780:
URL: https://github.com/apache/seatunnel/pull/13780

   Yes — I am contributing this change to Apache SeaTunnel, and I confirm it 
follows the project's
   contribution conventions (English PR title/description, one focused change, 
formatting and E2E
   validated locally). This is a test-only change: no production code, 
configuration default, REST/API
   or data format is modified.
   
   ## What this PR adds
   
   Adds `PendingJobWorkerJoinAdmissionIT` and its fixture
   `stream_fake_to_console_pending_worker_join.conf`, an E2E regression guard 
for the engine contract
   that a job submitted before any worker exists is queued and then admitted by 
worker registration
   alone.
   
   ## The contract
   
   Cluster bootstrap is not atomic: the master becomes active first and a job 
can arrive (CLI, REST,
   orchestrator) while the first worker is still starting. The engine must
   
   1. accept the submission and place the job into the pending queue under 
`ScheduleStrategy.WAIT`
      (`CoordinatorService#submitJob` creates the `JobMaster`, persists the job 
info and queues it);
   2. keep the job `PENDING` — neither `FAILED` nor `RUNNING` — while no worker 
can satisfy its slot
      demand;
   3. admit the *same* `JobMaster` instance once capacity appears: the 
pending-job scheduler
      re-evaluates `JobMaster#preApplyResources()` and runs the queued master 
instead of rebuilding it;
   4. start the whole runtime of the admitted job, including periodic 
checkpoint scheduling;
   5. leave the cluster capacity intact again after the job ends.
   
   The fixture is a streaming `FakeSource -> Console` job with `parallelism = 
1`. Such a pipeline needs
   exactly two slots: one source enumerator coordinator task group plus one 
data task group. The worker
   that joins later owns exactly those two fixed slots, so the job can only be 
admitted once its whole
   slot demand is satisfiable — admission is not faked with a partial 
reservation.
   
   ## Test flow
   
   1. Start a master-only cluster (`workerCount == 0`), with fixed slots and 
`WAIT`.
   2. Submit the job; require that the client observes `PENDING`, that the 
coordinator's pending queue
      contains the job id and that a `JobMaster` was allocated at submission.
   3. For a bounded window, require that the job stays `PENDING`, that it stays 
in the pending queue
      and that the job master object is unchanged. With zero workers any other 
outcome is either a
      bogus failure (`REJECT`-like) or a task deployment without a slot.
   4. Start the first worker; require that the job becomes `RUNNING`, that it 
is the same `JobMaster`
      instance (`assertSame`), that it leaves the pending queue, and that a 
periodic checkpoint
      completes — proving the admission started the whole runtime, not only the 
status.
   5. Cancel the admitted job and require `CANCELED` plus the terminal cleanup 
that removes the job
      master.
   6. Submit a second identical job and require it to reach `RUNNING` 
immediately, proving that the
      two-slot budget consumed by the queued-then-admitted job was released 
again.
   
   ## Why this is a boundary with real regression risk
   
   Every failure mode here is silent and user-visible at the same time. If a 
submission into a
   workerless cluster is rejected or failed instead of queued, a rolling start 
cannot be scripted. If
   the pending scheduler re-evaluates only on job events (submit, finish, 
cancel, failover) and not on
   capacity that appears while the job already waits, the job stays `PENDING` 
forever without any error.
   If admission rebuilt the `JobMaster` instead of reusing the queued one, the 
physical plan and
   checkpoint coordinator prepared at submission would be discarded. And if the 
queued job's resource
   reservation leaked, the next job on the same worker would never start. None 
of these raise an
   exception on the client side — the job simply never runs — so only an 
end-to-end state transition
   assertion catches them.
   
   ## Why the existing coverage does not reach it
   
   - `PendingJobsRestIT` submits against a single node that owns slots from the 
start and asserts the
     REST view of the pending queue; capacity is never absent.
   - `SplitClusterPendingJobLifecycleFailoverIT` queues jobs behind a holder 
that occupies existing
     capacity and drives master failover; every worker already exists.
   - `ClusterIT`, `JobExecutionIT` and the checkpoint/savepoint ITs await a 
complete master/worker
     cluster before submitting.
   - No test submits a job while `ResourceManager#workerCount` is zero, and the 
engine-side unit tests
     (`CoordinatorServiceTest`, `CoordinatorServiceWithCancelPendingJobTest`,
     `PendingDiagnosticsCollectorTest`) drive the pending queue directly 
instead of driving a real
     worker registration event through a real resource manager.
   
   ## Verification
   
   - `mvn -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
-Dtest=PendingJobWorkerJoinAdmissionIT test`
     — passes, three consecutive runs, ~17 s per run (JDK 17).
   - `mvn -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base spotless:check` 
—
     passes.
   - Negative observation while designing the fixture: with a worker that owns 
only one fixed slot the
     same job stays `PENDING` and is never failed, i.e. the wait path really is 
capacity driven.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to