Closed m5lapp closed 3 weeks ago
Yuck, this is unfortunate. Never seen that before (probably the beauties of NFS?) It is possible to have the GoCD config repo bootstrapped from and pushed to a remote, but I've personally been unsure of the merits of that. In any case, that won't help you now.
I believe it should be possible to start fresh with git init
like you suggest, but you will also need to add+commit the existing cruise-config.xml
before GoCD will handle it correctly at startup. Branch will need to be master
. If you want to reverse engineer from how the code behaves at start-up/initialization you can check here.
You'll definitely lose the ability to see the "Config Changed" history between pipeline runs, but I think that it will otherwise work OK.
I'd suggest you experiment with your process on a local GoCD first, either via a container with a mounted /godata
or just via https://www.gocd.org/test-drive-gocd.html - doesn't have to be with your "real" config repo, perhaps just one with a few manual commits driven by the GoCD UI or a few pipeline runs with config changes between them.
As to your performance/CPU issues, it would sound odd to me if it's causing that, but it's probably wise to fix this first before digging too deeply into that.
Thanks for getting back to me, I've been having a bit of play around with our test GoCD instance and deleting and re-initialising the Git repo does seem to work as expected, I've got a bit more testing to do but it's looking promising so far.
Before I do the work in production, you mentioned that the GoCD config can be automatically pushed to a remote. Given what's happened, it sounds like a good idea for us to look into doing that. However, I was unable to find any information about how to do that anywhere, do you know of any resources that exist?
There's no magic built in to push to a remote, but it's just a regular git repository so you could cron/supervisord something that does this periodically using command line git.
Alternatively, and probably better, just rely upon the built-in scheduled backup feature which includes zips of the configuration db/repo: https://docs.gocd.org/current/advanced_usage/one_click_backup.html ...
Or rely on lower level filesystem snapshot backups of your NFS volume.
On Sat, 20 Apr 2024 at 1:10 AM, Chad Wilson @.***> wrote:
There's no magic built in to push to a remote, but it's just a regular git repository so you could cron/supervisord something that does this periodically using command line git.
Alternatively, and probably better, just rely upon the built-in scheduled backup feature which includes zips of the configuration db/repo: https://docs.gocd.org/current/advanced_usage/one_click_backup.html ...
Or rely on lower level filesystem snapshot backups of your NFS volume.
I have used both cron as well as inotify in the past.
Here's a ChatGPT answer : https://chat.openai.com/share/7eda067a-3708-4a94-a6c7-0ffde86eeafa
—
Reply to this email directly, view it on GitHub https://github.com/gocd/gocd/issues/12701#issuecomment-2066972128, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF5JGWMCHMU6KI4EDEEJNLY6FFZ5AVCNFSM6AAAAABGJWHZJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWHE3TEMJSHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
My apologies. I realised that I might delete that code snippet by accident. Here's the actual code :
#!/bin/bash
# Define your local Git repository path
repo_path="/path/to/your/git/repository"
# Define your remote repository URL
remote_url="git@github.com:user/repository.git"
# Function to push changes
push_changes() {
cd "$repo_path" || exit
git push origin master # or your preferred branch
}
# Watch for changes using inotifywait
inotifywait -r -m -e modify,create,delete,move "$repo_path" |
while read -r directory events filename; do
# Only act when changes occur in the Git repository
if [[ "$directory/$filename" =~ ^$repo_path ]]; then
echo "Changes detected in $directory/$filename. Pushing changes..."
push_changes
fi
done
Thanks both, I've now fixed the Git repo in our production GoCD instance. I struggled to figure out the commit message format it needed with the correct checksums and things, it was always coming up with an error, but I found that just doing the git add
without the git commit
was sufficient and GoCD would detect this and do the commit for me.
We elected not to use a remote for the time being, if we see this issue again that we'll look to potentially do that. For now, we're chalking it up to a blip.
If you don't have it configured already, it's still a very good idea to be using at least the built in GoCD backup function. That's relatively trivial to set up since GoCD manages the cron and would have allowed you to roll back somewhere with this without losing everything.
Thanks Chad, we do have backups configured and keep them for 14 days, but this issue with the corruption has been around since at least early February (as far back as our logs go, likely much longer), so would be no use in this case unfortunately.
Fair enough. Could consider keeping them for longer I suppose. Shouldn't be too large in size once compressed?
Issue Type
Summary
We have been running GoCD in production for several years and noticed recently that the Weekly garbage collection of the config repository is failing due to a corrupted pack file. This is only affecting our production instance and we are not sure when it happened/appeared; the longest our logs go back is early February and it was happening then, so at least a few months.
GoCD itself is generally running OK, though around every four days we have seeing high CPU-usage/throttling and slow-down over a period of several hours until GoCD eventually restarts. This may or may not be related to the issue with the corrupted pack file, possibly it is if the GC has not run for a long time? A restart always restores it to normal performance in these cases.
Environment
We run GoCD in containers in a Kubernetes cluster using a custom image that builds on top of gocd/gocd-server:v23.2.0. The file system where the config repository is saved is backed by NFS. Garbage collections are configured to run using go.config.repo.gc.periodic=Y, but we do not specify any of the other go.config.repo.gc.* values, so we take the default values for those.
Basic environment details
23.2.0 (16938-e2b2936f3b573008381a3702139ebcb4383dc0b1)
17.0.8+7
Linux
Additional Environment Details
Steps to Reproduce
Expected Results
We expect the garbage collection for the config repository to run successfully according to the default cron schedule.
Actual Results
The config repository garbage collection fails and the three log messages listed further down are output.
Possible Fix
We took a copy of the Git repo and did some Googling to try and find solutions to this that others may have had as follows:
We were wondering if it would be possible to do something along the lines of deleting the .git/ directory of the config repository and then initialising a new one with
git init
, does that sounds reasonable?Log snippets
Code snippets/Screenshots
N/A
Any other info
N/A