Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Return Consul resolution error when no matching service name from peer
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancoleman committed Nov 7, 2022
1 parent 8840868 commit 7f67148
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/k8s/service/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ func (r *backendResolver) findPeerService(ctx context.Context, service *apigwv1a
return nil, err
}

if peer == nil {
return nil, NewConsulResolutionError(fmt.Sprintf("no peer %q found", consulPeer))
}

for _, importedService := range peer.StreamStatus.ImportedServices {
if importedService == consulName {
return NewConsulServiceReference(&ConsulService{
Expand All @@ -417,8 +421,7 @@ func (r *backendResolver) findPeerService(ctx context.Context, service *apigwv1a
}
}

// TODO Consider BackendNotFound vs. ConsulResolutionError
return nil, NewBackendNotFoundError(fmt.Sprintf("no service %s found on peer %s", consulName, consulPeer))
return nil, NewConsulResolutionError(fmt.Sprintf("no service %s found from peer %s", consulName, consulPeer))
}

func (r *backendResolver) findCatalogService(service *apigwv1alpha1.MeshService) (*ResolvedReference, error) {
Expand Down

0 comments on commit 7f67148

Please sign in to comment.