Skip to content

Commit 1184474

Browse files
committed
Do not fail if single cluster apply fails
1 parent d252781 commit 1184474

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

KustoSchemaTools/KustoClusterOrchestrator.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,34 @@ public async Task<List<ScriptExecuteCommandResult>> ApplyAsync(string clusterCon
9696
var clusterUrl = changeSet.To.Url;
9797

9898
var kustoHandler = KustoClusterHandlerFactory.Create(clusterName, clusterUrl);
99-
var result = await kustoHandler.WriteAsync(changeSet);
100-
101-
// Add the results from this cluster to the overall results list
102-
allResults.AddRange(result);
99+
try
100+
{
101+
var result = await kustoHandler.WriteAsync(changeSet);
102+
103+
// Add the results from this cluster to the overall results list
104+
allResults.AddRange(result);
105+
}
106+
catch (Exception ex)
107+
{
108+
Log.LogError(ex, $"Failed to apply changes to cluster: {clusterName}");
109+
allResults.Add(CreateFailedClusterResult(clusterName, clusterUrl, ex));
110+
}
103111
}
104112

105113
Log.LogInformation($"Finished applying. Total scripts executed: {allResults.Count}");
106114
return allResults;
107115
}
116+
117+
private static ScriptExecuteCommandResult CreateFailedClusterResult(string clusterName, string clusterUrl, Exception exception)
118+
{
119+
return new ScriptExecuteCommandResult
120+
{
121+
CommandType = $"cluster-script:{clusterName}",
122+
OperationId = Guid.Empty,
123+
Result = "Failed",
124+
Reason = $"{exception.GetType().Name}: {exception.Message}",
125+
CommandText = $"Apply cluster '{clusterName}' ({clusterUrl})"
126+
};
127+
}
108128
}
109129
}

0 commit comments

Comments
 (0)