Skip to content

Commit 9e7f6fc

Browse files
authored
Continue processing secrets if one failes rotation (#8168)
1 parent 677526b commit 9e7f6fc

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • tools/secret-management/Azure.Sdk.Tools.SecretManagement.Cli/Commands

tools/secret-management/Azure.Sdk.Tools.SecretManagement.Cli/Commands/RotateCommand.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
using System.CommandLine;
1+
using System.CommandLine;
22
using System.CommandLine.Invocation;
33
using Azure.Sdk.Tools.SecretRotation.Configuration;
44
using Azure.Sdk.Tools.SecretRotation.Core;
5+
using Microsoft.Extensions.Logging;
56

67
namespace Azure.Sdk.Tools.SecretManagement.Cli.Commands;
78

@@ -25,10 +26,24 @@ protected override async Task HandleCommandAsync(ILogger logger, RotationConfigu
2526
var timeProvider = new TimeProvider();
2627

2728
IEnumerable<RotationPlan> plans = rotationConfiguration.GetAllRotationPlans(logger, timeProvider);
29+
bool success = true;
2830

2931
foreach (RotationPlan plan in plans)
3032
{
31-
await plan.ExecuteAsync(onlyRotateExpiring, whatIf);
33+
try
34+
{
35+
await plan.ExecuteAsync(onlyRotateExpiring, whatIf);
36+
}
37+
catch (Exception ex)
38+
{
39+
logger.LogError(ex, "Exception thrown while executing plan {PlanName}", plan.Name);
40+
success = false;
41+
}
42+
}
43+
44+
if(!success)
45+
{
46+
throw new RotationException("Errors occurred while rotating secrets.");
3247
}
3348
}
3449
}

0 commit comments

Comments
 (0)