Enabling "Config as code" has completely messed my project

Hey @harsh_tech,

I have some good news for you this morning, upgrading will not fix the broken project but I put your ticket in front of our engineers because we have not seen this before and I felt it was something our engineers needed to be aware of. Ideally we should have some kind of catch statement in our code to check OCL files have been created before fully converting the project. Since we have never seen it before where it has not created the files this was not put in place. Our engineers are now looking into this to see if we can improve this in the future in case it happens to others.

They have investigated ways to get this project working again for you and they have hopefully found a solution. We do actually store the OCL files in the DB as a backup!

You will need to run the below query against your Octopus Database:

SELECT OclFileName, JSON_VALUE(CONVERT(NVARCHAR(MAX), DECOMPRESS(JSONBlob)), '$.Data') as OCL
FROM GitEntityStash
WHERE ProjectId = 'Projects-xyz'

You will need to replace ‘Projects-xyz’ with the Project ID of the broken project
(from your HAR file it looks like that is Projects-5902 but double check that).

The SQL result will contain the backed up contents for the deployment_process.ocl and deployment_settings.ocl files.

You should be able to take both file contents, create each file where your local Git directory is and commit those to the Git repo that’s associated with the project.

A file named schema_version.ocl will need to be manually created with the contents as follows:

version = 2

This file should then be committed to the Git repo as well.

From here, you should try and access the project via the Octopus portal again.

Hopefully that gets you back up and running! Let us know!

Kind Regards,

Clare

Thanks @clare.martin I will give it a try. I don’t have DB access, so I have to wait for someone from DB team to provide me data.
Glad to know that there is hope to recover the project …

1 Like

Hi @clare.martin this is what DB returned, do you think its still recoverable with this result?

OclFileName OCL
deployment_process.ocl NULL
deployment_settings.ocl connectivity_policy { allow_deployments_to_no_targets = true } versioning_strategy { template = #{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch} }

Actually I went ahead and tried it and error is gone but along with that all the steps and previous stuff is gone :frowning_face:

Hey @harsh_tech,

Thanks for getting back to us and trying out that query.

Unfortunately it appears that the project deployment process data has been lost somehow.

It’s strange that the deployment process ocl data is missing from the octopus server.

Would you be able to check the git repos past versions to see if the deployment process ever made it across at all?

Do you perhaps have a database backup you can restore on a test instance from before this project was converted?
If you do we can extract the deployment process and put it over a new project on your live instance.

Please let me know what you think of the above.

Kind Regards,
Adam

Hey @harsh_tech,

Sorry to hear the DB restore from that table has not completely restored your project, we have gotten rid of the error though so that will at least help with the next stage of this restore process. I read Adam’s comment and I recall you saying you cannot use a DB backup and I know the GIT repo did not have any OCL files in previously so you cannot look at previous edits.

Our engineers think you might be able to restore this from the audit log but we would need to know if that project shows up in there first.

Selecting Audit Trail from the overflow menu on the deployment process page should show a page with all of the history on the process.

If this does not work you can always go into the audit log and do an advanced filter search by searching for Document Type > Deployment Process and then Projects > Windows FSX - Create SMB Share and Set ACL’s

The engineers said we don’t have any functionality to restore a particular version or anything like that, so we may have to work with you to manually put it back.

For now, we want to establish that the process is showing up in the audit log, then we can work on how to restore it.

Let me know if you do have a deployment process audit log of that project and we can go from there.

Kind Regards,

Clare

Thanks @clare.martin … I could recover the PowerShell code from the Audit History. Thanks a lot for following it up and providing the solution. I thought its all gone, so I started rebuilding everything from scratch in last few days. But now I will just grab the script code from Audit History and will fix my newly built steps from it.

Hey @harsh_tech,

Oh fantastic news you could grab it from that, let us know if you run into any issues re-creating it from the PowerShell and we will do our best to help!

I am so sorry this has caused you so much time and effort to sort this, and I hope this has not put you off converting future projects into Config-as-Code…our CaC feature is really useful if you like working with code more than in a UI and want to take advantage of version control for your variables and deployment processes.

I would definitely recommend cloning an existing project (or creating a new template one) and converting that into CaC so you can have a play and see how useful that feature is, we are constantly developing it too so there is more to come in future releases.

I am hoping this is a one-off and it is just that specific project at that point in time when you converted it that caused this issue.

Let me know if you do want to clone a project and it does the same thing, our CaC team are still looking into how we can make sure the OCL files are created before converting the project in case this happens to anyone else.

Thank you for your patience whilst we worked through this with you and let us know if you need help with the PowerShell and getting the process from the audit log into the deployment process itself.

Kind Regards,

Clare

1 Like

Thats a good explanation @clare.martin . Appreciate your time and support on this. I might hold off on CaC till we get latest Octopus Server version as the current version has got issues as pointed in some of the replies above.

1 Like

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