Adventures with the Go programming language

After 10+ years of working with Java, I spent the last year working with Ruby & Rails. Let’s just say I’m not a fan. I wanted to learn something new and I’ve heard a lot of good things about Go. Quite a few projects use Go: Docker, Hugo, Kubernetes, Prometheus, and many more.

Three weeks ago, I picked up a copy of “The Go Programming Language” by Donovan & Kernighan. Yes, the same Kernighan that co-wrote the famous, “The C Programming Language”.

In order to learn it, I needed a real life scenario, I needed a project. Why not port, sm_photo_tool, my Smugmug command line tool from python to Go lang? That will give me experience with how Go handles parsing arguments, classes, REST APIs, concurrent uploads, and a bunch more things.  It’s the perfect project to learn Go.

In the next post I’ll talk about structs in Go.

Candlepin 0.5.5 released

Candlepin

It’s that time again, another release of Candlepin and associated projects available for your enjoyment. With this release we have subscription-manager in Fedora as well as a debut build of Thumbslug.

For more information on Candlepin, please visit: http://candlepinproject.org/

Features & Enhancements

subscription-manager

  • added support for host registration and guest association when host can not register itself
  • virt-who work to handle ESX guests
  • subscription-manager available in fedora

candlepin

  • build modified to use the tito hotness instead of bunch of disjoint bash scripts
  • disable manifest rules import
  • added support for host registration and guest association when host can not register itself

thumbslug

  • added appropriate init scripts to run as a service
  • uses Candlepin CRL
  • thumbslug talks to akamai
  • created puppet module for katello

Bugs fixed

subscription-manager

705883 Fix error dialog modal issues.
719743 Improved text output for successful pool subscription
740788 Getting error with quantity subscribe using subscription-assistance page.
746259 Don’t allow the user to pass in an empty string as an activation key
746732 Only use fallback locales for dates we need to parse
749332 Normalize the error messages for not being registered
749636 Client should not support users entering activation keys and existing consumer ids
752572 add interval logging statements back in on rhsmcertd startup
753093 The available subscriptions count does not show correctly in Subscription Manager GUI
754821 Default org of “Unknown” was not marked for gettext
755031 Unregister before attempting to run a second registration
755035 Migration script should work on RHEL 5.7 and up.
755130 add extra whitespace to classic warning
755541 Enhanced the message in the katello plugin to debug when the backend system does not support environments.
756173 Unexpected behavior change in subscription-manager unregister
756507 do not use output from “getlocale” as input for “setlocale”
758471 install-num-migrate-to-rhsm threw traceback when no instnum was found.
759199 rhsmcertd is logging the wrong value for certFrequency

candlepin

753093 The Available Subscriptions count do not show correctly in Subscription Manager GUI
754841 Implement DELETE /pools/id.
754843 Fix legacy virt bonus pools missing pool_derived.
755677 Activation Keys should not check quantity on unlimited pools
756628 Translate missing rule errors.
758462 ensure job detail isn’t null, skip it.

thumbslug

759607 update url for subscriptions handler

Download & Setup

Make sure you read over the Candlepin Setup Guide, which is located at https://fedorahosted.org/candlepin/wiki/Setup.

As well as the Headpin Install Guide which can be found at https://fedorahosted.org/candlepin/wiki/headpin/Install

Just give me the bits already! You can get the various bits at the urls below.

Candlepin:
http://repos.fedorapeople.org/repos/candlepin/candlepin/

Thumbslug:
http://repos.fedorapeople.org/repos/candlepin/thumbslug/

Headpin:
http://repos.fedorapeople.org/repos/katello

Subscription Manager:
http://repos.fedorapeople.org/repos/candlepin/subscription-manager/

python’s default argument values

I’ve been trying to track down a bug for a couple days now with zmugfs. I’m caching the tree structure returned by smugmug.users.getTree. Here’s my Node class:

class Node(object):
    def __init__(self, path, inode=MyStat(), children=[]):
        self.path = path
        self.inode = inode
        self.children = children

To a newbie like me, this looks perfectly fine. If no inode is passed in create an instance of MyStat(), if no children are passed in create an empty list. Well guess what! That’s not how python works with lists. If you do what I did above the children list is shared! Imagine my horror when each Node has a reference to ALL of the children of the other Nodes. EEK! A few minutes of googling and I found this page:
4.7.1 Default Argument Values.

I changed the constructor of the Node class to be as follows:

def __init__(self, path, inode=MyStat(), children=None):
    self.path = path
    self.inode = inode
    if children is None:
        self.children = []
    else:
        self.children = children

This fixed my problem.