Friday, September 4, 2015

debugging production problems with git and go

What follows is an accounting of a debug session I just completed. In the end the issue was not in my code but in a 3rd party library that was in turn effected because a service that it depended on was not running... but this is how I go there. (the stack tract stupid)

Logging into my server I realized that CoreOS had updated my Alpha channel server. It's a pain in my ass when that happens... and there are a number of side effects that I have not yet accounted for.

The login:
Welcome to Secure Shell version 0.8.34.
Answers to Frequently Asked Questions: http://goo.gl/TK7876
Connecting to richard_bucker_net@dev.oneoffcode.com...
Loading NaCl plugin... done.
richard_bucker_net@dev.oneoffcode.com's password: 
Last login: Fri Sep  4 03:40:27 2015 from 24.51.218.13
CoreOS alpha (794.0.0)
Failed Units: 6
  bosuncpu.service
  bosundisk.service
  bosunmemory.service
  bosunnetwork.service
  ChargebacksYesterday.service
  sshd@13382-10.240.126.213:22-43.229.53.60:13251.service

Crap, my chargeback service did not run. That's going to create a backlog of work for me.  But what happened?
$ sudo journalctl -u ChargebacksYesterday.service -e

Looking at the last page of the log I see that there was a stack trace. This is not going to be good because the trace is going to give me line numbers that do not match the current state of the code.  I'll need to branch the deployed version (after the fact) and then review the code. I hope no changes are required that demand merging.

The the commit-id from the binary
$ ChargebacksYesterday --version

appname ChargebacksYesterday
commit id: 5600cc2
build date dev-20150901141054

ALL of my programs return the above string when the '--version' CLI option is provided.  This way I get to the state of the code in order to debug problems. Looking at the log info, including the stack trace, you'll most likely not be able to debug a project that is being heavily developed.

go to my source
login
cd zquery

create a branch from the commit-id and push to the remote server
$ git branch
$ git branch debug_nil_pointer 5600cc2
$ git push -u origin debug_nil_pointer
$ git branch

** notice I created the branch from the commit-id and did not actually switch local branch.  I hate branch switching locally as I've janked my projects more than once.  In the next step I switch the branch view in the web GUI.

go to github/bitbucket and switch branches
- this is a visual thing you'll have to do it yourself

find my file and view the code
- I found the exact line of code and it turned out that I was correct. The bosun server running on my local server must have terminated or failed to restart after the CoreOS update.

No comments:

Post a Comment

another bad day for open source

One of the hallmarks of a good open source project is just how complicated it is to install, configure and maintain. Happily gitlab and the ...