Skip to content

Commit

Permalink
Make it possible to disable verification of RevisionHasTrafficEnabled…
Browse files Browse the repository at this point in the history
… for the ACA provider (#2080)
  • Loading branch information
npehrsson authored Jan 24, 2024
1 parent 3eae9c1 commit 8e5b42e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,24 @@ private async Task UpdateCurrentMember(ICollection<StoredMember> activeMembers,

if (currentMember is not null)
{
var canReceiveTraffic = await CanReceiveTrafficAsync().ConfigureAwait(false);
var revisionName = _containerAppMetadata.RevisionName;

if (!canReceiveTraffic)
{
_logger.LogInformation("Revision {RevisionName} is not active", revisionName);
activeMembers.Remove(currentMember);
expiredMembers.Add(currentMember);
}
else
if (_options.Value.IsVerifyRevisionHasTrafficEnabled)
{
_logger.LogInformation("Updating current member {MemberId} on {MemberAddress}", currentMember.Id, currentMember.Address);
currentMember = currentMember with { UpdatedAt = now };
await _clusterMemberStore.UpdateAsync(currentMember).ConfigureAwait(false);
var canReceiveTraffic = await CanReceiveTrafficAsync().ConfigureAwait(false);

if (!canReceiveTraffic)
{
var revisionName = _containerAppMetadata.RevisionName;

_logger.LogInformation("Revision {RevisionName} is not active", revisionName);
activeMembers.Remove(currentMember);
expiredMembers.Add(currentMember);
return;
}
}

_logger.LogInformation("Updating current member {MemberId} on {MemberAddress}", currentMember.Id, currentMember.Address);
currentMember = currentMember with { UpdatedAt = now };
await _clusterMemberStore.UpdateAsync(currentMember).ConfigureAwait(false);
}
}

Expand Down Expand Up @@ -228,12 +231,15 @@ private async Task AddMember()

private async Task AddMemberInternal()
{
var canReceiveTraffic = await CanReceiveTrafficAsync().ConfigureAwait(false);

if (!canReceiveTraffic)
if (_options.Value.IsVerifyRevisionHasTrafficEnabled)
{
_logger.LogInformation("Revision {RevisionName} is not active", _containerAppMetadata.RevisionName);
return;
var canReceiveTraffic = await CanReceiveTrafficAsync().ConfigureAwait(false);

if (!canReceiveTraffic)
{
_logger.LogInformation("Revision {RevisionName} is not active", _containerAppMetadata.RevisionName);
return;
}
}

var member = new Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ public class AzureContainerAppsProviderOptions
/// The actual TTL is determined by the <see cref="PollInterval"/> and the <see cref="MemberTimeToLive"/> by adding them together.
/// </summary>
public TimeSpan MemberTimeToLive { get; set; } = TimeSpan.FromMinutes(1);
/// <summary>
/// If set to true, the provider will verify that the revision that this replica is part of has 1 or more percent of the traffic.
/// If not it won't be added to the cluster, and if already added it will be removed.
/// </summary>
public bool IsVerifyRevisionHasTrafficEnabled { get; set; } = true;
}

0 comments on commit 8e5b42e

Please sign in to comment.