From 4a4bee7d9478327464fbe049d4ab1529b73c87c5 Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Fri, 15 Dec 2023 12:39:55 -0500 Subject: [PATCH] Log when pod controller creates workload in Consul --- .../connect-inject/controllers/pod/pod_controller.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/control-plane/connect-inject/controllers/pod/pod_controller.go b/control-plane/connect-inject/controllers/pod/pod_controller.go index ab37f7b263..1f94110c60 100644 --- a/control-plane/connect-inject/controllers/pod/pod_controller.go +++ b/control-plane/connect-inject/controllers/pod/pod_controller.go @@ -336,9 +336,11 @@ func (r *Controller) writeWorkload(ctx context.Context, pod corev1.Pod) error { } data := inject.ToProtoAny(workload) + resourceID := getWorkloadID(pod.GetName(), r.getConsulNamespace(pod.Namespace), r.getPartition()) + r.Log.Info("registering workload with Consul", getLogFieldsForResource(resourceID)) req := &pbresource.WriteRequest{ Resource: &pbresource.Resource{ - Id: getWorkloadID(pod.GetName(), r.getConsulNamespace(pod.Namespace), r.getPartition()), + Id: resourceID, Metadata: metaFromPod(pod), Data: data, }, @@ -762,3 +764,11 @@ func getDestinationsID(name, namespace, partition string) *pbresource.ID { }, } } + +func getLogFieldsForResource(id *pbresource.ID) []any { + return []any{ + "name", id.Name, + "ns", id.Tenancy.Namespace, + "partition", id.Tenancy.Partition, + } +}