Run container restart after certificate copy so exchange takes effect.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1462,8 +1462,8 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
btnRestartOnly.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
btnRestartOnly.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
btnRestartOnly.Click += async (_, _) => await RunRestartOnlyAsync();
|
btnRestartOnly.Click += async (_, _) => await RunRestartOnlyAsync();
|
||||||
|
|
||||||
btnDeploy = CreatePrimaryButton("Deployment starten");
|
btnDeploy = CreatePrimaryButton("Austauschen + Neustart");
|
||||||
btnDeploy.Size = new Size(170, 42);
|
btnDeploy.Size = new Size(190, 42);
|
||||||
btnDeploy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
btnDeploy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
btnDeploy.Visible = true;
|
btnDeploy.Visible = true;
|
||||||
btnDeploy.Click += async (_, _) => await RunDeploymentAsync();
|
btnDeploy.Click += async (_, _) => await RunDeploymentAsync();
|
||||||
@@ -2013,11 +2013,24 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string targetSummary = string.Join(
|
||||||
|
Environment.NewLine,
|
||||||
|
selectedTargets.Select(target =>
|
||||||
|
$"• {target.Name}"
|
||||||
|
+ Environment.NewLine
|
||||||
|
+ $" Datei → {target.FullTargetPath}"
|
||||||
|
+ Environment.NewLine
|
||||||
|
+ $" danach Neustart: {target.ContainerName}"));
|
||||||
|
|
||||||
DialogResult confirm = MessageBox.Show(
|
DialogResult confirm = MessageBox.Show(
|
||||||
this,
|
this,
|
||||||
$"Zertifikat wirklich auf {selectedTargets.Count} Ziel(e) kopieren?\n\n" +
|
"Zertifikat wirklich austauschen?\n\n"
|
||||||
$"Datei: {Path.GetFileName(txtCertificatePath.Text)}",
|
+ "Ablauf je Ziel:\n"
|
||||||
"Deployment starten",
|
+ "1) Datei kopieren (Backup der alten Datei)\n"
|
||||||
|
+ "2) Sonic-Container neu starten (MfApi)\n\n"
|
||||||
|
+ $"Quelle: {Path.GetFileName(txtCertificatePath.Text)}\n\n"
|
||||||
|
+ targetSummary,
|
||||||
|
"Austauschen + Neustart",
|
||||||
MessageBoxButtons.YesNo,
|
MessageBoxButtons.YesNo,
|
||||||
MessageBoxIcon.Warning);
|
MessageBoxIcon.Warning);
|
||||||
|
|
||||||
@@ -2033,7 +2046,7 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
UpdateToNextStep(3);
|
UpdateToNextStep(3);
|
||||||
|
|
||||||
SetStatus(
|
SetStatus(
|
||||||
$"Kopiere Zertifikat auf {selectedTargets.Count} Ziel(e) ...",
|
$"Tausche Zertifikat auf {selectedTargets.Count} Ziel(e) und starte Container neu …",
|
||||||
isError: false);
|
isError: false);
|
||||||
|
|
||||||
Progress<TargetProgressUpdate> progress = new(update =>
|
Progress<TargetProgressUpdate> progress = new(update =>
|
||||||
@@ -2061,15 +2074,16 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
if (runResult.OverallSuccess)
|
if (runResult.OverallSuccess)
|
||||||
{
|
{
|
||||||
SetStatus(
|
SetStatus(
|
||||||
$"Deployment erfolgreich: {runResult.TargetResults.Count} Ziel(e).",
|
$"Austausch + Neustart OK ({runResult.TargetResults.Count} Ziel(e)).",
|
||||||
isError: false);
|
isError: false);
|
||||||
|
|
||||||
UpdateToNextStep(4);
|
UpdateToNextStep(4);
|
||||||
|
await ProbeTargetCertificatesAsync();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetStatus(
|
SetStatus(
|
||||||
"Deployment für mindestens ein Ziel fehlgeschlagen.",
|
"Austausch für mindestens ein Ziel fehlgeschlagen.",
|
||||||
isError: true);
|
isError: true);
|
||||||
|
|
||||||
string details = string.Join(
|
string details = string.Join(
|
||||||
@@ -2083,23 +2097,25 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
|
|
||||||
CopyableErrorDialog.Show(
|
CopyableErrorDialog.Show(
|
||||||
this,
|
this,
|
||||||
"Deployment fehlgeschlagen",
|
"Austausch fehlgeschlagen",
|
||||||
details);
|
details);
|
||||||
|
|
||||||
|
await ProbeTargetCertificatesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
SetStatus("Deployment abgebrochen.", isError: true);
|
SetStatus("Austausch abgebrochen.", isError: true);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SetStatus(
|
SetStatus(
|
||||||
$"Deployment fehlgeschlagen: {ex.Message}",
|
$"Austausch fehlgeschlagen: {ex.Message}",
|
||||||
isError: true);
|
isError: true);
|
||||||
|
|
||||||
CopyableErrorDialog.Show(
|
CopyableErrorDialog.Show(
|
||||||
this,
|
this,
|
||||||
"Deployment fehlgeschlagen",
|
"Austausch fehlgeschlagen",
|
||||||
ex.ToString());
|
ex.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -191,33 +191,89 @@ public sealed class DeploymentOrchestrator
|
|||||||
target.BackupDirectoryName,
|
target.BackupDirectoryName,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
string copyStatus = $"Zertifikat kopiert: {Path.GetFileName(deployedFilePath)}";
|
string copyStatus =
|
||||||
|
$"Zertifikat kopiert: {Path.GetFileName(deployedFilePath)}";
|
||||||
|
|
||||||
steps.Add(copyStatus);
|
steps.Add(copyStatus);
|
||||||
logger.Write($"[{target.Name}] {copyStatus} | Ziel={deployedFilePath}");
|
logger.Write(
|
||||||
|
$"[{target.Name}] {copyStatus} | Ziel={deployedFilePath}");
|
||||||
|
|
||||||
progress?.Report(new TargetProgressUpdate(
|
progress?.Report(new TargetProgressUpdate(
|
||||||
target.Id,
|
target.Id,
|
||||||
copyStatus,
|
copyStatus,
|
||||||
true));
|
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
|
return new TargetStepResult
|
||||||
{
|
{
|
||||||
TargetId = target.Id,
|
TargetId = target.Id,
|
||||||
TargetName = target.Name,
|
TargetName = target.Name,
|
||||||
Success = true,
|
Success = true,
|
||||||
StatusText = "Kopieren erfolgreich",
|
StatusText = "Kopieren erfolgreich (kein Neustart)",
|
||||||
Detail = deployedFilePath,
|
Detail = deployedFilePath,
|
||||||
Steps = steps,
|
Steps = steps,
|
||||||
StartedAt = targetStart,
|
StartedAt = targetStart,
|
||||||
FinishedAt = DateTimeOffset.Now,
|
FinishedAt = DateTimeOffset.Now,
|
||||||
|
|
||||||
CopySucceeded = true,
|
CopySucceeded = true,
|
||||||
RestartSucceeded = true,
|
RestartSucceeded = true,
|
||||||
TlsSucceeded = true,
|
TlsSucceeded = true,
|
||||||
ObservedFingerprint = null
|
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 = 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 = restartOk,
|
||||||
|
TlsSucceeded = true,
|
||||||
|
ObservedFingerprint = null
|
||||||
|
};
|
||||||
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
|
|||||||
Reference in New Issue
Block a user