Skip to content

Commit d64aa72

Browse files
debug infoblox
1 parent 863388f commit d64aa72

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

AcmeCaPlugin/Clients/DNS/InfobloxDnsProvider.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ public async Task<bool> CreateRecordAsync(string recordName, string txtValue)
6969

7070
// Delete any existing records with the same name first to ensure only one record exists
7171
var searchUrl = $"./record:txt?name={Uri.EscapeDataString(cleanName)}";
72+
_logger?.LogDebug("[Infoblox] Searching for existing records at: {SearchUrl}", searchUrl);
73+
7274
var searchResponse = await _httpClient.GetAsync(searchUrl);
75+
_logger?.LogDebug("[Infoblox] Search response status: {StatusCode}", searchResponse.StatusCode);
7376

7477
if (searchResponse.IsSuccessStatusCode)
7578
{
7679
var searchJson = await searchResponse.Content.ReadAsStringAsync();
7780
var records = JsonDocument.Parse(searchJson).RootElement;
81+
var recordCount = records.GetArrayLength();
82+
_logger?.LogDebug("[Infoblox] Found {RecordCount} existing records", recordCount);
7883

7984
// Delete all existing records with this name
8085
foreach (var record in records.EnumerateArray())
@@ -87,6 +92,12 @@ public async Task<bool> CreateRecordAsync(string recordName, string txtValue)
8792
}
8893
}
8994
}
95+
else
96+
{
97+
var searchErrorBody = await searchResponse.Content.ReadAsStringAsync();
98+
_logger?.LogWarning("[Infoblox] Search for existing records failed: {StatusCode}, Response: {Response}",
99+
searchResponse.StatusCode, searchErrorBody);
100+
}
90101

91102
// Create new record with zone specified
92103
var payload = new
@@ -116,6 +127,7 @@ public async Task<bool> CreateRecordAsync(string recordName, string txtValue)
116127
{
117128
// Include detailed error information in the exception
118129
var errorDetails = $"Infoblox API returned {response.StatusCode}. Zone: {zoneName}, Record: {cleanName}, Response: {result}";
130+
_logger?.LogError("[Infoblox] API Error: {ErrorDetails}", errorDetails);
119131
throw new InvalidOperationException(errorDetails);
120132
}
121133

0 commit comments

Comments
 (0)