Run container restart after certificate copy so exchange takes effect.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-29 09:45:43 +02:00
co-authored by Cursor
parent a5557b44fa
commit b1e1789fd1
2 changed files with 91 additions and 19 deletions
@@ -191,29 +191,85 @@ public sealed class DeploymentOrchestrator
target.BackupDirectoryName,
cancellationToken);
string copyStatus = $"Zertifikat kopiert: {Path.GetFileName(deployedFilePath)}";
string copyStatus =
$"Zertifikat kopiert: {Path.GetFileName(deployedFilePath)}";
steps.Add(copyStatus);
logger.Write($"[{target.Name}] {copyStatus} | Ziel={deployedFilePath}");
logger.Write(
$"[{target.Name}] {copyStatus} | Ziel={deployedFilePath}");
progress?.Report(new TargetProgressUpdate(
target.Id,
copyStatus,
true));
// Nach dem Dateitausch Container neu starten, damit Sonic
// das neue Zertifikat lädt. Ohne Neustart bleibt oft das Alte aktiv.
bool restartNeeded =
target.RestartType is RestartType.SonicContainer
or RestartType.SonicContainerWithXapi
|| !string.IsNullOrWhiteSpace(target.ContainerName);
if (!restartNeeded)
{
return new TargetStepResult
{
TargetId = target.Id,
TargetName = target.Name,
Success = true,
StatusText = "Kopieren erfolgreich (kein Neustart)",
Detail = deployedFilePath,
Steps = steps,
StartedAt = targetStart,
FinishedAt = DateTimeOffset.Now,
CopySucceeded = true,
RestartSucceeded = true,
TlsSucceeded = true,
ObservedFingerprint = null
};
}
progress?.Report(new TargetProgressUpdate(
target.Id,
"Zertifikat kopiert Container-Neustart …",
true));
(bool restartOk, string restartStatus, string? restartDetail) =
await _restartExecutor.ExecuteAsync(
target,
cancellationToken);
string restartStep =
$"{restartStatus}: {restartDetail}";
steps.Add(restartStep);
logger.Write(
$"[{target.Name}] Restart nach Deploy: {restartStep}");
progress?.Report(new TargetProgressUpdate(
target.Id,
restartOk
? "Austausch + Neustart OK"
: restartStatus,
restartOk));
return new TargetStepResult
{
TargetId = target.Id,
TargetName = target.Name,
Success = true,
StatusText = "Kopieren erfolgreich",
Detail = deployedFilePath,
Success = restartOk,
StatusText = restartOk
? "Austausch + Neustart OK"
: $"Kopiert, Neustart fehlgeschlagen: {restartStatus}",
Detail =
$"Datei={deployedFilePath}"
+ Environment.NewLine
+ (restartDetail ?? string.Empty),
Steps = steps,
StartedAt = targetStart,
FinishedAt = DateTimeOffset.Now,
CopySucceeded = true,
RestartSucceeded = true,
RestartSucceeded = restartOk,
TlsSucceeded = true,
ObservedFingerprint = null
};