Skip to content

[LIVY-1081] SparkKubernetesApp: latch first observed app ID, reject mismatched re-attach under same tag - #556

Open
soumyadeeplogin wants to merge 1 commit into
apache:masterfrom
soumyadeeplogin:livy-item7-appid-latch-first
Open

soumyadeeplogin wants to merge 1 commit into
apache:masterfrom
soumyadeeplogin:livy-item7-appid-latch-first

Conversation

@soumyadeeplogin

@soumyadeeplogin soumyadeeplogin commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

SparkKubernetesApp.monitorSparkKubernetesApp() re-resolves the tracked Kubernetes
application on every poll cycle via a tag substring match
(getApplicationTag.contains(appTag)), and previously used whatever app ID it found
with no check against what it had seen before. If a stale/leaked tag reappeared or a
tag-substring collision occurred, a later poll could silently start tracking a
different application under the same tag, with no error.

This adds a knownAppId latch: the first observed app ID for a session is remembered,
and any later poll that resolves a different app ID for the same tag is rejected —
the promise fails, the session is driven to FAILED, and the tag is marked leaked,
mirroring the treatment of other terminal monitoring failures.

The decision logic is extracted into a pure, testable function,
SparkKubernetesApp.latchAppId(), following the pattern used in #544.

How was this patch tested?

Added latchAppId unit tests to SparkKubernetesAppSpec covering: no app ID known
yet (latches), matching app ID re-observed (no-op), and mismatched app ID observed
under the same tag (rejected with a diagnostic message naming the tag and both IDs).

Ran mvn -pl server -am test -Dtest=SparkKubernetesAppSpec: 14/14 tests pass (3 new).

Was this patch authored or co-authored using generative AI tooling?

Yes. Generated-by: Claude Code (Sonnet 5, Anthropic), used to implement the latchAppId
extraction and its unit tests, under human review. Please refer to the
ASF Generative Tooling Guidance
for details.

@soumyadeeplogin

Copy link
Copy Markdown
Contributor Author

Filed LIVY-1081 for this change.

@soumyadeeplogin

Copy link
Copy Markdown
Contributor Author

Hi @gyogal / @roczei — could one of you approve the pending CI workflow run for this PR (fork-contributor approval gate)? Happy to address any review feedback as well. Thanks!

…re-attach

monitorSparkKubernetesApp() re-resolves the tracked Kubernetes application on
every poll cycle via a tag substring match, with no check that the resolved
app ID matches what was seen on a previous poll. A stale/leaked tag or a tag
substring collision could silently switch which application is tracked.

Latch the first observed app ID per session and reject any later poll that
observes a different app ID for the same tag, failing the promise and
draining the session to FAILED rather than silently continuing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@soumyadeeplogin
soumyadeeplogin force-pushed the livy-item7-appid-latch-first branch from 559d6a3 to ea73b9e Compare September 23, 2026 05:12

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant