ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag#17242
ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag#17242
ROX_SENSOR_RECONCILIATION feature flag#17242Conversation
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Now that the feature flags are removed, consider refactoring the affected structs (e.g., Pipeline, Manager) to drop unused fields/methods (getCurrentContext, resetContext, etc.) and streamline the code paths.
- Rather than leaving old offline‐mode tests marked as skipped, delete or consolidate them so the test suite remains concise and avoids future confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that the feature flags are removed, consider refactoring the affected structs (e.g., Pipeline, Manager) to drop unused fields/methods (getCurrentContext, resetContext, etc.) and streamline the code paths.
- Rather than leaving old offline‐mode tests marked as skipped, delete or consolidate them so the test suite remains concise and avoids future confusion.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Images are ready for the commit at 398a299. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #17242 +/- ##
==========================================
- Coverage 48.84% 48.83% -0.01%
==========================================
Files 2720 2720
Lines 203032 203030 -2
==========================================
- Hits 99166 99153 -13
- Misses 96079 96087 +8
- Partials 7787 7790 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ROX_SENSOR_RECONCILIATION feature flag
ROX_SENSOR_RECONCILIATION feature flagROX_SENSOR_RECONCILIATION feature flag
827234d to
3f5bd1f
Compare
This removes the ROX_CAPTURE_INTERMEDIATE_EVENTS feature flag that has been enabled by default since Release 4.3 (February 2024). The flag enabled offline v3 behavior where Sensor buffers events during Central disconnects. This is now the standard operational mode. Changes: - Removed feature flag definition from pkg/features/list.go - Network flow manager: Always use buffered channels and continue enrichment during offline mode - Process signal pipeline: Always use long-lived contexts that persist across disconnects - Detector: Always use buffered queues and handle pause/resume on connection events - Removed EnrichmentReasonEpFeatureDisabled (no longer returned) - Updated integration tests to remove flag setup - Removed unused features package imports from 9 files All event buffering and offline operation functionality remains fully operational. This PR is stacked on #17236 (ROX_PREVENT_SENSOR_RESTART_ON_DISCONNECT removal). Partially generated with AI assistance.
- Removed SensorReconciliationOnReconnect feature flag definition - Always enable SendDeduperStateOnReconnect capability - Removed conditional checks in Central sensor service - Updated local-sensor tool to always send deduper state - Removed feature flag from test setup - Removed unused features imports from test files This flag has been enabled since Release 4.3 (October 2023). Reconciliation is now always performed on sensor reconnect. Partially generated by AI.
3f5bd1f to
3169aec
Compare
|
@sourcery-ai re-review |
|
Sure! I'm generating a new review now. |
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `central/sensor/service/connection/connection_test.go:172-174` </location>
<code_context>
}
func (s *testSuite) TestSendDeduperStateIfSensorReconciliation() {
- s.T().Setenv(features.SensorReconciliationOnReconnect.EnvVar(), "true")
s.T().Setenv(env.MaxDeduperEntriesPerMessage.EnvVar(), "2")
- if !features.SensorReconciliationOnReconnect.Enabled() {
- s.T().Skip("Test skipped if ROX_SENSOR_RECONCILIATION feature flag isn't set")
- }
</code_context>
<issue_to_address>
**suggestion (testing):** Test logic for feature flag gating has been removed; ensure test still covers always-on reconciliation.
Please verify the test still checks deduper state transmission on reconnect, update the test name for clarity, and confirm negative scenarios are tested.
Suggested implementation:
```golang
func (s *testSuite) TestDeduperStateTransmissionOnReconnectAlwaysOnReconciliation() {
s.T().Setenv(env.MaxDeduperEntriesPerMessage.EnvVar(), "2")
cases := map[string]struct {
givenSensorCapabilities []centralsensor.SensorCapability
givenSensorState central.SensorHello_SensorState
expectDeduperStateSent bool
}{
"deduper state sent on reconnect": {
givenSensorCapabilities: []centralsensor.SensorCapability{centralsensor.SensorCapability_DEDUPER},
givenSensorState: central.SensorHello_SENSOR_STATE_RECONNECTING,
expectDeduperStateSent: true,
},
"deduper state not sent if capability missing": {
givenSensorCapabilities: []centralsensor.SensorCapability{},
givenSensorState: central.SensorHello_SENSOR_STATE_RECONNECTING,
expectDeduperStateSent: false,
},
"deduper state not sent if not reconnecting": {
givenSensorCapabilities: []centralsensor.SensorCapability{centralsensor.SensorCapability_DEDUPER},
givenSensorState: central.SensorHello_SENSOR_STATE_CONNECTED,
expectDeduperStateSent: false,
},
}
for name, tc := range cases {
s.Run(name, func() {
// Setup sensor with given capabilities and state
sensor := newTestSensor(tc.givenSensorCapabilities, tc.givenSensorState)
// Simulate reconnect
sensor.Reconnect()
// Check if deduper state was sent
if tc.expectDeduperStateSent {
s.True(sensor.DeduperStateSent(), "Expected deduper state to be sent")
} else {
s.False(sensor.DeduperStateSent(), "Expected deduper state NOT to be sent")
}
})
}
```
You may need to implement or adjust the helper methods `newTestSensor`, `Reconnect`, and `DeduperStateSent` to match your test infrastructure. Ensure that the test covers both positive and negative scenarios as shown.
</issue_to_address>
### Comment 2
<location> `sensor/tests/connection/k8sreconciliation/reconcile_test.go:47-8` </location>
<code_context>
}
func Test_SensorReconcilesKubernetesEvents(t *testing.T) {
- t.Setenv(features.SensorReconciliationOnReconnect.EnvVar(), "true")
-
t.Setenv("ROX_SENSOR_CONNECTION_RETRY_INITIAL_INTERVAL", "1s")
t.Setenv("ROX_SENSOR_CONNECTION_RETRY_MAX_INTERVAL", "2s")
</code_context>
<issue_to_address>
**suggestion (testing):** Removed feature flag environment setup; verify test covers reconciliation unconditionally.
Ensure the test now asserts reconciliation occurs on reconnect without relying on the feature flag. Update the test name or comments to reflect this unconditional behavior.
Suggested implementation:
```golang
func Test_SensorAlwaysReconcilesKubernetesEventsOnReconnect(t *testing.T) {
// This test verifies that reconciliation occurs on reconnect unconditionally,
// without relying on any feature flag.
t.Setenv("ROX_SENSOR_CONNECTION_RETRY_INITIAL_INTERVAL", "1s")
t.Setenv("ROX_SENSOR_CONNECTION_RETRY_MAX_INTERVAL", "2s")
// Setup test environment and sensor
env := helper.NewTestEnv(t)
defer env.Cleanup()
// Simulate initial connection and event processing
env.ConnectSensor()
env.SendKubernetesEvent("Pod", "pod-1", hash.NewHash("pod-1"))
assert.True(t, env.HasProcessedEvent("Pod", "pod-1"), "Sensor should process initial event")
// Simulate sensor disconnect and reconnect
env.DisconnectSensor()
env.ConnectSensor()
// Assert that reconciliation occurs on reconnect
assert.True(t, env.HasReconciledEvent("Pod", "pod-1"), "Sensor should reconcile event on reconnect unconditionally")
```
- Ensure that `helper.NewTestEnv`, `SendKubernetesEvent`, `HasProcessedEvent`, `DisconnectSensor`, `ConnectSensor`, and `HasReconciledEvent` exist and behave as expected in your test helper.
- If these helper methods do not exist, you will need to implement them or adjust the test logic to match your actual test environment and reconciliation verification.
</issue_to_address>
### Comment 3
<location> `sensor/tests/connection/runtime/runtime_test.go:32-29` </location>
<code_context>
}
func Test_SensorReconcilesKubernetesEvents(t *testing.T) {
- t.Setenv(features.SensorReconciliationOnReconnect.EnvVar(), "true")
-
t.Setenv("ROX_SENSOR_CONNECTION_RETRY_INITIAL_INTERVAL", "1s")
t.Setenv("ROX_SENSOR_CONNECTION_RETRY_MAX_INTERVAL", "2s")
</code_context>
<issue_to_address>
**suggestion (testing):** Feature flag environment variable setup removed; confirm test still validates runtime event reconciliation.
Ensure the test accurately reflects the always-on state for event reconciliation, updating assertions if necessary.
Suggested implementation:
```golang
func Test_SensorIntermediateRuntimeEvents(t *testing.T) {
t.Setenv(env.ConnectionRetryInitialInterval.EnvVar(), "1s")
t.Setenv(env.ConnectionRetryMaxInterval.EnvVar(), "2s")
// Ensure runtime event reconciliation is always enabled.
// Remove any logic that depends on the feature flag and assert reconciliation occurs.
// Setup test environment and sensor
sensor, cleanup := helper.SetupTestSensor(t)
defer cleanup()
// Simulate a runtime event (e.g., pod creation)
pod := testutils.NewPod("test-pod", "default")
sensor.EmitKubernetesEvent(pod)
// Simulate sensor reconnect
sensor.Disconnect()
sensor.Reconnect()
// Assert that the runtime event is reconciled after reconnect
reconciledPod, err := sensor.GetPod("test-pod", "default")
if err != nil {
t.Fatalf("Expected pod to be reconciled after reconnect, but got error: %v", err)
}
if reconciledPod == nil {
t.Fatalf("Expected pod to be present after reconciliation, but got nil")
}
```
- If the helper or testutils packages do not provide the methods used above (e.g., EmitKubernetesEvent, Disconnect, Reconnect, GetPod), you will need to adapt the test to use the appropriate methods for your test sensor.
- If there are more specific runtime events or reconciliation logic to validate, update the assertions to match your application's requirements.
- Remove any other references to the feature flag in this test file.
</issue_to_address>
### Comment 4
<location> `central/sensor/service/connection/connection_test.go:171` </location>
<code_context>
}
func (s *testSuite) TestSendDeduperStateIfSensorReconciliation() {
- s.T().Setenv(features.SensorReconciliationOnReconnect.EnvVar(), "true")
s.T().Setenv(env.MaxDeduperEntriesPerMessage.EnvVar(), "2")
</code_context>
<issue_to_address>
**nitpick:** Consider renaming the test to reflect unconditional deduper state sending.
The test name should be updated to match its new behavior, since it no longer depends on the feature flag.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Hey @vikin91, I've posted a new review for you! |
Human here
This has been created fully by AI.
Description
This PR removes the
ROX_SENSOR_RECONCILIATIONfeature flag, which has been enabled by default since Release 4.3 (October 2023). The flag controlled whether sensor reconciliation occurs on reconnect to Central.Changes:
SensorReconciliationOnReconnectfeature flag definition frompkg/features/list.goSendDeduperStateOnReconnectcapability always enabled in Central sensor servicecentral/sensor/service/service_impl.golocal-sensortool to unconditionally send deduper stateWhy: The flag has been enabled for over 2 years without issues. Removing it simplifies the codebase and eliminates dead code paths. Sensor reconciliation on reconnect is now always performed, which is the expected and tested behavior.
User-facing documentation
Testing and quality
Automated testing
How I validated my change
sensor/tests/connection/k8sreconciliation/validate the reconciliation behaviorAI assistance: Initial feature flag removal and related code changes were identified and generated by AI. All code was manually reviewed, verified for correctness, and compilation was validated by the author.