Skip to content

Commit

Permalink
Log when pod controller creates workload in Consul
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancoleman committed Dec 15, 2023
1 parent ee37a61 commit 4a4bee7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion control-plane/connect-inject/controllers/pod/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
}
}

0 comments on commit 4a4bee7

Please sign in to comment.