Skip to content

Commit 9f2a086

Browse files
debug infoblox
1 parent a7d3f6e commit 9f2a086

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

AcmeCaPlugin/Clients/DNS/InfobloxDnsProvider.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,38 @@ public async Task<bool> CreateRecordAsync(string recordName, string txtValue)
8484
// Delete all existing records with this name
8585
foreach (var record in records.EnumerateArray())
8686
{
87-
var recordRef = record.GetProperty("_ref").GetString();
88-
if (!string.IsNullOrEmpty(recordRef))
87+
if (!record.TryGetProperty("_ref", out var refProperty))
8988
{
89+
_logger?.LogWarning("[Infoblox] Record does not have _ref property");
90+
continue;
91+
}
92+
93+
var recordRef = refProperty.GetString();
94+
if (string.IsNullOrEmpty(recordRef))
95+
{
96+
_logger?.LogWarning("[Infoblox] Record _ref is null or empty");
97+
continue;
98+
}
99+
100+
try
101+
{
102+
_logger?.LogDebug("[Infoblox] Attempting to delete record with ref: {RecordRef}", recordRef);
90103
var deleteResponse = await _httpClient.DeleteAsync(recordRef);
91-
_logger?.LogDebug("[Infoblox] Deleted existing TXT record {RecordRef}: {StatusCode}", recordRef, deleteResponse.StatusCode);
104+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
105+
106+
_logger?.LogDebug("[Infoblox] Delete response: {StatusCode}, Body: {Body}",
107+
deleteResponse.StatusCode, deleteResult);
108+
109+
if (!deleteResponse.IsSuccessStatusCode)
110+
{
111+
_logger?.LogWarning("[Infoblox] Failed to delete record {RecordRef}: {StatusCode} - {Response}",
112+
recordRef, deleteResponse.StatusCode, deleteResult);
113+
}
114+
}
115+
catch (Exception deleteEx)
116+
{
117+
_logger?.LogError(deleteEx, "[Infoblox] Exception while deleting record {RecordRef}", recordRef);
118+
// Continue anyway - we'll try to create the new record
92119
}
93120
}
94121
}

0 commit comments

Comments
 (0)