Merge pull request #1433 from tgstation/MinorestOfFixes [TGSDeploy]

Detaching a deleted instance doesn't throw
This commit is contained in:
Jordan Dominion
2023-03-24 22:01:09 -04:00
committed by GitHub
4 changed files with 31 additions and 8 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="ControlPanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>5.3.2</TgsCoreVersion>
<TgsCoreVersion>5.3.3</TgsCoreVersion>
<TgsConfigVersion>4.4.0</TgsConfigVersion>
<TgsApiVersion>9.8.1</TgsApiVersion>
<TgsApiLibraryVersion>10.2.0</TgsApiLibraryVersion>
@@ -719,18 +719,40 @@ namespace Tgstation.Server.Host.Components.Deployment
{
var noEstimate = !estimatedDuration.HasValue;
progressReporter.StageName = currentStage;
progressReporter.ReportProgress(noEstimate ? null : 0);
double? lastReport = noEstimate ? null : 0;
progressReporter.ReportProgress(lastReport);
var sleepInterval = estimatedDuration.HasValue ? estimatedDuration.Value / 100 : TimeSpan.FromMilliseconds(250);
var minimumSleepInterval = TimeSpan.FromMilliseconds(250);
var sleepInterval = estimatedDuration.HasValue ? estimatedDuration.Value / 100 : minimumSleepInterval;
if (estimatedDuration.HasValue)
{
logger.LogDebug("Compile is expected to take: {0}", estimatedDuration);
}
else
{
logger.LogTrace("No metric to estimate compile time.");
}
logger.LogDebug("Compile is expected to take: {0}", estimatedDuration);
try
{
for (var iteration = 0; iteration < (estimatedDuration.HasValue ? 99 : Int32.MaxValue); ++iteration)
{
await Task.Delay(sleepInterval, cancellationToken);
var nextInterval = DateTimeOffset.Now + sleepInterval;
do
{
var remainingSleepThisInterval = nextInterval - DateTimeOffset.Now;
var nextSleepSpan = remainingSleepThisInterval < minimumSleepInterval ? remainingSleepThisInterval : minimumSleepInterval;
await Task.Delay(nextSleepSpan, cancellationToken);
progressReporter.StageName = currentStage;
progressReporter.ReportProgress(lastReport);
}
while (DateTimeOffset.Now < nextInterval);
progressReporter.StageName = currentStage;
progressReporter.ReportProgress(noEstimate ? null : sleepInterval * (iteration + 1) / estimatedDuration.Value);
lastReport = noEstimate ? null : sleepInterval * (iteration + 1) / estimatedDuration.Value;
progressReporter.ReportProgress(lastReport);
}
}
catch (OperationCanceledException)
@@ -305,7 +305,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
compileJob.RevisionInformation.OriginCommitSha,
compileJob.RevisionInformation.CommitSha,
compileJob.GitHubDeploymentId.HasValue
? $"{Environment.NewLine}[GitHub Deployments](https://github.com/{remoteRepositoryOwner}/{remoteRepositoryName}/deployments/activity_log?environment=TGS%3A%20{Metadata.Name})"
? $"{Environment.NewLine}[GitHub Deployments](https://github.com/{remoteRepositoryOwner}/{remoteRepositoryName}/deployments/activity_log?environment=TGS%3A+{Metadata.Name.Replace(" ", "+", StringComparison.Ordinal)})"
: String.Empty);
/// <summary>
@@ -303,7 +303,8 @@ namespace Tgstation.Server.Host.Controllers
var attachFileName = ioManager.ConcatPath(originalModel.Path, InstanceAttachFileName);
try
{
await ioManager.WriteAllBytes(attachFileName, Array.Empty<byte>(), cancellationToken);
if (await ioManager.DirectoryExists(originalModel.Path, cancellationToken))
await ioManager.WriteAllBytes(attachFileName, Array.Empty<byte>(), cancellationToken);
}
catch (OperationCanceledException)
{