Skip to content

feat: implement DumpState for file-discovery#1836

Open
thc1006 wants to merge 1 commit into
llm-d:mainfrom
thc1006:ops/dumpstate-file-discovery
Open

feat: implement DumpState for file-discovery#1836
thc1006 wants to merge 1 commit into
llm-d:mainfrom
thc1006:ops/dumpstate-file-discovery

Conversation

@thc1006

@thc1006 thc1006 commented Jun 27, 2026

Copy link
Copy Markdown

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds plugin.StateDumper to the file-discovery plugin so the endpoints it
currently has loaded can be inspected through GET /debug/plugins/state, the
same way the inflight-load-producer already exposes its state.

DumpState reports the endpoint identities (namespace/name) only, sorted and
capped at 100 with a truncated flag so the payload stays bounded. Addresses
and labels are deliberately left out.

The endpoint set is read concurrently with file reloads, so this adds a
read-write mutex to guard it; load now swaps the set under the lock. Behaviour
is otherwise unchanged.

Example response for this plugin:

{"endpoints":["default/pod-a","default/pod-b"],"totalEndpoints":2,"maxEndpoints":100,"truncated":false}

Part of #1755.

Which issue(s) this PR fixes:

Fixes #1776

Release note (write NONE if no user-facing change):

NONE

Testing:

New unit tests, all passing (race detector enabled):

  • Endpoint identities are reported and sorted
  • The list is capped with the truncated flag set, keeping the sorted-first endpoints
  • Concurrent reloads and dumps run cleanly under -race
  • An empty set returns valid JSON

@thc1006 thc1006 requested a review from a team as a code owner June 27, 2026 15:39
@thc1006 thc1006 requested review from elevran and vMaroon June 27, 2026 15:39
@github-actions github-actions Bot added kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 27, 2026
Endpoints []string `json:"endpoints"`
TotalEndpoints int `json:"totalEndpoints"`
MaxEndpoints int `json:"maxEndpoints"`
Truncated bool `json:"truncated"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the field Truncated needed. A quick manual comparison of TotalEndpoints and MaxEndpoints will tell a user whether or not the output was truncated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, totalEndpoints > maxEndpoints carries the same information, so I've removed the field and noted the derivation on the struct. The cap stays so the dump is still bounded.

Expose the set of endpoints currently loaded from the discovery file through
/debug/plugins/state. Only the endpoint identities are reported, sorted and
capped so the payload stays bounded; addresses and labels are left out.

DumpState reads the endpoint set concurrently with file reloads, so a read-write
mutex now guards it and load swaps the set under the lock.

Part of llm-d#1755.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@thc1006 thc1006 force-pushed the ops/dumpstate-file-discovery branch from cf5dbda to a57b409 Compare June 28, 2026 14:09
@thc1006 thc1006 requested a review from shmuelk June 28, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Operations] Implement DumpState for file-discovery plugin

2 participants