juju.replicaset could use kr/pretty in its debug messages

Bug #1761202 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
John A Meinel

Bug Description

Things like this are hard to parse:
machine-0: 18:08:29 DEBUG juju.replicaset Set() changing replica set
from {Name: juju, Version: 10, Members: {Member{2 "10.16.17.4:37017" map[juju-machine-id:2]}, Member{1 "10.16.17.189:37017" map[juju-machine-id:0]}, Member{3 "10.16.17.165:37017" map[juju-machine-id:3]}}}
  to {Name: juju, Version: 11, Members: {Member{3 "10.16.17.165:37017" map[juju-machine-id:3]}, Member{2 "10.16.17.4:37017" map[juju-machine-id:2]}, Member{1 "10.16.17.189:37017" map[juju-machine-id:0]}}}

It would be better to format those nicely so you can figure out what is actually changing. eg:
machine-0: 18:08:29 DEBUG juju.replicaset Set() changing replica set
from {
 Name: juju,
 Version: 10,
 Members: {
  Member{1 "10.16.17.189:37017" map[juju-machine-id:0]},
  Member{2 "10.16.17.4:37017" map[juju-machine-id:2]},
  Member{3 "10.16.17.165:37017" map[juju-machine-id:3]},
 },
}
  to {
 Name: juju,
 Version: 11,
 Members: {
  Member{1 "10.16.17.189:37017" map[juju-machine-id:0]},
  Member{2 "10.16.17.4:37017" map[juju-machine-id:2]},
  Member{3 "10.16.17.165:37017" map[juju-machine-id:3]},
 },
}

Note that the members are also sorted by Id.
Also, this particular change was illegal because were also changing the Voting status of some machines, but that does not show up in the output. We need to include more fields so we can tell what is really changing.

Potentially we might even use something like:
  https://godoc.org/github.com/kr/pretty#Diff

John A Meinel (jameinel)
description: updated
Changed in juju:
assignee: nobody → John A Meinel (jameinel)
John A Meinel (jameinel)
Changed in juju:
status: Triaged → In Progress
Revision history for this message
John A Meinel (jameinel) wrote :

pretty.Diff turned out to not be super helpful when dealing with slices of Members. Using a custom formatter and then doing the diff gave:
[LOG] 0:18.786 DEBUG juju.replicaset Add() changing replica set
from {
  Name: juju,
  Version: 1,
  Members: {
    {1 "localhost:43465" foo:bar voting},
  },
}
  to {
  Name: juju,
  Version: 2,
  Members: {
    {1 "localhost:43465" foo:bar voting},
    {2 "localhost:41232" voting},
    {3 "localhost:36076" voting},
  },
}
diff:
Version: 1 != 2
Members: []replicaset.Member[1] != []replicaset.Member[3]

So it didn't really clarify that #2 and #3 were being added.

However, we can at least update the existing "fmtConfigForLog" to do a better job with indenting, etc, and making it much clearer to read.

https://github.com/juju/replicaset/pull/8

John A Meinel (jameinel)
Changed in juju:
status: In Progress → Fix Committed
milestone: none → 2.4-beta1
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.