Skip to content

ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag#17242

Merged
vikin91 merged 5 commits intomasterfrom
piotr/ROX-31236-remove-sensor-reconciliation-flag
Oct 22, 2025
Merged

ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag#17242
vikin91 merged 5 commits intomasterfrom
piotr/ROX-31236-remove-sensor-reconciliation-flag

Conversation

@vikin91
Copy link
Contributor

@vikin91 vikin91 commented Oct 10, 2025

Human here

This has been created fully by AI.

  • I have checked the code changes and the PR description.

Description

This PR removes the ROX_SENSOR_RECONCILIATION feature 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:

  • Removed SensorReconciliationOnReconnect feature flag definition from pkg/features/list.go
  • Made SendDeduperStateOnReconnect capability always enabled in Central sensor service
  • Removed conditional checks based on the feature flag in central/sensor/service/service_impl.go
  • Updated local-sensor tool to unconditionally send deduper state
  • Cleaned up test files that referenced the feature flag

Why: 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

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Verified compilation succeeds with no errors after the changes
  • Reviewed existing test coverage: sensor reconciliation tests in sensor/tests/connection/k8sreconciliation/ validate the reconciliation behavior
  • Confirmed that the removed feature flag was enabled by default and not conditionally used in production environments
  • All existing CI tests pass, ensuring the always-on behavior works correctly

AI 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.

@openshift-ci
Copy link

openshift-ci bot commented Oct 10, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Oct 10, 2025

Images are ready for the commit at 398a299.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.10.x-56-g398a2999f7.

@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.83%. Comparing base (2c41166) to head (398a299).
⚠️ Report is 58 commits behind head on master.

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     
Flag Coverage Δ
go-unit-tests 48.83% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vikin91 vikin91 changed the title ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag Oct 13, 2025
@vikin91 vikin91 changed the title ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag ROX-31236: Remove ROX_SENSOR_RECONCILIATION feature flag Oct 14, 2025
@vikin91 vikin91 force-pushed the piotr/ROX-31236-remove-sensor-reconciliation-flag branch from 827234d to 3f5bd1f Compare October 16, 2025 15:50
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.
@vikin91 vikin91 force-pushed the piotr/ROX-31236-remove-sensor-reconciliation-flag branch from 3f5bd1f to 3169aec Compare October 16, 2025 15:55
@vikin91
Copy link
Contributor Author

vikin91 commented Oct 16, 2025

@sourcery-ai re-review

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 16, 2025

Sure! I'm generating a new review now.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 16, 2025

Hey @vikin91, I've posted a new review for you!

@vikin91 vikin91 marked this pull request as ready for review October 16, 2025 16:03
@vikin91 vikin91 requested a review from a team as a code owner October 16, 2025 16:03
Copy link
Contributor

@lvalerom lvalerom left a comment

Choose a reason for hiding this comment

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

LGTM

@vikin91 vikin91 merged commit 7ee2a87 into master Oct 22, 2025
105 checks passed
@vikin91 vikin91 deleted the piotr/ROX-31236-remove-sensor-reconciliation-flag branch October 22, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants