-
Notifications
You must be signed in to change notification settings - Fork 176
ROX-29755: Recover reprocessing when Sensor's are 'stuck' #15802
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
16 commits
Select commit
Hold shift + click to select a range
3c104e8
add contains to syncmap
dcaravel ac5747f
add env var to configure send timeout
dcaravel c04dc05
return context error if possible in injectmessage
dcaravel abe2f42
add timeout to reprocessor
dcaravel e373f31
remove unused method/tests
dcaravel 3a962ab
Remove usage of logging.ClusterID
dcaravel 529f1d4
Add metric to count the number of skipped messages
dcaravel cec6c54
disable timeout if needed
dcaravel 79c690d
fix style
dcaravel ffb4fa3
move timeout var to package
dcaravel b9f4d85
move metrics add metric tests
dcaravel 25316d2
cleanup error message
dcaravel 9537e55
fix style check
dcaravel 620fde5
add reprocessor unit test
dcaravel 0bb5550
change reprocess deployments log to error level
dcaravel 7372f15
add separate reason for not sent messages
dcaravel 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
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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package metrics | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/prometheus/client_golang/prometheus/testutil" | ||
| "github.com/stackrox/rox/generated/internalapi/central" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestIncrementMsgToSensorNotSentCounter(t *testing.T) { | ||
| t.Run("no panic on nil msg", func(t *testing.T) { | ||
| assert.NotPanics(t, func() { | ||
| IncrementMsgToSensorNotSentCounter("", nil, "") | ||
| }) | ||
| }) | ||
|
|
||
| t.Run("no panic on nil inner msg", func(t *testing.T) { | ||
| assert.NotPanics(t, func() { | ||
| IncrementMsgToSensorNotSentCounter("", ¢ral.MsgToSensor{ | ||
| Msg: nil, | ||
| }, "") | ||
| }) | ||
| }) | ||
|
|
||
| t.Run("inc and extract type", func(t *testing.T) { | ||
| // Clear any prior values. | ||
| prometheus.Unregister(msgToSensorNotSentCounter) | ||
| require.NoError(t, prometheus.Register(msgToSensorNotSentCounter)) | ||
|
|
||
| // Get references to the counters. | ||
| updImgErrCounter, err := msgToSensorNotSentCounter.GetMetricWith( | ||
| prometheus.Labels{"ClusterID": "a", "type": "UpdatedImage", "reason": NotSentError}, | ||
| ) | ||
| require.NoError(t, err) | ||
| updImgSkipCounter, err := msgToSensorNotSentCounter.GetMetricWith( | ||
| prometheus.Labels{"ClusterID": "a", "type": "UpdatedImage", "reason": NotSentSkip}, | ||
| ) | ||
| require.NoError(t, err) | ||
| reprocessDeploySignalCounter, err := msgToSensorNotSentCounter.GetMetricWith( | ||
| prometheus.Labels{"ClusterID": "b", "type": "ReprocessDeployments", "reason": NotSentSignal}, | ||
| ) | ||
| require.NoError(t, err) | ||
|
|
||
| // Sanity check. | ||
| assert.Equal(t, 0.0, testutil.ToFloat64(updImgErrCounter)) | ||
| assert.Equal(t, 0.0, testutil.ToFloat64(updImgSkipCounter)) | ||
| assert.Equal(t, 0.0, testutil.ToFloat64(reprocessDeploySignalCounter)) | ||
|
|
||
| // Verify the count is incremented, type extracted, and reason recorded. | ||
| IncrementMsgToSensorNotSentCounter("a", ¢ral.MsgToSensor{ | ||
| Msg: ¢ral.MsgToSensor_UpdatedImage{}, | ||
| }, NotSentError) | ||
| assert.Equal(t, 1.0, testutil.ToFloat64(updImgErrCounter)) | ||
| assert.Equal(t, 0.0, testutil.ToFloat64(updImgSkipCounter)) | ||
| assert.Equal(t, 0.0, testutil.ToFloat64(reprocessDeploySignalCounter)) | ||
|
|
||
| IncrementMsgToSensorNotSentCounter("a", ¢ral.MsgToSensor{ | ||
| Msg: ¢ral.MsgToSensor_UpdatedImage{}, | ||
| }, NotSentSkip) | ||
| assert.Equal(t, 1.0, testutil.ToFloat64(updImgErrCounter)) | ||
| assert.Equal(t, 1.0, testutil.ToFloat64(updImgSkipCounter)) | ||
| assert.Equal(t, 0.0, testutil.ToFloat64(reprocessDeploySignalCounter)) | ||
|
|
||
| IncrementMsgToSensorNotSentCounter("b", ¢ral.MsgToSensor{ | ||
| Msg: ¢ral.MsgToSensor_ReprocessDeployments{}, | ||
| }, NotSentSignal) | ||
| assert.Equal(t, 1.0, testutil.ToFloat64(updImgErrCounter)) | ||
| assert.Equal(t, 1.0, testutil.ToFloat64(updImgSkipCounter)) | ||
| assert.Equal(t, 1.0, testutil.ToFloat64(reprocessDeploySignalCounter)) | ||
| }) | ||
| } |
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
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
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.
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.