fix: filter component fetch to nodes only and safe channel close - #131
Open
synackd wants to merge 1 commit into
Open
fix: filter component fetch to nodes only and safe channel close#131synackd wants to merge 1 commit into
synackd wants to merge 1 commit into
Conversation
synackd
force-pushed
the
pr/c-component-fetch-filter
branch
2 times, most recently
from
August 31, 2026 16:28
cf0f42f to
86dda3d
Compare
The original implementation of ComponentInformation fetched the full component list without filtering, causing cache‑misses for non‑Node components and unnecessary processing. Update the SMD client to request only Node components by appending ?type=Node to the endpoint (/hsm/v2/State/Components). The change ensures that ComponentInformation and related cache logic operate correctly for node resources. Additionally, StopCacheRefresh now safely closes its stop channel using a select‑based guard (safeClose) to avoid panics if the channel is closed multiple times. Corresponding tests have been updated to reflect the new behavior. These improvements enhance performance and stability of the SMD client. Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
synackd
force-pushed
the
pr/c-component-fetch-filter
branch
from
August 31, 2026 16:32
86dda3d to
8db0a0f
Compare
15 tasks
synackd
marked this pull request as ready for review
August 31, 2026 16:43
17 tasks
alexlovelltroy
requested changes
Aug 31, 2026
alexlovelltroy
left a comment
Member
There was a problem hiding this comment.
Looks like TestPopulateNodes is failing on this PR. We need to fix that before merging.
Comment on lines
+161
to
170
| // Ensure the stop channel is closed exactly once. | ||
| s.stopOnce.Do(func() { | ||
| close(s.stopCacheRefresh) | ||
| // safeClose closes the channel only if it hasn't been closed already. | ||
| select { | ||
| case <-s.stopCacheRefresh: | ||
| // already closed | ||
| default: | ||
| close(s.stopCacheRefresh) | ||
| } | ||
| }) |
Member
There was a problem hiding this comment.
Why did we need to expand this?
I think the original has equivalent safety.
Contributor
Author
There was a problem hiding this comment.
Probably not necessary, the main change is to deduplicate the close(). I can revert this block and get rid of the extra close() below. I presume that the close() below is extra?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The original implementation of
ComponentInformationfetched the full component list without filtering, causing cache‑misses for non‑Node components and unnecessary processing. Update the SMD client to request only Node components by appending?type=Nodeto the endpoint (/hsm/v2/State/Components). The change ensures thatComponentInformationand related cache logic operate correctly for node resources. Additionally,StopCacheRefreshnow safely closes its stop channel using a select‑based guard (safeClose) to avoid panics if the channel is closed multiple times. Corresponding tests have been updated to reflect the new behavior. These improvements enhance performance and stability of the SMD client.Fixes #128 (comment)
Fixes #128 (comment)
Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryType of Change