Today at work we ran into an issue where HipChat refused to restart, so after a bit of digging a colleague in IT found this ticket. In it, Atlassian tells us to run a few commands, and one of them is a wget… Oh yeah, let's take a peek!
So I download the tarball and check what's inside…
$ wget https://s3.amazonaws.com/hipchat-server-stable/utils/hcpub-1045.tar.gz
--2016-07-14 02:15:37-- https://s3.amazonaws.com/hipchat-server-stable/utils/hcpub-1045.tar.gz
Resolving s3.amazonaws.com (s3.amazonaws.com)... 54.231.83.26
Connecting to s3.amazonaws.com (s3.amazonaws.com)|54.231.83.26|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3120 (3.0K) [application/x-tar]
Saving to: ‘hcpub-1045.tar.gz’
2016-07-14 02:15:37 (161 MB/s) - ‘hcpub-1045.tar.gz’ saved [3120/3120]
$ tar -tf hcpub-1045.tar.gz
hcpub-1045/
hcpub-1045/nginx.package.init.erb.HCPUB-1045
hcpub-1045/package.rb.HCPUB-1045
hcpub-1045/hcpub-1045-nginx-fix.shAlright, 3 files. Let's look at the shell script hcpub-1045-nginx-fix.sh as it looks like our entry point…
$ tar -xzf hcpub-1045.tar.gz --to-command=cat hcpub-1045/hcpub-1045-nginx-fix.sh
#!/bin/bash
echo "HCPUB-1045 starting with a backup"
cp -a /hipchat-scm/chef-repo/cookbooks/nginx/templates/default/nginx.package.init.erb ./nginx.package.init.erb.HCPUB-1045.BAK
cp -a /hipchat-scm/chef-repo/cookbooks/nginx/recipes/package.rb ./package.rb.HCPUB-1045.BAK
cp -a ./nginx.package.init.erb.HCPUB-1045 /hipchat-scm/chef-repo/cookbooks/nginx/templates/default/nginx.package.init.erb
cp -a ./package.rb.HCPUB-1045 /hipchat-scm/chef-repo/cookbooks/nginx/recipes/package.rb
/opt/atlassian/hipchat/sbin/cs
/opt/atlassian/hipchat/sbin/hup
echo "HCPUB-1045 fix done"Well, that's boring! Let's see what kind of script this little package.rb.HCPUB-104 is… Ruby or what?
$ tar -xzf hcpub-1045.tar.gz --to-command=head hcpub-1045/package.rb.HCPUB-1045
# HC-31142 because chef sucks (our old version symlink following and file exist checking)
# http://smarden.org/runit/faq.html#remove
# https://docs.chef.io/resource_common.html#run-in-compile-phase
bash 'stop-nginx-runit' do
code <<-eoh usr bin sv stop nginx || true rm -rf etc -f service test -l init.d && nginx.dpkg-new < code>Whoa! Wait… huh? Did I read that right?
$ zgrep sucks hcpub-1045.tar.gz
Binary file (standard input) matches
$ echo "haha tu me niaise!!!"
haha tu me niaise!!!
$ tar -xzf hcpub-1045.tar.gz --to-command=head hcpub-1045/package.rb.HCPUB-1045 | grep sucks
# HC-31142 because chef sucks (our old version symlink following and file exist checking)Well now, I love that! Looks like Chef sucks a bit according to Atlassian, if I'm reading their publicly distributed comments right. At least it has the merit of being clear.
I obviously found this pretty funny, and at the same time I can picture being a developer stuck maintaining a product the company bought for millions of dollars, built on a tech stack the internal team barely uses… Yeah, I'd rage the exact same way. Especially when you can clearly tell the quality isn't quite on par with Jira or Bamboo, for instance.
Anyway, thanks Atlassian! That made my day and took the edge off my own troubleshooting for a while! And yes, the patch worked like a charm.
