OctopusDeploy / Issues

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

Updating a Step Template version fails silently with schema version upgrade #7814

Closed StephenHeise closed 1 year ago

StephenHeise commented 2 years ago

Private issue: https://github.com/OctopusDeploy/ResearchAndDevelopment/issues/570

Team

Severity

Some customers impacted, workaround exists

Version

All

Latest Version

No response

What happened?

If a user has a CaC project with a schema version migration pending and they try to update the version of a process step based on a library step template, the update silently fails.

Reproduction

  1. Create a simple library step template.
  2. Make a few modifications to it so that there are several versions of it available.
  3. Add a step to a CaC project, based on the library step template and commit.
  4. Manually set the step version in the deployment_process.ocl file back one version, e.g. Octopus.Action.Template.Version = "6" -> Octopus.Action.Template.Version = "5".
  5. Manually change the schema version in the schema_version.ocl back one version, e.g. version = 5 -> version = 4.
  6. Commit & push.
  7. Refresh Octopus Server and go into the (now out-of-date) step.
  8. Click the Update and commit button.
  9. Nothing happens...

Error and Stacktrace

Request URL: http://localhost:5000/api/Spaces-1/actiontemplates/ActionTemplates-41/actionsUpdate
Request method: POST
Status code: 500 Internal Server Error
Response: {
  "ErrorMessage": "Stack empty."
}
System.InvalidOperationException: Stack empty.
   at System.Collections.Generic.Stack`1.ThrowForEmptyStack()
   at Octopus.Core.Features.Projects.ProjectScope.GetProjectPath() in ./source/Octopus.Core/Features/Projects/ProjectScope.cs:line 36
   at Octopus.Core.Git.Schema.GitSchemaVersionProvider.LoadProject(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Schema/GitSchemaVersionProvider.cs:line 132
   at Octopus.Core.Git.Schema.GitSchemaVersionProvider.GetProjectLatestSchemaVersion(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Schema/GitSchemaVersionProvider.cs:line 126
   at Octopus.Core.Git.Schema.GitSchemaVersionProvider.LoadSchemaVersions(String verifiedFileNameOrNull, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Schema/GitSchemaVersionProvider.cs:line 102
   at Octopus.Core.Git.Schema.GitSchemaVersionProvider.LoadSchemaVersions(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Schema/GitSchemaVersionProvider.cs:line 65
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.<>c__DisplayClass20_0.<<Commit>b__0>d.MoveNext() in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 116
--- End of stack trace from previous location ---
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.MigrateBeforeExecute[T](Func`1 innerOperation, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 211
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.Commit(String message, CommitAuthor author, CommitAuthor committer, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 144
   at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWork.CommitToGit(CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWork.cs:line 177
   at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWork.Complete(CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWork.cs:line 122
   at Octopus.NancyOwin.NancyMiddleware.RequestComplete(NancyContext context, IDictionary`2 environment, CancellationToken cancellationToken) in ./source/Octopus.Server/Owin/NancyMiddleware.cs:line 174
   at Octopus.NancyOwin.NancyMiddleware.RequestComplete(NancyContext context, IDictionary`2 environment, CancellationToken cancellationToken) in ./source/Octopus.Server/Owin/NancyMiddleware.cs:line 174
   at Octopus.NancyOwin.NancyMiddleware.<>c__DisplayClass3_0.<<UseNancy>b__1>d.MoveNext() in ./source/Octopus.Server/Owin/NancyMiddleware.cs:line 110
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Owin.WebSocketAcceptAdapter.<>c__DisplayClass6_0.<<AdaptWebSockets>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 47
   at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 47
   at Octopus.Server.Web.Middleware.OctopusClientOldVersionWarningMiddleware.InvokeAsync(HttpContext context, IAutomationContext automationContext) in ./source/Octopus.Server/Web/Middleware/OctopusClientOldVersionWarningMiddleware.cs:line 53
   at Octopus.Server.Web.Middleware.DynamicContentHeadersMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/DynamicContentHeadersMiddleware.cs:line 49
   at Octopus.Server.Web.Middleware.PrivateSpaceToggleMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/PrivateSpaceToggleMiddleware.cs:line 56
   at Octopus.Server.Web.Middleware.MaintenanceModeMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/MaintenanceModeMiddleware.cs:line 61
   at Octopus.Server.Web.Middleware.OctopusAuthenticationMiddleware.InvokeAsync(HttpContext context, IUserAuthenticator userAuthenticator, IAuthCookieService authCookieService, IWebAuthCache authCache, ILogger logger) in ./source/Octopus.Server/Web/Middleware/OctopusAuthenticationMiddleware.cs:line 57
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Octopus.Server.Web.Middleware.LegacyRequestLoggerMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/LegacyRequestLoggerMiddleware.cs:line 42
   at Octopus.Server.Web.Middleware.TelemetryMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/TelemetryMiddleware.cs:line 76
   at Octopus.Server.Web.Middleware.ErrorHandlingMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/ErrorHandlingMiddleware.cs:line 98

More Information

No response

Workaround

  1. Go into the Deployment Process.
  2. Make a trivial change, for example, change the name of a step or add a note to it. Anything unrelated to step templates.
  3. Commit the change. This should trigger the migration of the schema. There should be a commit with a message 'Octopus Schema Migration to vX' that changes the .octopus/schema_version.ocl file to version = X, where X is the latest schema version. It may have other changes as well.
  4. Now the Update and Commit button should work on the step.
  5. The trivial change change can now be undone and committed, if required.
AvdeevArtem commented 1 year ago

We have same issues

octoreleasebot commented 1 year ago

Release Note: Fix step template updating on Git projects when there are pending Git migrations

Octobob commented 1 year ago

:tada: The fix for this issue has been released in:

Release stream Release
2023.1 2023.1.8336
2023.2+ all releases