Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(ucs): default to shadow mode when no rollout config is present (#12039)

Amitsingh Tanwar70913156ae59
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 7c553edc9f..4d1ce965fc 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -2524,14 +2524,17 @@ fn create_proxy_override(
// Helper function to execute rollout logic or return default
impl From<RolloutConfig> for RolloutExecutionResult {
fn from(config: RolloutConfig) -> Self {
- // Validate both rollout_percent bounds and execution_mode
let is_valid_percent = (0.0..=1.0).contains(&config.rollout_percent);
- let is_valid_execution_mode =
- !matches!(config.execution_mode, ExecutionMode::NotApplicable);
- match (is_valid_percent, is_valid_execution_mode) {
- (true, true) => {
- // Calculate probability to determine if request should execute
+ match is_valid_percent {
+ false => {
+ logger::warn!(
+ is_valid_percent = is_valid_percent,
+ "Invalid rollout percent in rollout config. Defaulting to should_execute false."
+ );
+ Self::default()
+ }
+ true => {
let sampled_value: f64 = rand::thread_rng().gen_range(0.0..1.0);
let should_execute = sampled_value < config.rollout_percent;
@@ -2548,7 +2551,6 @@ impl From<RolloutConfig> for RolloutExecutionResult {
let proxy_override =
create_proxy_override(config.http_url, config.https_url);
logger::info!(
- should_execute = should_execute,
execution_mode = ?config.execution_mode,
"Rollout will be executed with proxy override"
);
@@ -2560,7 +2562,6 @@ impl From<RolloutConfig> for RolloutExecutionResult {
}
false => {
logger::info!(
- should_execute = should_execute,
execution_mode = ?config.execution_mode,
"Rollout will not be executed"
);
@@ -2568,29 +2569,6 @@ impl From<RolloutConfig> for RolloutExecutionResult {
}
}
}
- (true, false) => {
- logger::warn!(
- is_valid_percent = is_valid_percent,
- is_valid_execution_mode = is_valid_execution_mode,
- "Invalid execution mode in rollout config. Defaulting to NotApplicable and should execute false."
- );
- Self::default()
- }
- (false, true) => {
- logger::warn!(
- is_valid_percent = is_valid_percent,
- "Invalid rollout percent in rollout config. Defaulting to should execute false."
- );
- Self::default()
- }
- (false, false) => {
- logger::warn!(
- is_valid_percent = is_valid_percent,
- is_valid_execution_mode = is_valid_execution_mode,
- "Invalid rollout percent and execution mode in rollout config. Defaulting to should execute false and NotApplicable."
- );
- Self::default()
- }
}
}
}
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 8ff742b341..af18472196 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -383,12 +383,14 @@ where
| CallConnectorAction::HandleResponseWithoutBuildRequest
| CallConnectorAction::Avoid
| CallConnectorAction::StatusUpdate { .. } => {
- // UCS is enabled, call decide function
- decide_execution_path(
- connector_integration_type,
- previous_gateway,
- rollout_result.execution_mode,
- )?
+ // If a rollout config key exists use its execution mode,
+ // otherwise default to Shadow so all traffic mirrors through UCS.
+ let execution_mode = if rollout_result.should_execute {
+ rollout_result.execution_mode
+ } else {
+ ExecutionMode::Shadow
+ };
+ decide_execution_path(connector_integration_type, previous_gateway, execution_mode)?
}
}
};