Enabling "Config as code" has completely messed my project

This did not help. Getting new errors now.

Hi @harsh_tech,

Thanks for getting in touch, though I’m sorry to see that didn’t help. Could you provide details about the new errors you’re seeing after clearing the cache? I’m hoping that’ll help narrow the search down a bit.

Best regards,

Kenny

I get " * The file ‘schema_version.ocl’ does not exist in the Git repository.

Hey @harsh_tech,

Just reading this to get a response out to you as Kenny is off shift as part of our AUS based team.

I noticed I just replied to another ticket of yours here. Is this the same issue with the same project? If so am I able to close one of the tickets as it can get confusing if we are trying to fault find the same issue on two tickets.

In my response on that other ticket I asked you to clear the Git Cache which, when reading this one, it looks like you already did this, is this the case and you are still getting the schema_version.ocl file does not exist in the Git Repository?

Do you have any files in there at all? If you have the .octopus folder in there it may be worth going into that and trying to manually create a blank schema_version.ocl file and see if that fixes the issue.

If there are no files in there at all can you check the permissions in the repo and make sure the account you are using in Octopus to connect to that Git Repo has the correct permissions. We have the permission list you need here.

Let me know if any of those suggestions help and if this is the same job as the other ticket I will close the other one and we can focus on this ticket to see if we can get that project up again.

I looks forward to hearing from you,

Kind Regards,

Clare

Thanks @clare.martin for your response, yes its same issue. There are no files in Git at all, not even a .octopus folder. I just assigned the Admin permissions to the user now, though user was already Org Owner. however still getting similar errors. Its the same job as other ticket, however my question on other ticket was mainly about how to turn off the CaC.

Hey @harsh_tech,

Thank you for confirming that, ill set the other ticket to solved and we will work on this one if that is ok. CaC is a one-way feature as Daniel mentioned unfortunately.

Lets try and get this working for you, I took a look in our support files and noticed you posted two files yesterday showing your config as code setup. Initially I thought maybe having dots in your repo name would cause an issue but I just created a new repo called Clare.Test.CaC and its converted one of my projects fine and put all the files in there so the issue you are experiencing is confusing.

Have you just got one project you have converted to CaC or is this the first one you have converted? If you have others have they converted fine?

On the other ticket you mentioned you are going to try manually clearing out the Git folder. If that does not work can we get the HAR file and Octopus Server logs I mentioned in that ticket and we can take a look for you to see if we can see why this is happening.

You can send them to our secure link here.

I hope we can get this solved for you, hopefully the logs and HAR file will give us some more information.

Kind Regards,

Clare

This is first time trying CaC on a project

Hey @harsh_tech,

Thanks for letting me know, let me know how you get along with clearing the Git folder and if that still doesn’t work let me know once the HAR file and logs have been uploaded and we can take a look.

Kind Regards,

Clare

Hey @harsh_tech,

Just a quick update for you on this, I was just going through our current GitHub issues to see if we had any new ones out I should be aware of and I came across this:

Cannot update project settings when default branch has no OCL

The error shown in that GitHub issue is what you are seeing so I am wondering if you could try and implement the workaround to see if that gets you up and running, the workaround is to merge the changes from the initial commit branch into the default branch.

I am wondering if you have a few different branches in your repo and accidentally committed your initial conversion of the project to a non-default branch?

If you have no OCL files in any of your branches for this project then ignore what I have mentioned and let me know once you have tested the manual Git clear and if you want to send us over some logs.

Kind Regards,

Clare

Thanks @clare.martin for following up on this. Unfortunately the manual clean up did not work and also there is no other branch with the code. I keep getting same error -

The file ‘schema_version.ocl’ does not exist in the Git repository.

I just uploaded the HAR file and will soon upload server log file.

Hey @harsh_tech,

Thank you for confirming there are no OCL files present in any of your repo branches and you cleared the Git folder manually and it still has not fixed the issue.

I will take a look at both files once you have uploaded them both, hopefully they show us a bit more.

Kind Regards,

Clare

Thanks @clare.martin its all uploaded now. Hopefully I can atleast recover my project :cry:

1 Like

Hey @harsh_tech,

Thank you for those logs, I have had a look at both, the server logs are showing that you can connect to the GIT repo fine (with a 200 response code). But then when it comes to accessing the project itself its throwing up the schema error you mentioned in this ticket.

Looking at the HAR trace for that project I can see it errors out with a 400 response which means there is a bad request (because it cannot find a deployment process OCL file in the repository it is looking in).

I have discussed this with the other members of our support team as none of us have seen this happen before so its a strange one. Because you have no OCL files in the repository at all, unfortunately we think that project is not recoverable.

Do you take regular backups of your DB and would you be able to restore one to a test VM at all? If so you can recover your project from the DB backup. You could actually use that and convert it to CaC using the same repo. That should then create the files required and your current project on your live instance would then start working!

I cannot say what went wrong here, the only thing I can think is you setup CaC on the project and it bombed out before it had the chance to create the OCL files, so the project was converted but no files were created. We have never seen this happen before so it is a bit strange!

If the DB backup project also errors out and doesn’t create the files it might be worth looking at that repo and possibly deleting it and creating a new one from scratch with just the default (main) branch. I would delete your ‘master’ branch in your current repo anyway so you only have one branch (main) for the initial setup.

Let me know how you get on, if you don’t have any DB backups that are usable I am sorry to say that project is gone. We do recommend cloning a project to test this on before hand if this is the first time you are playing with CaC to make sure the process runs smoothly but this looks like an anomaly as it seems you have everything setup correctly.

Keep us informed of how you get on,

Kind Regards,

Clare

Thanks for @clare.martin , I don’t think the restore is an option for me. If I upgrade the Octopus to latest version, would it recover the 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