Skip to content

Commit

Permalink
adding cleanup and file retries
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtallcampbell committed Aug 3, 2024
1 parent 8e83020 commit 34af4db
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Services/ScheduleProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ private void WaitForFileToFinishCopying(string filePath) {
|| _response.DeployRequest.DeployAction == MessageFormats.PlatformServices.Deployment.DeployRequest.Types.DeployActions.Create
|| _response.DeployRequest.DeployAction == MessageFormats.PlatformServices.Deployment.DeployRequest.Types.DeployActions.Delete) {
WaitForFileToFinishCopying(Path.Combine(_scheduleImportDirectory, _response.DeployRequest.YamlFileContents));

string yamlFilePath = Path.Combine(_scheduleImportDirectory, _response.DeployRequest.YamlFileContents);
_response.DeployRequest.YamlFileContents = File.ReadAllText(Path.Combine(_scheduleImportDirectory, _response.DeployRequest.YamlFileContents));
File.Delete(Path.Combine(_scheduleImportDirectory, _response.DeployRequest.YamlFileContents));
File.Delete(yamlFilePath);
}


Expand Down Expand Up @@ -480,7 +482,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} else {
// This lets the schedule retry next go round
if (!File.Exists(Path.Combine(_scheduleImportDirectory, request.YamlFileContents))) {
throw new FileNotFoundException($"YamlFile '{request.YamlFileContents}' does not exist at {_scheduleImportDirectory}.");
throw new FileNotFoundException($"YamlFile '{request.YamlFileContents}' does not exist at {_scheduleImportDirectory}.", fileName: request.YamlFileContents);
}

// Wait for the file to finish copying or timeout if we didn't receive one
Expand All @@ -489,7 +491,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} catch (TimeoutException) {
// Only trip an error if the file is required
if (request.AppContextFile.Required == true) {
throw new FileNotFoundException($"YamlFile '{request.YamlFileContents}' still copying to {_scheduleImportDirectory}.");
throw new FileNotFoundException($"YamlFile '{request.YamlFileContents}' still copying to {_scheduleImportDirectory}.", fileName: request.YamlFileContents);
}
}
}
Expand All @@ -508,7 +510,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} else {
// This lets the schedule retry next go round
if (!File.Exists(Path.Combine(_scheduleImportDirectory, request.AppContainerImage.TarballFileName))) {
throw new FileNotFoundException($"AppContainerImage Tarball'{request.AppContainerImage.TarballFileName}' does not exist at {_scheduleImportDirectory}.");
throw new FileNotFoundException($"AppContainerImage Tarball '{request.AppContainerImage.TarballFileName}' does not exist at {_scheduleImportDirectory}.", fileName: request.AppContainerImage.TarballFileName);
}

// Wait for the file to finish copying or timeout if we didn't receive one
Expand All @@ -517,7 +519,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} catch (TimeoutException) {
// Only trip an error if the file is required
if (request.AppContextFile.Required == true) {
throw new FileNotFoundException($"DockerFile '{request.AppContainerImage.TarballFileName}' still copying to {_scheduleImportDirectory}.");
throw new FileNotFoundException($"DockerFile '{request.AppContainerImage.TarballFileName}' still copying to {_scheduleImportDirectory}.", fileName: request.AppContainerImage.TarballFileName);
}
}
}
Expand All @@ -535,7 +537,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} else {
// This lets the schedule retry next go round
if (!File.Exists(Path.Combine(_scheduleImportDirectory, request.AppContainerBuild.DockerFile))) {
throw new FileNotFoundException($"DockerFile'{request.AppContainerBuild.DockerFile}' does not exist at {_scheduleImportDirectory}.");
throw new FileNotFoundException($"DockerFile'{request.AppContainerBuild.DockerFile}' does not exist at {_scheduleImportDirectory}.", fileName: request.AppContainerBuild.DockerFile);
}

// Wait for the file to finish copying or timeout if we didn't receive one
Expand All @@ -544,7 +546,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} catch (TimeoutException) {
// Only trip an error if the file is required
if (request.AppContextFile.Required == true) {
throw new FileNotFoundException($"DockerFile '{request.AppContainerBuild.DockerFile}' still copying to {_scheduleImportDirectory}.");
throw new FileNotFoundException($"DockerFile '{request.AppContainerBuild.DockerFile}' still copying to {_scheduleImportDirectory}.", fileName: request.AppContainerBuild.DockerFile);
}
}
}
Expand All @@ -562,7 +564,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} else {
// This lets the schedule retry next go round
if (!File.Exists(Path.Combine(_scheduleImportDirectory, request.AppContextFile.FileName))) {
throw new FileNotFoundException($"AppContextFile '{request.AppContextFile.FileName}' does not exist at {_scheduleImportDirectory}.");
throw new FileNotFoundException($"AppContextFile '{request.AppContextFile.FileName}' does not exist at {_scheduleImportDirectory}.", fileName: request.AppContextFile.FileName);
}

// Wait for the file to finish copying or timeout if we didn't receive one
Expand All @@ -571,7 +573,7 @@ private MessageFormats.PlatformServices.Deployment.DeployResponse ValidatePrereq
} catch (TimeoutException) {
// Only trip an error if the file is required
if (request.AppContextFile.Required == true) {
throw new FileNotFoundException($"AppContextFile '{request.AppContextFile.FileName}' still copying to {_scheduleImportDirectory}.");
throw new FileNotFoundException($"AppContextFile '{request.AppContextFile.FileName}' still copying to {_scheduleImportDirectory}.", fileName: request.AppContextFile.FileName);
}
}
}
Expand Down

0 comments on commit 34af4db

Please sign in to comment.