-
Notifications
You must be signed in to change notification settings - Fork 174
ROX-13540: Allow Sensor Component NodeScanHandler to start max. once
#3800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
ad9cf66
Fix: Ensure that consecutive calls to nodeScanHandlerImpl.Start don't…
vikin91 c441c41
Optimize nodeScanHandlerImpl.sendScan
vikin91 41dd60f
Remove stoppedC, fix race condition in test
vikin91 4df0e64
Minor: Tune a comment and reduce a line
vikin91 70b80bb
Make the nodeScanHandlerImpl restartable
vikin91 da01dfe
Rename mutex var
vikin91 053b710
Rename var runFinishedC to stoppedC
vikin91 375a03e
Undo restartability: allow the component to Start() once
vikin91 c5052a7
Extend comment for the test where producer stops the component after …
vikin91 17932b4
Change error message when starting NodeScanHandler for the N>1 time
vikin91 32ba377
Make deferred statement evaluate properly
vikin91 7e85378
Do not initialize toCentral chan twice
vikin91 943deee
Correct comment
vikin91 889e083
Address race in TestHandlerStoppedError by accepting both values
vikin91 142289d
Delete SetupTest and make sure that the Suite implements the interface
vikin91 b8a647d
Add waiting for Stopped() in TestStopHandler
vikin91 38c94fe
Rephrase comment in TestStopHandler
vikin91 86dae6e
Add more assertions to TestHandlerRegularRoutine
vikin91 c008157
Ensure all test cases do h.Stopped().Wait()
vikin91 283a43e
WIP: Rework tests
vikin91 98a2509
Reword comment
vikin91 d9fcadc
Fix race in TestStopHandler between handler Stop and receiver receivi…
vikin91 83f8613
Stop(nil) and skip stopAll in TestHandlerRegularRoutine
vikin91 706d1aa
Skip stopAll in TestHandlerStoppedError
vikin91 cc6fd29
Cleanup generateTestInputNoClose
vikin91 ae283da
Improve TestRestartHandler
vikin91 d948528
Improve TestDoubleStartHandler and TestDoubleStopHandler
vikin91 13befb8
Temporarily revert "Fix race in TestStopHandler between handler Stop …
vikin91 dc50b12
Remove the test context
vikin91 a4f7112
Do not defer assertNoGoroutineLeaks
vikin91 8369b91
Correct stopAll code in TestStopHandler
vikin91 ad836f8
Remove redundant waiting in TestRestartHandler
vikin91 06bc997
Remove stopAll and fix race in TestStopHandler
vikin91 a4c6c54
Fix hidden race in TestMultipleStartHandler
vikin91 e22e35b
Remove redundant TestRestartHandler
vikin91 ed00521
Remove assertions NotPanics
vikin91 e385c20
Add coverage with test TestInputChannelClosed
vikin91 5246c62
Fine details: comments and order of cleanup
vikin91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,25 @@ | ||
| package compliance | ||
|
|
||
| import ( | ||
| "github.com/stackrox/rox/generated/internalapi/central" | ||
| "github.com/stackrox/rox/generated/storage" | ||
| "github.com/stackrox/rox/pkg/concurrency" | ||
| "github.com/stackrox/rox/pkg/sync" | ||
| "github.com/stackrox/rox/sensor/common" | ||
| ) | ||
|
|
||
| // NodeScanHandler is responsible for handling the arriving NodeScanV2 messages, processing then, and sending them to central | ||
| type NodeScanHandler interface { | ||
| common.SensorComponent | ||
| Stopped() concurrency.ReadOnlyErrorSignal | ||
| } | ||
|
|
||
| // NewNodeScanHandler returns a new instance of a NodeScanHandler | ||
| func NewNodeScanHandler(ch <-chan *storage.NodeScanV2) NodeScanHandler { | ||
| return &nodeScanHandlerImpl{ | ||
| nodeScans: ch, | ||
| toCentral: make(chan *central.MsgFromSensor), | ||
|
|
||
| stopC: concurrency.NewErrorSignal(), | ||
| stoppedC: concurrency.NewErrorSignal(), | ||
| toCentral: nil, | ||
| stopC: concurrency.NewErrorSignal(), | ||
| lock: &sync.Mutex{}, | ||
| stoppedC: concurrency.NewErrorSignal(), | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.