Skip to content

Commit

Permalink
[Fleet Installer] Don't throw when deleting registry value if it's al…
Browse files Browse the repository at this point in the history
…ready deleted (#6672)

## Summary of changes

Don't throw when deleting registry value if it's already deleted.

## Reason for change

The uninstall command should be idempotent. Currently, if you run it
twice, it will fail, because it can't find the crash-tracking key to
delete.

## Implementation details

I assumed `RegistryKey.DeleteValue()` worked like `File.Delete()`. It
doesn't, you need to pass `throwOnMissingValue`.

## Test coverage

Yeah... I still need to write integration tests, and this will be part
of them
  • Loading branch information
andrewlock authored Feb 18, 2025
1 parent 259d478 commit f68b537
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tracer/src/Datadog.FleetInstaller/RegistryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static bool RemoveCrashTrackingKey(ILogger log, TracerValues values, stri
try
{
var key = Registry.LocalMachine.OpenSubKey(registryKeyName, writable: true);
key?.DeleteValue(crashHandlerPath);
key?.DeleteValue(crashHandlerPath, throwOnMissingValue: false);
log.WriteInfo($"Crash tracking handler path '{crashHandlerPath}' removed from '{registryKeyName}'");

return true;
Expand Down Expand Up @@ -83,6 +83,8 @@ public static bool TryGetIisVersion(ILogger log, [NotNullWhen(true)] out Version
var minor = key.GetValue("MinorVersion") as int? ?? 0;

version = new(major: major, minor: minor);

log.WriteInfo($"Found IIS version: '{major}.{minor}'");
return true;
}
catch (Exception ex)
Expand Down

0 comments on commit f68b537

Please sign in to comment.