Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Project Variable Templates - WorkerPool Default Value Set to WorkerPool Name Causes "Octopus.Core.Model.Exceptions.EntityNotFoundException"

Open FinnianDempsey opened this issue 1 year ago • 1 comments

Severity

Not Blocking, Workaround Exists

Version

2024.1.1743

Latest Version

I could reproduce the problem in the latest build

What happened?

When configuring a Project Variable Templates with a WorkerPool Control Type, if the Default Value is set to the Name of the WorkerPool then deployments will fail with an error Octopus.Core.Model.Exceptions.EntityNotFoundException

Reproduction

  1. Create Tenant enabled Project
  2. Create a Project Variable Template using a WorkerPool variable type with the value of a worker pool's name.
  3. Configure a script step to run on a worker based on a variable, select the workerpool variable from the Project Variable Template
  4. Add a Tenant, connect it to the project, don't set any values for variables.
  5. Deploy release and see error

Error and Stacktrace

Exception of type 'Octopus.Core.Model.Exceptions.EntityNotFoundException' was thrown. Octopus.Core.Model.Exceptions.EntityNotFoundException at Octopus.Core.Persistence.Database.DatabaseDocumentStore`2.Get(TKey id) in DatabaseDocumentStore.cs:line 67 at Octopus.Core.Persistence.Database.FullTableCacheDocumentStoreDecorator`2.Get(TKey id) in FullTableCacheDocumentStoreDecorator.cs:line 61 at Octopus.Core.Persistence.EntityTracking.EntityTracker.GetOrTrack[TDocument,TKey](TKey id, Func`2 getDocument) in EntityTracker.cs:line 49 at Octopus.Core.Persistence.Database.AccessCheckingDocumentStoreDecorator`2.Get(TKey id) in AccessCheckingDocumentStoreDecorator.cs:line 48 at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionPlanner.AddNonSkippedActionsToPlan(DeploymentStep step, PlannedStep plannedStep, ITaskLog taskLog) in ExecutionPlanner.cs:line 547 at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionPlanner.PlanSteps(IList`1 steps, ITaskLog taskLog)+MoveNext() in ExecutionPlanner.cs:line 444 at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source) at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionPlanner.Initialize(ITaskLog taskLog, CancellationToken cancellationToken) in ExecutionPlanner.cs:line 219 at Octopus.Server.Orchestration.ServerTasks.Deploy.DeploymentPlanService.CreateOrResumePlan(DeploymentId deploymentId, ITaskLog taskLog, CancellationToken cancellationToken) in DeploymentPlanService.cs:line 105 at Octopus.Server.Orchestration.ServerTasks.Deploy.DeploymentTaskController.<Execute>b__5_0(IDeploymentPlanService planService, Factory executionPlannerFactory, CancellationToken ct) in DeploymentTaskController.cs:line 53 at Octopus.Server.Infrastructure.Orchestration.UnitsOfWork.UnitOfWorkExecutor.<>c__DisplayClass5_0`2.<Execute in UnitOfWorkExecutor.cs:line 76 at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExtensionMethods.Do(IUnitOfWork unitOfWork, Func`1 action, CancellationToken cancellationToken, String name) in UnitOfWorkExtensionMethods.cs:line 58 at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExtensionMethods.Do(IUnitOfWork unitOfWork, Func`1 action, CancellationToken cancellationToken, String name) in UnitOfWorkExtensionMethods.cs:line 58 at Octopus.Server.Infrastructure.Orchestration.UnitsOfWork.UnitOfWorkExecutor.Execute[T1,T2](Func`4 action, CancellationToken cancellationToken, String name) in UnitOfWorkExecutor.cs:line 79 at Octopus.Server.Infrastructure.Orchestration.UnitsOfWork.UnitOfWorkExecutor.Execute[T1,T2](Func`4 action, CancellationToken cancellationToken, String name) in UnitOfWorkExecutor.cs:line 79 at Octopus.Server.Orchestration.ServerTasks.Deploy.DeploymentTaskController.Execute(CancellationToken cancellationToken) in DeploymentTaskController.cs:line 50 at Octopus.Server.Orchestration.ServerTasks.RunningTask.<>c__DisplayClass35_0.<WorkerTask in RunningTask.cs:line 177 at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExtensionMethods.Do(IUnitOfWork unitOfWork, Func`1 action, CancellationToken cancellationToken, String name) in UnitOfWorkExtensionMethods.cs:line 58 at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExtensionMethods.Do(IUnitOfWork unitOfWork, Func`1 action, CancellationToken cancellationToken, String name) in UnitOfWorkExtensionMethods.cs:line 58 at Octopus.Server.Orchestration.ServerTasks.RunningTask.WorkerTask(CancellationToken cancellationToken) in RunningTask.cs:line 173 at Octopus.Server.Orchestration.ServerTasks.RunningTask.WorkerTask(CancellationToken cancellationToken) in RunningTask.cs:line 184

More Information

Project Variable Template set to WorkerPool name: Screenshot 2023-11-23 at 14 50 50

Deployment Process using the WorkerPool variable: Screenshot 2023-11-23 at 14 51 01

Inherited default value on Tenant Variable is empty: Screenshot 2023-11-23 at 14 51 21

Internal Link - Slack Internal Link - Zendesk

Workaround

Only Project Variable Templates that use the WorkerPool name are effected.

To workaround the issue set the variable default value to a WorkerPool type project variable or the WorkerPool Id, or set the value directly on the Tenant

FinnianDempsey avatar Nov 23 '23 05:11 FinnianDempsey