OctopusDeploy / Issues

| Public | Bug reports and known issues for Octopus Deploy and all related tools
https://octopus.com
162 stars 20 forks source link

Trigger may not fire if step set in release versioning doesn't match step set in channel #8737

Open patrick-smergut-octopus opened 6 months ago

patrick-smergut-octopus commented 6 months ago

Severity

Impacting one customer, potential to impact others

Version

2024.2.4636

Latest Version

None

What happened?

When a trigger fires, there are 2 areas involved that are used to reference a step to get versioning from a package:

If these aren't both pointing to the same step, the trigger can fail to fire even when the same package is being deployed in the different steps.

This seems to happen primarily when the steps referenced are restricted to a different environment and/or channel than those specified in the trigger.

Reproduction

Upload a test package to the internal feed with a dev pre-release tag (e.g. TestPackage.1.0.0-dev.zip).

Create a project with the following:

image

image

Configure a trigger to create/deploy a release:

image

Set the trigger to fire, and when it is processed the below error should be presented.

Error and Stacktrace

| == Failed: Process recurring scheduled triggers ==
17:35:20   Fatal    |   Failed to process scheduled triggers [Deploy to dev]
                    | 
                    |   == Warning: Processing Deploy to dev ==
17:35:20   Info     |     Processing trigger [Deploy to dev](~/app#/Spaces-184/projects/Projects-5147/triggers/scheduled/edit/ProjectTriggers-1663)...
17:35:20   Info     |     Creating and deploying a new release for project Break project trigger in the Dev only channel to Development.
17:35:20   Error    |     A scheduled trigger failed while attempting to create and deploy a release
                    |     Object reference not set to an instance of an object.
                    |     System.NullReferenceException: Object reference not set to an instance of an object.
                    |     at Octopus.Server.Communications.Packages.SnapshotCreationFactory`2.SetVersionFromVersioningStrategy(IOctopusQueryExecutor queryExecutor, Project project, Release release, IEnumerable`1 candidateVersioningSteps, VariableCollection variables, IReadOnlyCollection`1 channelsForProject) in ./source/Octopus.Server/Communications/Packages/SnapshotCreationFactory.cs:line 214
                    |     at Octopus.Server.Communications.Packages.SnapshotCreationFactory`2.<>c__DisplayClass16_0.<FillAndCreateSnapshot>b__4(Release r) in ./source/Octopus.Server/Communications/Packages/SnapshotCreationFactory.cs:line 168
                    |     at Octopus.Core.Model.Projects.SnapshotMatchExtensionMethods.<>c__DisplayClass0_0.<<Switch>b__0>d.MoveNext() in ./source/Octopus.Core/Model/Projects/ISnapshot.cs:line 33
                    |     --- End of stack trace from previous location ---
                    |     at Octopus.Core.Model.Projects.SnapshotMatchExtensionMethods.<>c__DisplayClass2_0.<<Switch>b__0>d.MoveNext() in ./source/Octopus.Core/Model/Projects/ISnapshot.cs:line 66
                    |     --- End of stack trace from previous location ---
                    |     at Octopus.Core.Model.Projects.SnapshotMatchExtensionMethods.Switch(ISnapshot snapshot, Func`3 releaseAction, Func`3 runbookSnapshotAction, CancellationToken cancellationToken) in ./source/Octopus.Core/Model/Projects/ISnapshot.cs:line 62
                    |     at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
                    |     at Octopus.Core.Model.Projects.SnapshotMatchExtensionMethods.Switch(ISnapshot snapshot, Action`1 releaseAction, Action`1 runbookSnapshotAction) in ./source/Octopus.Core/Model/Projects/ISnapshot.cs:line 29
                    |     at Octopus.Server.Communications.Packages.SnapshotCreationFactory`2.FillAndCreateSnapshot(IOctopusQueryExecutor queryExecutor, ProjectReference projectReference, IProcess process, TSnapshot snapshot, IOctopusPrincipalInternal octopusPrincipal, Channel releaseChannel, IReadOnlyCollection`1 projectChannels, CancellationToken cancellationToken)
                    |     at Octopus.Server.Communications.Packages.ReleaseCreation.ReleaseCreationFactory.FillAndCreateRelease(IOctopusQueryExecutor queryExecutor, ProjectReference projectReference, Release release, CancellationToken cancellationToken, IOctopusPrincipalInternal octopusPrincipal) in ./source/Octopus.Server/Communications/Packages/ReleaseCreation/ReleaseCreationFactory.cs:line 67
                    |     at Octopus.Server.Orchestration.ServerTasks.ProcessRecurringScheduledDeployments.ScheduledProjectTriggerProcessor.CreateRelease(ProjectReference projectReference, DeploymentSettings settings, Channel channel, ProjectTrigger trigger, CancellationToken cancellationToken) in ./source/Octopus.Server/Orchestration/ServerTasks/ProcessRecurringScheduledDeployments/ScheduledProjectTriggerProcessor.cs:line 469
                    |     at Octopus.Server.Orchestration.ServerTasks.ProcessRecurringScheduledDeployments.ScheduledProjectTriggerProcessor.DeployNewRelease(ProjectTrigger trigger, ITaskLog taskLog, CancellationToken cancellationToken) in ./source/Octopus.Server/Orchestration/ServerTasks/ProcessRecurringScheduledDeployments/ScheduledProjectTriggerProcessor.cs:line 348
                    |     at Octopus.Server.Orchestration.ServerTasks.ProcessRecurringScheduledDeployments.ScheduledProjectTriggerProcessor.SafelyDeployNewRelease(ProjectTrigger trigger, ITaskLog taskLog, CancellationToken cancellationToken) in ./source/Octopus.Server/Orchestration/ServerTasks/ProcessRecurringScheduledDeployments/ScheduledProjectTriggerProcessor.cs:line 308
                    |     Octopus.Server version 2024.2.4636 (2024.2.4636)
17:35:20   Verbose  |     Update the last scheduled time for Deploy to dev to 4/12/2024 5:35:19 PM

More Information

Internal link to repro

First reported here [internal]

Similar to https://github.com/OctopusDeploy/Issues/issues/8736

Workaround

Use the same step in the Project Release Version configuration as the one used in the channel version rule, and make sure the step can run for that channel. For example:

tothegills commented 6 months ago

The issue arises when Octopus can not determine the version of an automatically created release. We consider this a configuration issue and will not issue a patch. When a project is configured to "Use the version number from an included package", the step must apply to all channels.