Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
97d1b53
Bump actions/upload-artifact from 3.1.1 to 3.1.2 (#314)
dependabot[bot] Jan 11, 2023
c0e35e9
Bump actions/cache from 3.0.11 to 3.2.3 (#313)
dependabot[bot] Jan 11, 2023
2831d3c
Bump Microsoft.NET.Test.Sdk from 17.4.0 to 17.4.1 (#309)
dependabot[bot] Jan 11, 2023
7ad457a
Clears payload at startup (#326)
mocsharp Feb 5, 2023
e3a463b
Fix payload assembler not respecting user configured timeout window (…
mocsharp Feb 9, 2023
1067bb0
Bump Microsoft.EntityFrameworkCore.InMemory from 6.0.13 to 6.0.14 (#337)
dependabot[bot] Feb 21, 2023
55f78e3
Bump Microsoft.EntityFrameworkCore from 6.0.13 to 6.0.14 (#336)
dependabot[bot] Feb 21, 2023
efaab5c
Bump Microsoft.EntityFrameworkCore.Design from 6.0.13 to 6.0.14 (#335)
dependabot[bot] Feb 21, 2023
49227ef
Bump anchore/scan-action from 3.3.2 to 3.3.4 (#334)
dependabot[bot] Feb 21, 2023
65c549e
Bump actions/cache from 3.2.3 to 3.2.5 (#333)
dependabot[bot] Feb 21, 2023
539ae4d
Bump docker/build-push-action from 3.2.0 to 4.0.0 (#328)
dependabot[bot] Feb 21, 2023
2267f21
Bump docker/metadata-action from 4.1.1 to 4.3.0 (#319)
dependabot[bot] Feb 21, 2023
3b1b3c7
Bump actions/cache from 3.2.5 to 3.2.6 (#342)
dependabot[bot] Mar 8, 2023
a176f43
Bump Microsoft.EntityFrameworkCore.Sqlite from 6.0.13 to 6.0.14 (#338)
dependabot[bot] Mar 8, 2023
86cb04c
Update messaging lib to 0.1.20 (#343)
mocsharp Mar 8, 2023
7c97f1e
Log payload move exception (#323)
mocsharp Mar 8, 2023
4906d18
Update message lib to 0.1.21 (#345)
mocsharp Mar 10, 2023
1a2af0c
gh-347 Remove incomplete payloads on timeout (#348)
mocsharp Mar 11, 2023
76b145d
Bump Microsoft.NET.Test.Sdk from 17.4.1 to 17.5.0 (#354)
dependabot[bot] Mar 15, 2023
4359c79
Bump gittools/actions from 0.9.15 to 0.10.2 (#352)
dependabot[bot] Mar 15, 2023
4142479
Bump actions/cache from 3.2.6 to 3.3.1 (#350)
dependabot[bot] Mar 15, 2023
88f1f3e
upping licenses
neildsouth Mar 16, 2023
8a4d6f3
upped dependancies
neildsouth Mar 16, 2023
9a11492
Merge pull request #356 from Project-MONAI/ac1619-nds
neildsouth Mar 16, 2023
222c747
Update Storage & Messaging libraries (#355)
mocsharp Mar 17, 2023
a8caee3
Add PUT /config/ae (#371)
mocsharp Mar 28, 2023
fcbd588
gh-347 Update log statement for debugging (#366)
mocsharp Mar 28, 2023
ac7d557
Set time limit when calling Storage List/Verify APIs (#378)
mocsharp Apr 6, 2023
1e63847
Bump anchore/scan-action from 3.3.4 to 3.3.5 (#373)
dependabot[bot] Apr 18, 2023
a83ef62
Resets ActionBlock if faulted or cancelled. (#385)
mocsharp Apr 20, 2023
10523c4
Merge branch 'main' into patch/0.3.17
mocsharp Apr 20, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.gitversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ branches:
ignore:
sha: []
merge-message-formats: {}
next-version: 0.3.15
next-version: 0.3.16
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ jobs:

- name: Anchore container scan
id: anchore-scan
uses: anchore/scan-action@v3.3.4
uses: anchore/scan-action@v3.3.5
if: ${{ (matrix.os == 'ubuntu-latest') }}
with:
image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
Expand Down
1 change: 1 addition & 0 deletions src/Api/Storage/Payload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public TimeSpan Elapsed
public string? CalledAeTitle { get => Files.OfType<DicomFileStorageMetadata>().Select(p => p.CalledAeTitle).FirstOrDefault(); }

public int FilesUploaded { get => Files.Count(p => p.IsUploaded); }

public int FilesFailedToUpload { get => Files.Count(p => p.IsUploadFailed); }

public Payload(string key, string correlationId, uint timeout)
Expand Down
10 changes: 10 additions & 0 deletions src/Common/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,15 @@ public static async Task<bool> Post<TInput>(this ActionBlock<TInput> actionBlock
await Task.Delay(delay).ConfigureAwait(false);
return actionBlock.Post(input);
}

/// <summary>
/// Checks if a given task is faulted or cancelled.
/// </summary>
/// <param name="task">The task object</param>
/// <returns>True if canceled or faulted. False otherwise.</returns>
public static bool IsCanceledOrFaulted(this Task task)
{
return task.IsCanceled || task.IsFaulted;
}
}
}
2 changes: 1 addition & 1 deletion src/Configuration/DicomWebConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DicomWebConfiguration
/// Gets or sets the maximum number of simultaneous DICOMweb connections.
/// </summary>
[ConfigurationKeyName("maximumNumberOfConnections")]
public int MaximumNumberOfConnection { get; set; } = 2;
public ushort MaximumNumberOfConnection { get; set; } = 2;

/// <summary>
/// Gets or set the maximum allowed file size in bytes with default to 2GiB.
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/ScuConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ScuConfiguration
/// Gets or sets the maximum number of simultaneous DICOM associations for the SCU service.
/// </summary>
[ConfigurationKeyName("maximumNumberOfAssociations")]
public int MaximumNumberOfAssociations { get; set; } = 8;
public ushort MaximumNumberOfAssociations { get; set; } = 8;

public ScuConfiguration()
{
Expand Down
50 changes: 50 additions & 0 deletions src/InformaticsGateway/Common/PostPayloadException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2023 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Runtime.Serialization;
using Monai.Deploy.InformaticsGateway.Api.Storage;

namespace Monai.Deploy.InformaticsGateway.Common
{
internal class PostPayloadException : Exception
{
public Payload.PayloadState TargetQueue { get; }
public Payload Payload { get; }

public PostPayloadException()
{
}

public PostPayloadException(Api.Storage.Payload.PayloadState targetState, Payload payload)
{
TargetQueue = targetState;
Payload = payload;
}

public PostPayloadException(string message) : base(message)
{
}

public PostPayloadException(string message, Exception innerException) : base(message, innerException)
{
}

protected PostPayloadException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
6 changes: 3 additions & 3 deletions src/InformaticsGateway/Logging/Log.3000.PayloadAssembler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 MONAI Consortium
* Copyright 2022-2023 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,8 +33,8 @@ public static partial class Log
[LoggerMessage(EventId = 3004, Level = LogLevel.Trace, Message = "Number of incomplete payloads waiting for processing: {count}.")]
public static partial void BucketsActive(this ILogger logger, int count);

[LoggerMessage(EventId = 3005, Level = LogLevel.Trace, Message = "Checking elapsed time for bucket: {key} with timeout set to {timeout}s. Elapsed {elapsed}s with {failedFiles} failures out of {totalNumberOfFiles}.")]
public static partial void BucketElapsedTime(this ILogger logger, string key, uint timeout, double elapsed, int totalNumberOfFiles, int failedFiles);
[LoggerMessage(EventId = 3005, Level = LogLevel.Trace, Message = "Checking elapsed time for bucket: {key} with timeout set to {timeout}s. Elapsed {elapsed}s with {succeededFiles} uplaoded and {failedFiles} failures out of {totalNumberOfFiles}.")]
public static partial void BucketElapsedTime(this ILogger logger, string key, uint timeout, double elapsed, int totalNumberOfFiles, int succeededFiles, int failedFiles);

[LoggerMessage(EventId = 3007, Level = LogLevel.Information, Message = "Bucket {key} sent to processing queue with {count} files.")]
public static partial void BucketReady(this ILogger logger, string key, int count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static partial class Log
[LoggerMessage(EventId = 4010, Level = LogLevel.Debug, Message = "File {path} exists={exists}.")]
public static partial void VerifyFileExists(this ILogger logger, string path, bool exists);

[LoggerMessage(EventId = 4011, Level = LogLevel.Information, Message = "Initializing Object Uploader service with {threads} workers.")]
[LoggerMessage(EventId = 4011, Level = LogLevel.Information, Message = "Initializing Object Uploser service with {threads} workers.")]
public static partial void InitializeThreads(this ILogger logger, int threads);
}
}
6 changes: 6 additions & 0 deletions src/InformaticsGateway/Logging/Log.500.ExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,11 @@ public static partial class Log

[LoggerMessage(EventId = 533, Level = LogLevel.Error, Message = "Recovering messaging service connection due to {reason}.")]
public static partial void MessagingServiceErrorRecover(this ILogger logger, string reason);

[LoggerMessage(EventId = 534, Level = LogLevel.Error, Message = "Error posting export job for processing correlation ID {correlationId}, export task ID {exportTaskId}.")]
public static partial void ErrorPostingExportJobToQueue(this ILogger logger, string correlationId, string exportTaskId);

[LoggerMessage(EventId = 535, Level = LogLevel.Warning, Message = "Exceeded maximum number of worker in {serviceName}: {count}.")]
public static partial void ExceededMaxmimumNumberOfWorkers(this ILogger logger, string serviceName, ulong count);
}
}
12 changes: 12 additions & 0 deletions src/InformaticsGateway/Logging/Log.700.PayloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,17 @@ public static partial class Log

[LoggerMessage(EventId = 743, Level = LogLevel.Error, Message = "Exception moving payload.")]
public static partial void PayloadMoveException(this ILogger logger, Exception ex);

[LoggerMessage(EventId = 744, Level = LogLevel.Warning, Message = "PayloadNotification move payload queue: faulted: {isFauled}, cancelled: {isCancelled}.")]
public static partial void MoveQueueFaulted(this ILogger logger, bool isFauled, bool isCancelled);

[LoggerMessage(EventId = 745, Level = LogLevel.Warning, Message = "PayloadNotification publishing payload queue: faulted: {isFauled}, cancelled: {isCancelled}.")]
public static partial void PublishQueueFaulted(this ILogger logger, bool isFauled, bool isCancelled);

[LoggerMessage(EventId = 746, Level = LogLevel.Error, Message = "Error posting payload to move queue.")]
public static partial void ErrorPostingJobToMovePayloadsQueue(this ILogger logger);

[LoggerMessage(EventId = 747, Level = LogLevel.Error, Message = "Error posting payload to publish queue.")]
public static partial void ErrorPostingJobToPublishPayloadsQueue(this ILogger logger);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private async void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
var payload = await _payloads[key].Task.ConfigureAwait(false);
using var loggerScope = _logger.BeginScope(new LoggingDataDictionary<string, object> { { "CorrelationId", payload.CorrelationId } });

_logger.BucketElapsedTime(key, payload.Timeout, payload.ElapsedTime().TotalSeconds, payload.Files.Count, payload.FilesFailedToUpload);
_logger.BucketElapsedTime(key, payload.Timeout, payload.ElapsedTime().TotalSeconds, payload.Files.Count, payload.FilesUploaded, payload.FilesFailedToUpload);
// Wait for timer window closes before sending payload for processing
if (payload.HasTimedOut)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public async Task MoveFilesAsync(Payload payload, ActionBlock<Payload> moveQueue
var action = await UpdatePayloadState(payload, ex, cancellationToken).ConfigureAwait(false);
if (action == PayloadAction.Updated)
{
await moveQueue.Post(payload, _options.Value.Storage.Retries.RetryDelays.ElementAt(payload.RetryCount - 1)).ConfigureAwait(false);
if (!await moveQueue.Post(payload, _options.Value.Storage.Retries.RetryDelays.ElementAt(payload.RetryCount - 1)).ConfigureAwait(false))
{
throw new PostPayloadException(Payload.PayloadState.Move, payload);
}
}
}
finally
Expand All @@ -111,7 +114,11 @@ private async Task NotifyIfCompleted(Payload payload, ActionBlock<Payload> notif
await repository.UpdateAsync(payload, cancellationToken).ConfigureAwait(false);
_logger.PayloadSaved(payload.PayloadId);

notificationQueue.Post(payload);
if (!notificationQueue.Post(payload))
{
throw new PostPayloadException(Payload.PayloadState.Notify, payload);
}

_logger.PayloadReadyToBePublished(payload.PayloadId);
}
else // we should never hit this else block.
Expand Down Expand Up @@ -185,7 +192,7 @@ await _storageService.CopyObjectAsync(

await VerifyFileExists(payloadId, file, cancellationToken).ConfigureAwait(false);
}
catch (StorageServiceException ex) when (ex.Message.Contains("Not found", StringComparison.OrdinalIgnoreCase)) // TODO: StorageLib shall not throw any errors from MINIO
catch (StorageObjectNotFoundException ex) when (ex.Message.Contains("Not found", StringComparison.OrdinalIgnoreCase)) // TODO: StorageLib shall not throw any errors from MINIO
{
// when file cannot be found on the Storage Service, we assume file has been moved previously by verifying the file exists on destination.
_logger.FileMissingInPayload(payloadId, file.GetTempStoragPath(_options.Value.Storage.RemoteTemporaryStoragePath), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ public async Task NotifyAsync(Payload payload, ActionBlock<Payload> notification
var action = await UpdatePayloadState(payload, cancellationToken).ConfigureAwait(false);
if (action == PayloadAction.Updated)
{
await notificationQueue.Post(payload, _options.Value.Messaging.Retries.RetryDelays.ElementAt(payload.RetryCount - 1)).ConfigureAwait(false);
_logger.FailedToPublishWorkflowRequest(payload.PayloadId, ex);
if (!await notificationQueue.Post(payload, _options.Value.Messaging.Retries.RetryDelays.ElementAt(payload.RetryCount - 1)).ConfigureAwait(false))
{
throw new PostPayloadException(Payload.PayloadState.Notify, payload);
}
}
}
}
Expand Down
Loading