Skip to content

Commit

Permalink
MAISTRA-2611 Fix deletion of service exports to federated mesh (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgn committed Sep 1, 2021
1 parent e49d4bf commit 7253710
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/servicemesh/federation/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,17 @@ func (s *meshServer) resync() {
s.logger.Debugf("skipping external service: %s", svc.Hostname)
continue
}
svcKey := serviceKeyForService(svc)
svcMessage := s.getServiceMessage(svc, s.exportConfig.NameForService(svc))
if svcMessage == nil {
if existingSvc, found := s.currentServices[svcKey]; found {
s.logger.Debugf("export for service %+v as %+v deleted", svcKey, existingSvc.ServiceKey)
s.deleteService(svcKey, existingSvc)
continue
}
s.logger.Debugf("skipping export of service %+v, as it does not match any export filter", serviceKeyForService(svc))
continue
}
svcKey := serviceKeyForService(svc)
if existingSvc, found := s.currentServices[svcKey]; found {
if existingSvc.GenerateChecksum() == svcMessage.GenerateChecksum() {
continue
Expand Down
46 changes: 46 additions & 0 deletions pkg/servicemesh/federation/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,52 @@ func TestWatch(t *testing.T) {
},
},
},
{
name: "service export removed",
remoteName: "test-remote",
serviceExports: exportProductPage,
updatedExports: &v1.ExportedServiceSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-remote",
},
},
services: []*model.Service{
{
Hostname: "productpage.bookinfo.svc.cluster.local",
Attributes: model.ServiceAttributes{
Name: "productpage",
Namespace: "bookinfo",
},
Ports: model.PortList{
&model.Port{
Name: "https",
Protocol: protocol.HTTPS,
Port: 443,
},
},
},
},
serviceEvents: nil,
expectedWatchEvents: []*federationmodel.WatchEvent{
{
Action: federationmodel.ActionDelete,
Service: &federationmodel.ServiceMessage{
ServiceKey: federationmodel.ServiceKey{
Name: "service",
Namespace: "federation",
Hostname: "service.federation.svc.test-remote-exports.local",
},
ServicePorts: []*federationmodel.ServicePort{
{
Name: "https",
Port: 443,
Protocol: "HTTPS",
},
},
},
},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 7253710

Please sign in to comment.