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

Commit

Permalink
sds: Remove unused services list from SDS struct
Browse files Browse the repository at this point in the history
Signed-off-by: Delyan Raychev <delyan.raychev@microsoft.com>
  • Loading branch information
draychev committed Feb 26, 2021
1 parent 5c137bd commit 6b7d1aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
22 changes: 7 additions & 15 deletions pkg/envoy/sds/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ import (
func NewResponse(meshCatalog catalog.MeshCataloger, proxy *envoy.Proxy, request *xds_discovery.DiscoveryRequest, cfg configurator.Configurator, certManager certificate.Manager) (*xds_discovery.DiscoveryResponse, error) {
log.Debug().Msgf("Composing SDS Discovery Response for Envoy with certificate SerialNumber=%s on Pod with UID=%s", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())

svcList, err := meshCatalog.GetServicesFromEnvoyCertificate(proxy.GetCertificateCommonName())
if err != nil {
log.Error().Err(err).Msgf("Error getting services associated with Envoy with certificate SerialNumber=%s on Pod with UID=%s",
proxy.GetCertificateSerialNumber(), proxy.GetPodUID())
return nil, err
}

// OSM currently relies on kubernetes ServiceAccount for service identity
svcAccount, err := catalog.GetServiceAccountFromProxyCertificate(proxy.GetCertificateCommonName())
if err != nil {
Expand All @@ -36,18 +29,17 @@ func NewResponse(meshCatalog catalog.MeshCataloger, proxy *envoy.Proxy, request
return nil, err
}

sdsImpl := newSDSImpl(proxy, meshCatalog, certManager, cfg, svcList, svcAccount)
sdsImpl := newSDSImpl(proxy, meshCatalog, certManager, cfg, svcAccount)
return sdsImpl.createDiscoveryResponse(request)
}

func newSDSImpl(proxy *envoy.Proxy, meshCatalog catalog.MeshCataloger, certManager certificate.Manager, cfg configurator.Configurator, proxyServices []service.MeshService, svcAccount service.K8sServiceAccount) *sdsImpl {
func newSDSImpl(proxy *envoy.Proxy, meshCatalog catalog.MeshCataloger, certManager certificate.Manager, cfg configurator.Configurator, svcAccount service.K8sServiceAccount) *sdsImpl {
impl := &sdsImpl{
proxy: proxy,
meshCatalog: meshCatalog,
certManager: certManager,
cfg: cfg,
svcAccount: svcAccount,
proxyServices: proxyServices,
proxy: proxy,
meshCatalog: meshCatalog,
certManager: certManager,
cfg: cfg,
svcAccount: svcAccount,
}

return impl
Expand Down
14 changes: 6 additions & 8 deletions pkg/envoy/sds/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ func TestGetRootCert(t *testing.T) {
certCommonName := certificate.CommonName(fmt.Sprintf("%s.%s.%s", uuid.New().String(), "sa-1", "ns-1"))
certSerialNumber := certificate.SerialNumber("123456")
s := &sdsImpl{
proxyServices: []service.MeshService{tc.proxyService},
svcAccount: tc.proxySvcAccount,
proxy: envoy.NewProxy(certCommonName, certSerialNumber, nil),
certManager: mockCertManager,
svcAccount: tc.proxySvcAccount,
proxy: envoy.NewProxy(certCommonName, certSerialNumber, nil),
certManager: mockCertManager,

// these points to the dynamic mocks which gets updated for each test
meshCatalog: d.mockCatalog,
Expand Down Expand Up @@ -356,10 +355,9 @@ func TestGetSDSSecrets(t *testing.T) {
certCommonName := certificate.CommonName(fmt.Sprintf("%s.%s.%s", uuid.New().String(), "sa-1", "ns-1"))
certSerialNumber := certificate.SerialNumber("123456")
s := &sdsImpl{
proxyServices: []service.MeshService{tc.proxyService},
svcAccount: tc.proxySvcAccount,
proxy: envoy.NewProxy(certCommonName, certSerialNumber, nil),
certManager: mockCertManager,
svcAccount: tc.proxySvcAccount,
proxy: envoy.NewProxy(certCommonName, certSerialNumber, nil),
certManager: mockCertManager,

// these points to the dynamic mocks which gets updated for each test
meshCatalog: d.mockCatalog,
Expand Down
11 changes: 5 additions & 6 deletions pkg/envoy/sds/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ var (

// sdsImpl is the type that implements the internal functionality of SDS
type sdsImpl struct {
proxy *envoy.Proxy
proxyServices []service.MeshService
svcAccount service.K8sServiceAccount
meshCatalog catalog.MeshCataloger
cfg configurator.Configurator
certManager certificate.Manager
proxy *envoy.Proxy
svcAccount service.K8sServiceAccount
meshCatalog catalog.MeshCataloger
cfg configurator.Configurator
certManager certificate.Manager
}

0 comments on commit 6b7d1aa

Please sign in to comment.