Skip to content

Commit

Permalink
updateMachineStatus: Log changes with ObjectReflectDiff
Browse files Browse the repository at this point in the history
Because logs like:

  $ curl -s https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_installer/525/pull-ci-openshift-installer-master-e2e-aws/867/artifacts/e2e-aws/pods/openshift-cluster-api_clusterapi-manager-controllers-76c6686888-brwk4_aws-machine-controller.log.gz | gunzip  | tail -n 11
  time="2018-10-24T15:08:11Z" level=debug msg="finished calculating AWS status" controller=awsMachine instanceID=i-0d6c4a1b08ea79f9e machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-0-sjvd8
  time="2018-10-24T15:08:11Z" level=info msg="machine status has changed, updating" controller=awsMachine instanceID=i-0d6c4a1b08ea79f9e machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-0-sjvd8
  time="2018-10-24T15:08:12Z" level=debug msg="checking if machine exists" controller=awsMachine machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=debug msg="instance exists as \"i-0de7e801e6cb70ca2\"" controller=awsMachine machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=debug msg="updating machine" controller=awsMachine machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=debug msg="obtaining EC2 client for region" controller=awsMachine machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk region=us-east-1
  time="2018-10-24T15:08:12Z" level=debug msg="found 1 instances for machine" controller=awsMachine machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=debug msg="instance found" controller=awsMachine instanceID=i-0de7e801e6cb70ca2 machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=debug msg="updating status" controller=awsMachine instanceID=i-0de7e801e6cb70ca2 machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=debug msg="finished calculating AWS status" controller=awsMachine instanceID=i-0de7e801e6cb70ca2 machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk
  time="2018-10-24T15:08:12Z" level=info msg="machine status has changed, updating" controller=awsMachine instanceID=i-0de7e801e6cb70ca2 machine=openshift-cluster-api/ci-op-kgknj8yp-1d3f3-worker-1-vwwqk

are pretty opaque without details about what has changed.

Among the various diff flavors in the package, I've gone with
ObjectReflectDiff to get the most readable output.  ObjectDiff
(strangely) compares compact JSON, leading to output like:

  $ curl -s https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_cluster-api-provider-aws/93/pull-ci-openshift-cluster-api-provider-aws-master-e2e-aws/94/artifacts/e2e-aws/pods/openshift-cluster-api_clusterapi-manager-controllers-54f8676476-pzkxz_machine-controller.log.gz | gunzip | tail -n6
  time="2018-10-29T23:20:13Z" level=info msg="machine status has changed, updating" controller=awsMachine instanceID=i-0cd71a40aceb4b1c5 machine=openshift-cluster-api/ci-op-3y5hwj87-d771b-worker-0-dltpq
  time="2018-10-29T23:20:13Z" level=debug msg="changed status:\n{\n\nA: }\n\nB: \"providerStatus\":{\"kind\":\"AWSMachineProviderStatus\",\"apiVersion\":\"awsproviderconfig.k8s.io/v1alpha1\",\"InstanceID\":\"i-0cd71a40aceb4b1c5\",\"InstanceState\":\"running\",\"Conditions\":[{\"Type\":\"MachineCreation\",\"Status\":\"True\",\"LastProbeTime\":\"2018-10-29T23:20:13Z\",\"LastTransitionTime\":\"2018-10-29T23:20:13Z\",\"Reason\":\"MachineCreationSucceeded\",\"Message\":\"machine successfully created\"}]},\"addresses\":[{\"type\":\"InternalIP\",\"address\":\"10.0.139.1\"},{\"type\":\"ExternalDNS\",\"address\":\"\"},{\"type\":\"InternalDNS\",\"address\":\"ip-10-0-139-1.ec2.internal\"}]}\n\n" controller=awsMachine instanceID=i-0cd71a40aceb4b1c5 machine=openshift-cluster-api/ci-op-3y5hwj87-d771b-worker-0-dltpq
  time="2018-10-29T23:20:13Z" level=debug msg="checking if machine exists" controller=awsMachine machine=openshift-cluster-api/ci-op-3y5hwj87-d771b-worker-1-5qgrt
  time="2018-10-29T23:20:13Z" level=debug msg="instance exists as \"i-0f0cc95e0b1f619ef\"" controller=awsMachine machine=openshift-cluster-api/ci-op-3y5hwj87-d771b-worker-1-5qgrt
  time="2018-10-29T23:20:13Z" level=debug msg="updating machine" controller=awsMachine machine=openshift-cluster-api/ci-op-3y5hwj87-d771b-worker-1-5qgrt
  time="2018-10-29T23:20:13Z" level=debug msg="obtaining EC2 client for region" controller=awsMachine machine=openshift-cluster-api/ci-op-3y5hwj87-d771b-worker-1-5qgrt region=us-east-1

ObjectGoPrintDiff sounds very noisy, although I haven't actually run
it to see the output.  ObjectGoPrintSideBySide sounds like it takes a
lot of space too, and while side-by-side diffs can be useful when
printed out, once that output has been wrapped in a string with
escaped newlines, etc., I expect it would be pretty hard to skim.
  • Loading branch information
wking committed Oct 30, 2018
1 parent 926813e commit ece3a63
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/cloud/aws/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/kubernetes"

providerconfigv1 "sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1"
Expand Down Expand Up @@ -134,7 +135,7 @@ func (a *Actuator) updateMachineStatus(machine *clusterv1.Machine, awsStatus *pr
}

if !equality.Semantic.DeepEqual(machine.Status, machineCopy.Status) {
glog.Info("machine status has changed, updating")
glog.Infof("machine status changed: %s", diff.ObjectReflectDiff(machine.Status, machineCopy.Status))
time := metav1.Now()
machineCopy.Status.LastUpdated = &time

Expand Down

0 comments on commit ece3a63

Please sign in to comment.