From 2d0a30758dcdbf94585e87b4246e27086e55e643 Mon Sep 17 00:00:00 2001 From: Markus Heiliger Date: Wed, 24 Mar 2021 18:01:50 -0700 Subject: [PATCH] restart task runner orchestration if org or proj resourcestate is not ready --- .../Handlers/ComponentTaskRunCommandHandler.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/TeamCloud.Orchestrator/Command/Handlers/ComponentTaskRunCommandHandler.cs b/src/TeamCloud.Orchestrator/Command/Handlers/ComponentTaskRunCommandHandler.cs index 9b18575d..e4ec58da 100644 --- a/src/TeamCloud.Orchestrator/Command/Handlers/ComponentTaskRunCommandHandler.cs +++ b/src/TeamCloud.Orchestrator/Command/Handlers/ComponentTaskRunCommandHandler.cs @@ -56,8 +56,10 @@ public async Task HandleAsync(ComponentTaskRunCommand command, I .CallActivityWithRetryAsync(nameof(OrganizationGetActivity), new OrganizationGetActivity.Input() { Id = commandResult.Result.Organization }) .ConfigureAwait(true); - if (organization.ResourceState != ResourceState.Succeeded) - throw new NotSupportedException($"Organization {organization} is in not supported resource state: {organization.ResourceState}"); + if (!organization.ResourceState.IsFinal()) + orchestrationContext.ContinueAsNew(command, false); + else if (organization.ResourceState == ResourceState.Failed) + throw new NotSupportedException("Can't process task when organization resource state is 'Failed'"); } var project = await orchestrationContext @@ -70,8 +72,10 @@ public async Task HandleAsync(ComponentTaskRunCommand command, I .CallActivityWithRetryAsync(nameof(ProjectGetActivity), new ProjectGetActivity.Input() { Organization = commandResult.Result.Organization, Id = commandResult.Result.ProjectId }) .ConfigureAwait(true); - if (project.ResourceState != ResourceState.Succeeded) - throw new NotSupportedException($"Project {project} is in not supported resource state: {project.ResourceState}"); + if (!project.ResourceState.IsFinal()) + orchestrationContext.ContinueAsNew(command, false); + else if (project.ResourceState == ResourceState.Failed) + throw new NotSupportedException("Can't process task when project resource state is 'Failed'"); } var component = await orchestrationContext