Unable to upgrade past v3.3.27

If i try to upgrade the Octopus server, i get the attached error. We are currently using version 3.3.27 and I have tried upgrading to the latest version and also v3.4.16 to see if an incremental upgrade would help.

I get as far as installing successfully but when i try to start up the OctopusDeploy Service, it starts but stops soon after and the attached is shown in the event logs.

It seems to have a Primary Key conflict that is preventing it from updating the database.

Is there a way around this issue?

OctopusError.txt (12.1 KB)

Hi,

Could you run the below SQL query, it would seem that there’s already a Machine Policy in the database that uses the same ID as the default policy we insert in that script that is failing.

SELECT *
FROM [dbo].[MachinePolicy]

Thank you and best regards,
Henrik

Hello,

There was 1 row and it contained the following:

Id: MachinePolicies-1
Name: Default Machine Policy
IsDefault: 1
JSON: {“Description”:“This policy is automatically applied to machines that are created when no policy is specified. Any other machine policies will inherit this policy’s custom health check scripts unless they specify their own.”,“MachineHealthCheckPolicy”:{“TentacleEndpointHealthCheckPolicy”:{“RunType”:“Inline”,“ScriptBody”:"$freeDiskSpaceThreshold = 5GB\r\n\r\nTry {\r\n\tGet-WmiObject win32_LogicalDisk -ErrorAction Stop | ? { ($.DriveType -eq 3) -and ($.FreeSpace -ne $null)} | % { CheckDriveCapacity @{Name =$.DeviceId; FreeSpace=$.FreeSpace} }\r\n} Catch [System.Runtime.InteropServices.COMException] {\r\n\tGet-WmiObject win32_Volume | ? { ($.DriveType -eq 3) -and ($.FreeSpace -ne $null) -and ($.DriveLetter -ne $null)} | % { CheckDriveCapacity @{Name =$.DriveLetter; FreeSpace=$.FreeSpace} }\r\n\tGet-WmiObject Win32_MappedLogicalDisk | ? { ($.FreeSpace -ne $null) -and ($.DeviceId -ne $null)} | % { CheckDriveCapacity @{Name =$.DeviceId; FreeSpace=$_.FreeSpace} }\t\r\n}"},“SshEndpointHealthCheckPolicy”:{“RunType”:“Inline”,“ScriptBody”:""},“HealthCheckInterval”:“01:00:00”},“MachineConnectivityPolicy”:{“MachineConnectivityBehavior”:“ExpectedToBeOnline”},“MachineCleanupPolicy”:{“DeleteMachinesBehavior”:“DoNotDelete”,“DeleteMachinesElapsedTimeSpan”:“00:00:00”},“MachineUpdatePolicy”:{“CalamariUpdateBehavior”:“UpdateOnDeployment”,“TentacleUpdateBehavior”:“NeverUpdate”,“TentacleUpdateAccountId”:null}}

Also, due to our teams structure, i had to request our database team to create the database before installing v3.3.27 but they followed the guidelines mentioned on https://octopus.com/docs/installation/sql-server-database and we are using AD authentication.

Hi,

So that is the default machine policy that the script that is failing creates, so that’s a bit strange that it already exists.

Could you have that record deleted from the database and then try running the upgrade again?

Thank you and best regards,
Henrik

Hi Guys. We are getting the exact same problem attempting to upgrade from 3.1.1 to the latest version 2018.4.0

Ijo, how did you go with Henriks suggestion?

We tried renaming the primary key from MachinePolicies-1 to MachinePolicies-2 and the problem shifted to another table.
We had to revert the change.
Interesting note that in the windows logs there was a message along the lines of Database rolled back to last known stable configuration (something like that).
In order to fully recover back to the old version though, we had to restore the database back to a pre-deployment backup

Hi Bill,

Thanks for getting in touch, we’ve had a few other customers that have encountered this issue and they got around it by upgrading to 3.17.14 first and then up to latest version.

Could you try this approach and see if this gets you past this hurdle?

Thank you and best regards,
Henrik

Hi Henrik. Thanks for getting back to me. Sounds good, I’ll give it a try
Cheers
Bill

Hi Henrik,

Thank you so much.

Deleting the row from the table and then installing 3.17.14 before going to the latest version has fixed the issue and it is all successfully installed.

Thanks!
Laura

Hi Ijo and Henrik,
We are going to attempt the upgrade again with your recommendations. However, it seems we also need to delete a row from a table. From the thread I’m guess its [dbo].[MachinePolicy].

  1. Is this step a requirement?
  2. Is there any other tables requiring pre-work
  3. What was the actual statement to remove the record ?
    ie delete from [dbo].[MachinePolicy] where id = ‘MachinePolices-1’
  4. When was this step done?
    ie: Shutdown Octopus? Or Place Octopus in maintenance mode or Leave it running?

Thanks for your help guys, any advice will be hugely appreciated.
Kind Regards
Bill

By the way Ijo and Henrik
The deployment worked. So thanks very much.
The only other issue we had was the TeamCity Octopus Package Needed to be upgraded with each upgrade

So thanks Very much Guys

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.