Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Removing ListSMIPolicies() and ListMonitoredNamespaces() from MeshCat…
Browse files Browse the repository at this point in the history
…aloger interface (#3109)

* Removing ListSMIPolicies() and ListMonitoredNamespaces() from MeshCataloger interface

Signed-off-by: Delyan Raychev <delyan.raychev@microsoft.com>
  • Loading branch information
draychev authored Apr 9, 2021
1 parent 12f85a1 commit 707593c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 49 deletions.
34 changes: 0 additions & 34 deletions pkg/catalog/mock_catalog_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions pkg/catalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
"time"

"github.com/google/uuid"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
"k8s.io/client-go/kubernetes"

"github.com/openservicemesh/osm/pkg/certificate"
Expand Down Expand Up @@ -81,9 +78,6 @@ type MeshCataloger interface {
// ListServiceAccountsForService lists the service accounts associated with the given service
ListServiceAccountsForService(service.MeshService) ([]service.K8sServiceAccount, error)

// ListSMIPolicies lists SMI policies.
ListSMIPolicies() ([]*split.TrafficSplit, []service.K8sServiceAccount, []*spec.HTTPRouteGroup, []*access.TrafficTarget)

// ListEndpointsForService returns the list of individual instance endpoint backing a service
ListEndpointsForService(service.MeshService) ([]endpoint.Endpoint, error)

Expand Down Expand Up @@ -114,15 +108,12 @@ type MeshCataloger interface {
// GetIngressPoliciesForService returns the inbound traffic policies associated with an ingress service
GetIngressPoliciesForService(service.MeshService) ([]*trafficpolicy.InboundTrafficPolicy, error)

// ListMonitoredNamespaces lists namespaces monitored by the control plane
ListMonitoredNamespaces() []string

// GetTargetPortToProtocolMappingForService returns a mapping of the service's ports to their corresponding application protocol.
// The ports returned are the actual ports on which the application exposes the service derived from the service's endpoints,
// ie. 'spec.ports[].targetPort' instead of 'spec.ports[].port' for a Kubernetes service.
GetTargetPortToProtocolMappingForService(service.MeshService) (map[uint32]string, error)

// GetTargetPortToProtocolMappingForService returns a mapping of the service's ports to their corresponding application protocol,
// GetPortToProtocolMappingForService returns a mapping of the service's ports to their corresponding application protocol,
// where the ports returned are the ones used by downstream clients in their requests. This can be different from the ports
// actually exposed by the application binary, ie. 'spec.ports[].port' instead of 'spec.ports[].targetPort' for a Kubernetes service.
GetPortToProtocolMappingForService(service.MeshService) (map[uint32]string, error)
Expand Down
6 changes: 5 additions & 1 deletion pkg/debugger/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ type namespaces struct {
func (ds DebugConfig) getMonitoredNamespacesHandler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var n namespaces
n.Namespaces = ds.meshCatalogDebugger.ListMonitoredNamespaces()
var err error
n.Namespaces, err = ds.kubeController.ListMonitoredNamespaces()
if err != nil {
log.Error().Err(err).Msgf("Error marshalling policy %+v", n)
}

jsonPolicies, err := json.Marshal(n)
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions pkg/debugger/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"net/http/httptest"
"testing"

k8s "github.com/openservicemesh/osm/pkg/kubernetes"

"github.com/golang/mock/gomock"
tassert "github.com/stretchr/testify/assert"

Expand All @@ -13,11 +15,11 @@ import (
// Tests getMonitoredNamespaces through HTTP handler returns a the list of monitored namespaces
func TestMonitoredNamespaceHandler(t *testing.T) {
assert := tassert.New(t)
mockCtrl := gomock.NewController(t)
mock := NewMockMeshCatalogDebugger(mockCtrl)

mockKubeController := k8s.NewMockController(gomock.NewController(t))

ds := DebugConfig{
meshCatalogDebugger: mock,
kubeController: mockKubeController,
}
monitoredNamespacesHandler := ds.getMonitoredNamespacesHandler()

Expand All @@ -26,7 +28,7 @@ func TestMonitoredNamespaceHandler(t *testing.T) {
tests.BookstoreV1Service.Namespace, // default
})

mock.EXPECT().ListMonitoredNamespaces().Return(uniqueNs)
mockKubeController.EXPECT().ListMonitoredNamespaces().Return(uniqueNs, nil)

responseRecorder := httptest.NewRecorder()
monitoredNamespacesHandler.ServeHTTP(responseRecorder, nil)
Expand Down

0 comments on commit 707593c

Please sign in to comment.