Skip to content

Commit

Permalink
Use metadata on decoded workload
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancoleman committed Dec 16, 2023
1 parent 0777ee5 commit 6d754a9
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions internal/mesh/internal/controllers/sidecarproxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,18 @@ func (r *reconciler) Reconcile(ctx context.Context, rt controller.Runtime, req c

// Check if the workload exists.
workloadID := resource.ReplaceType(pbcatalog.WorkloadType, req.ID)

res, err := rt.Client.Read(ctx, &pbresource.ReadRequest{Id: workloadID})
workload, err := dataFetcher.FetchWorkload(ctx, workloadID)
if err != nil {
rt.Logger.Error("error fetching the associated workload", "error", err)
rt.Logger.Error("error reading the associated workload", "error", err)
return err
}

// If the workload is for a xGateway, then do nothing + let the gatewayproxy controller reconcile it
if res != nil && res.Resource != nil {
if gatewayKind := res.Resource.Metadata["gateway-kind"]; gatewayKind != "" {
rt.Logger.Trace("workload is a gateway; skipping reconciliation", "workload", workloadID, "gateway-kind", gatewayKind)
return nil
}
if gatewayKind := workload.Metadata["gateway-kind"]; gatewayKind != "" {
rt.Logger.Trace("workload is a gateway; skipping reconciliation", "workload", workloadID, "gateway-kind", gatewayKind)
return nil
}

workload, err := resource.Decode[*pbcatalog.Workload](res.Resource)
if err != nil {
rt.Logger.Error("error decoding the associated workload", "error", err)
return err
}
if workload == nil {
// If workload has been deleted, then return as ProxyStateTemplate should be cleaned up
// by the garbage collector because of the owner reference.
Expand Down

0 comments on commit 6d754a9

Please sign in to comment.