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

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. This patch was authored with the assistance of Claude (Anthropic), used to
implement the latchAppId extraction and its unit tests, following the ASF's
Generative Tooling Guidance (https://www.apache.org/legal/generative-tooling.html).
All code was reviewed by the human contributor before submission.

…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

Copy link
Copy Markdown
Contributor Author

Filed LIVY-1081 for this change.

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