ROX-28780: Unify Sensor endpoint env vars#20751
Conversation
ROX_SENSOR_ENDPOINT and ROX_ADVERTISED_ENDPOINT duplicated the same
in-cluster Sensor address with inconsistent sanitization. Add
SensorEndpointSetting() to resolve the canonical env var, fall back to
the legacy name, and derive sensor.{namespace}.svc:443 from
POD_NAMESPACE when unset. Switch compliance, admission, and scanner
callers; inject ROX_SENSOR_ENDPOINT alongside the legacy var in Helm
for a safe transition.
AI-Assisted: cursor, implementation and tests generated, user reviewed
|
This change is part of the following stack: Change managed by git-spice. |
|
Skipping CI for Draft Pull Request. |
📝 WalkthroughWalkthroughThis PR migrates sensor endpoint resolution from using advertised endpoint to a new unified ChangesSensor Endpoint Resolution and Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🚀 Build Images ReadyImages are ready for commit 0466f53. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-1098-g0466f53974 |
|
CI e2e fails with |
|
/retest |
Description
ROX_SENSOR_ENDPOINTandROX_ADVERTISED_ENDPOINTboth describe the in-cluster Sensor address but were registered separately, withStripAnyPrefixonly on the legacy name. Helm already sets both fromsensor.endpoint(defaultsensor.{{ namespace }}.svc:443), yet compliance usedROX_ADVERTISED_ENDPOINTwhile admission and scanner v4 usedROX_SENSOR_ENDPOINT. This is ambiguous and we should rather have one variable for configuring this, not two.Add
env.SensorEndpointSetting()to resolve the canonical env var, fall back to the legacy name, and derivesensor.{POD_NAMESPACE}.svc:443when neither is set. Switch in-cluster callers (compliance, admission, scanner transport) to that helper. InjectROX_SENSOR_ENDPOINTalongsideROX_ADVERTISED_ENDPOINTin Helm for a safe transition; removal of the legacy env var from charts is follow-up.Before: compliance connected via
ROX_ADVERTISED_ENDPOINTonly; unset envwith a wrong namespace default could point at
sensor.stackrox.svc.After: all in-cluster clients use the same resolution order; a custom
namespace works without setting either var when
POD_NAMESPACEis present.Central kubectl bundle rendering (
central/clusters/deployer.go) still readsenv.AdvertisedEndpointdirectly because Central runs outside the securedcluster namespace.
Fixes ROX-28780 (follow-up to
ROX-28698).
AI-Assisted: cursor, implementation and tests generated, user reviewed logic
User-facing documentation
Testing and quality
Automated testing
How I validated my change