Skip to content

Commit

Permalink
add comments, logs, remove printlns
Browse files Browse the repository at this point in the history
  • Loading branch information
ndhanushkodi committed Sep 19, 2023
1 parent 4c0dba3 commit b8134ee
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (r *reconciler) Reconcile(ctx context.Context, rt controller.Runtime, req c
// Get all destinationsData.
destinationsRefs := r.destinationsCache.DestinationsBySourceProxy(req.ID)
if len(destinationsRefs) > 0 {
rt.Logger.Trace("found destinations", "destination_refs", destinationsRefs)
rt.Logger.Trace("found destinations for this proxy", "id", req.ID, "destination_refs", destinationsRefs)
} else {
rt.Logger.Trace("did not find any destinations for this proxy", "id", req.ID)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ func (f *Fetcher) FetchImplicitDestinationsData(
if err != nil {
return nil, err
}
// We only add the endpoint to the map if it's not nil. If it's missing on lookup now, the
// controller should get triggered when the endpoint exists again since it watches service
// endpoints.
if se != nil {
endpointsMap[seRK] = se
}
Expand Down
3 changes: 0 additions & 3 deletions internal/mesh/internal/controllers/xds/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func (r *xdsReconciler) Reconcile(ctx context.Context, rt controller.Runtime, re
endpointReferencesMap := proxyStateTemplate.Template.RequiredEndpoints
var endpointsInProxyStateTemplate []resource.ReferenceOrID
for xdsClusterName, endpointRef := range endpointReferencesMap {
fmt.Println("*********** xds controller: generating endpoints for", xdsClusterName, endpointRef)
// Step 1: Resolve the reference by looking up the ServiceEndpoints.
// serviceEndpoints will not be nil unless there is an error.
//
Expand Down Expand Up @@ -310,7 +309,6 @@ func (r *xdsReconciler) Reconcile(ctx context.Context, rt controller.Runtime, re
// Now that the references have been resolved, push the computed proxy state to the updater.
computedProxyState := proxyStateTemplate.Template.ProxyState

fmt.Println("******** generated proxy state", proxyStateTemplate.Template.ProxyState)
err = r.updater.PushChange(req.ID, &proxytracker.ProxyState{ProxyState: computedProxyState})
if err != nil {
// Set the status.
Expand Down Expand Up @@ -343,7 +341,6 @@ func leafResourceRef(workloadIdentity, namespace, partition string) *pbresource.
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,
PeerName: "local",
},
}
return ref
Expand Down
3 changes: 0 additions & 3 deletions internal/mesh/internal/controllers/xds/endpoint_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func generateProxyStateEndpoints(serviceEndpoints *ServiceEndpointsData, portNam
}
eps := serviceEndpoints.Endpoints.GetEndpoints()

fmt.Println("*********** xds controller: generating endpoints", psEndpoints)
for _, ep := range eps {
for _, addr := range ep.Addresses {
// Check if the address is using the portName name this proxy state endpoints is for. If it does, create the
Expand All @@ -44,8 +43,6 @@ func generateProxyStateEndpoints(serviceEndpoints *ServiceEndpointsData, portNam
}
}

fmt.Println("*********** xds controller: computed endpoints", psEndpoints)

return &pbproxystate.Endpoints{Endpoints: psEndpoints}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package sidecarproxymapper

import (
"context"
"fmt"

"github.com/hashicorp/consul/internal/controller"
"github.com/hashicorp/consul/internal/mesh/internal/types/intermediate"
Expand All @@ -19,7 +18,6 @@ func (m *Mapper) MapDestinationsToProxyStateTemplate(ctx context.Context, rt con
if err != nil {
return nil, err
}
fmt.Println("******** observed upstreams", "id", res.Id)

// Look up workloads for this destinations.
sourceProxyIDs := make(map[resource.ReferenceKey]struct{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package sidecarproxymapper

import (
"context"
"fmt"

"github.com/hashicorp/consul/internal/controller"
"github.com/hashicorp/consul/internal/mesh/internal/types"
Expand Down Expand Up @@ -72,8 +71,6 @@ func (m *Mapper) mapServiceThroughDestinationsToProxyStateTemplates(
}

func (m *Mapper) listAllProxyStateTemplatesTemporarily(ctx context.Context, rt controller.Runtime, tenancy *pbresource.Tenancy) ([]*pbresource.ID, error) {
fmt.Println("******* listing all proxy state templates")
fmt.Println("******* tenancy", tenancy)
// todo (ishustava): this is a stub for now until we implement implicit destinations.
// For tproxy, we generate requests for all proxy states in the cluster.
// This will generate duplicate events for proxies already added above,
Expand All @@ -87,14 +84,10 @@ func (m *Mapper) listAllProxyStateTemplatesTemporarily(ctx context.Context, rt c
},
})
if err != nil {
fmt.Println("*********** errored listing all proxy state templates: ", err)
return nil, err
}

result := make([]*pbresource.ID, 0, len(rsp.Resources))
if len(rsp.Resources) == 0 {
fmt.Println("*********** got 0 proxy state templates: ")
}
for _, r := range rsp.Resources {
result = append(result, r.Id)
}
Expand Down

0 comments on commit b8134ee

Please sign in to comment.