Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f5cb08a
Fixes payload
NaluTripician Jul 3, 2025
bdec17e
New approach
NaluTripician Jul 10, 2025
d4ad254
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 10, 2025
f247499
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 15, 2025
9275c83
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 16, 2025
80681aa
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 17, 2025
dd9ba9c
Update ThinClientStoreModelTests.cs
NaluTripician Jul 18, 2025
65a94ae
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 18, 2025
5dde83f
Revert "Merge branch 'master' into users/nalutripician/FIThinclientPa…
NaluTripician Jul 18, 2025
eff2071
Revert "Update ThinClientStoreModelTests.cs"
NaluTripician Jul 18, 2025
fd94d11
Reapply "Update ThinClientStoreModelTests.cs"
NaluTripician Jul 18, 2025
e10bb61
Reapply "Merge branch 'master' into users/nalutripician/FIThinclientP…
NaluTripician Jul 18, 2025
5ad7d04
Fixed build errors
NaluTripician Jul 18, 2025
6979a90
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
kundadebdatta Jul 22, 2025
780de28
fix document client
NaluTripician Jul 22, 2025
f9ae96f
Update DocumentClient.cs
NaluTripician Jul 22, 2025
74f795e
added FI connection in GatewayStoreModel
NaluTripician Jul 24, 2025
e458367
Update ThinClientStoreClient.cs
NaluTripician Jul 24, 2025
23de714
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 24, 2025
bf477ae
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Jul 29, 2025
fc1080e
fix merge
NaluTripician Jul 29, 2025
4f9253a
Update DocumentClient.cs
NaluTripician Jul 29, 2025
282d10c
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Aug 5, 2025
dc1cd44
Update GatewayStoreModel.cs
NaluTripician Aug 6, 2025
f89c605
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Aug 7, 2025
27582e5
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Aug 8, 2025
e32d233
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Aug 12, 2025
353c743
Update GatewayStoreModel.cs
NaluTripician Aug 12, 2025
29a0373
Merge branch 'master' into users/nalutripician/FIThinclientPayloadFix
NaluTripician Aug 13, 2025
c0a6084
fixes merge
NaluTripician Aug 13, 2025
4d7be33
Copilot suggestions
NaluTripician Aug 13, 2025
01929f6
Copilot suggestions
NaluTripician Aug 13, 2025
18020ad
Code changes to clean up Gateway Store Model. Fixing Build Break.
kundadebdatta Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ await BackoffRetryUtility<IEnumerable<string>>.ExecuteAsync(
result.GetDelay(),
result.GetSuppressServiceRequests(),
result.GetInjectionRate(),
this.applicationContext));
this.applicationContext,
this.globalEndpointManager));
}

private async Task<IFaultInjectionRuleInternal> GetEffectiveConnectionErrorRule(FaultInjectionRule rule)
Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Microsoft.Azure.Cosmos/src/DocumentClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,8 @@ private async Task<bool> GetInitializationTaskAsync(IStoreClientFactory storeCli
httpClient: this.httpClient,
globalPartitionEndpointManager: this.PartitionKeyRangeLocation,
isThinClientEnabled: this.isThinClientEnabled,
userAgentContainer: this.ConnectionPolicy.UserAgentContainer);
userAgentContainer: this.ConnectionPolicy.UserAgentContainer,
this.chaosInterceptor);

this.GatewayStoreModel = gatewayStoreModel;

Expand Down
15 changes: 10 additions & 5 deletions Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace Microsoft.Azure.Cosmos
using Microsoft.Azure.Cosmos.Routing;
using Microsoft.Azure.Cosmos.Tracing;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Collections;
using Microsoft.Azure.Documents.Collections;
using Microsoft.Azure.Documents.FaultInjection;
using Newtonsoft.Json;

// Marking it as non-sealed in order to unit test it using Moq framework
Expand All @@ -26,7 +27,8 @@ internal class GatewayStoreModel : IStoreModelExtension, IDisposable
private static readonly string sessionConsistencyAsString = ConsistencyLevel.Session.ToString();
private readonly GlobalPartitionEndpointManager globalPartitionEndpointManager;
private readonly ISessionContainer sessionContainer;
private readonly DocumentClientEventSource eventSource;
private readonly DocumentClientEventSource eventSource;
private readonly IChaosInterceptor chaosInterceptor;
Comment thread
NaluTripician marked this conversation as resolved.

internal readonly GlobalEndpointManager endpointManager;
internal readonly ConsistencyLevel defaultConsistencyLevel;
Expand All @@ -48,13 +50,15 @@ public GatewayStoreModel(
CosmosHttpClient httpClient,
GlobalPartitionEndpointManager globalPartitionEndpointManager,
bool isThinClientEnabled,
UserAgentContainer userAgentContainer = null)
UserAgentContainer userAgentContainer = null,
IChaosInterceptor chaosInterceptor = null)
{
this.endpointManager = endpointManager;
this.sessionContainer = sessionContainer;
this.defaultConsistencyLevel = defaultConsistencyLevel;
this.eventSource = eventSource;
this.globalPartitionEndpointManager = globalPartitionEndpointManager;
this.globalPartitionEndpointManager = globalPartitionEndpointManager;
this.chaosInterceptor = chaosInterceptor;
Comment thread
NaluTripician marked this conversation as resolved.
this.gatewayStoreClient = new GatewayStoreClient(
httpClient,
this.eventSource,
Expand All @@ -68,7 +72,8 @@ public GatewayStoreModel(
userAgentContainer,
this.eventSource,
globalPartitionEndpointManager,
serializerSettings);
serializerSettings,
this.chaosInterceptor);
}

this.globalPartitionEndpointManager.SetBackgroundConnectionPeriodicRefreshTask(
Expand Down
7 changes: 0 additions & 7 deletions Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ private async Task<HttpResponseMessage> SendHttpHelperAsync(
{
if (this.chaosInterceptor != null && documentServiceRequest != null)
{
this.SetFaultInjectionHeader(documentServiceRequest, requestMessage);
(bool hasFault, HttpResponseMessage fiResponseMessage) = await this.InjectFaultsAsync(cancellationTokenSource, documentServiceRequest, requestMessage);
if (hasFault)
{
Expand All @@ -374,7 +373,6 @@ private async Task<HttpResponseMessage> SendHttpHelperAsync(

if (this.chaosInterceptor != null && documentServiceRequest != null)
{
this.SetFaultInjectionHeader(documentServiceRequest, requestMessage);
CancellationToken fiToken = cancellationTokenSource.Token;
fiToken.ThrowIfCancellationRequested();
await this.chaosInterceptor.OnAfterHttpSendAsync(documentServiceRequest, fiToken);
Expand Down Expand Up @@ -469,11 +467,6 @@ private async Task<HttpResponseMessage> SendHttpHelperAsync(
}
}

private void SetFaultInjectionHeader(DocumentServiceRequest documentServiceRequest, HttpRequestMessage requestMessage)
{
documentServiceRequest.Headers.Set("FAULTINJECTION_GW_URI", requestMessage.RequestUri.ToString());
}

private async Task<(bool, HttpResponseMessage)> InjectFaultsAsync(
CancellationTokenSource cancellationTokenSource,
DocumentServiceRequest documentServiceRequest,
Expand Down
19 changes: 18 additions & 1 deletion Microsoft.Azure.Cosmos/src/ThinClientStoreClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Azure.Cosmos
using Microsoft.Azure.Cosmos.Core.Trace;
using Microsoft.Azure.Cosmos.Routing;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.FaultInjection;
using Newtonsoft.Json;
using static Microsoft.Azure.Cosmos.ThinClientTransportSerializer;

Expand All @@ -26,13 +27,15 @@ internal class ThinClientStoreClient : GatewayStoreClient
private readonly GlobalPartitionEndpointManager globalPartitionEndpointManager;
private readonly ObjectPool<BufferProviderWrapper> bufferProviderWrapperPool;
private readonly UserAgentContainer userAgentContainer;
private readonly IChaosInterceptor chaosInterceptor;

public ThinClientStoreClient(
CosmosHttpClient httpClient,
UserAgentContainer userAgentContainer,
ICommunicationEventSource eventSource,
GlobalPartitionEndpointManager globalPartitionEndpointManager,
JsonSerializerSettings serializerSettings = null)
JsonSerializerSettings serializerSettings = null,
IChaosInterceptor chaosInterceptor = null)
: base(httpClient,
eventSource,
globalPartitionEndpointManager,
Expand All @@ -43,6 +46,7 @@ public ThinClientStoreClient(
this.userAgentContainer = userAgentContainer
?? throw new ArgumentNullException(nameof(userAgentContainer),
"UserAgentContainer cannot be null when initializing ThinClientStoreClient.");
this.chaosInterceptor = chaosInterceptor;
}

public override async Task<DocumentServiceResponse> InvokeAsync(
Expand All @@ -63,6 +67,19 @@ public override async Task<DocumentServiceResponse> InvokeAsync(
clientCollectionCache,
cancellationToken))
{
if (this.chaosInterceptor != null)
{
request.Headers.Set("FAULTINJECTION_IS_PROXY", "true");
(bool hasFault, HttpResponseMessage fiResponseMessage) = await this.chaosInterceptor.OnHttpRequestCallAsync(request, cancellationToken);
if (hasFault)
{
DefaultTrace.TraceInformation("Chaos interceptor injected fault for request: {0}", request);
fiResponseMessage.RequestMessage = responseMessage.RequestMessage;
Comment thread
NaluTripician marked this conversation as resolved.
request.Headers.Remove("FAULTINJECTION_IS_PROXY");
return await ThinClientStoreClient.ParseResponseAsync(fiResponseMessage, request.SerializerSettings ?? base.SerializerSettings, request);
}
}

HttpResponseMessage proxyResponse = await ThinClientTransportSerializer.ConvertProxyResponseAsync(responseMessage);
return await ThinClientStoreClient.ParseResponseAsync(proxyResponse, request.SerializerSettings ?? base.SerializerSettings, request);
}
Expand Down
Loading