diff --git a/Common/src/Storage/SessionTableExtensions.cs b/Common/src/Storage/SessionTableExtensions.cs index 5996d958c..83582f4c5 100644 --- a/Common/src/Storage/SessionTableExtensions.cs +++ b/Common/src/Storage/SessionTableExtensions.cs @@ -233,7 +233,7 @@ public static async Task ResumeSessionAsync(this ISessionTable sess CancellationToken cancellationToken = default) { var session = await sessionTable.UpdateOneSessionAsync(sessionId, - data => data.Status == SessionStatus.Paused, + data => data.Status == SessionStatus.Paused || data.Status == SessionStatus.Running, new UpdateDefinition().Set(model => model.Status, SessionStatus.Running), false, @@ -251,8 +251,8 @@ public static async Task ResumeSessionAsync(this ISessionTable sess switch (session.Status) { case SessionStatus.Paused: - throw new UnreachableException($"Session status should be {SessionStatus.Running} but is {session.Status}"); case SessionStatus.Running: + throw new UnreachableException($"Session status should be {SessionStatus.Running} but is {session.Status}"); case SessionStatus.Purged: case SessionStatus.Cancelled: throw new InvalidSessionTransitionException($"Cannot resume a session with status {session.Status}"); diff --git a/Common/src/gRPC/Services/GrpcSessionsService.cs b/Common/src/gRPC/Services/GrpcSessionsService.cs index 0f5d176be..ddad9d9d7 100644 --- a/Common/src/gRPC/Services/GrpcSessionsService.cs +++ b/Common/src/gRPC/Services/GrpcSessionsService.cs @@ -35,8 +35,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Logging; -using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; - namespace ArmoniK.Core.Common.gRPC.Services; [Authorize(AuthenticationSchemes = Authenticator.SchemeName)] @@ -516,36 +514,28 @@ public override async Task ResumeSession(ResumeSessionReq catch (SessionNotFoundException e) { logger_.LogWarning(e, - "Error while getting session"); + "Error while resuming session"); throw new RpcException(new Status(StatusCode.NotFound, "Session not found")); } catch (InvalidSessionTransitionException e) { logger_.LogWarning(e, - "Error while cancelling session"); + "Error while resuming session"); throw new RpcException(new Status(StatusCode.FailedPrecondition, "Session is in a state that cannot be cancelled")); } catch (ArmoniKException e) { logger_.LogWarning(e, - "Error while getting session"); - await taskTable_.UpdateManyTasks(data => data.SessionId == request.SessionId && data.Status == TaskStatus.Submitted, - new UpdateDefinition().Set(data => data.Status, - TaskStatus.Paused)) - .ConfigureAwait(false); + "Error while resuming session"); throw new RpcException(new Status(StatusCode.Internal, "Internal Armonik Exception, see application logs")); } catch (Exception e) { logger_.LogWarning(e, - "Error while getting session"); - await taskTable_.UpdateManyTasks(data => data.SessionId == request.SessionId && data.Status == TaskStatus.Submitted, - new UpdateDefinition().Set(data => data.Status, - TaskStatus.Paused)) - .ConfigureAwait(false); + "Error while resuming session"); throw new RpcException(new Status(StatusCode.Unknown, "Unknown Exception, see application logs")); }