Get only first service to test whether we have to cleanup index of a service

This commit is contained in:
Pierre Souchay 2018-02-19 22:44:49 +01:00
parent 523feb0be4
commit ec1b278595
1 changed files with 2 additions and 2 deletions

View File

@ -1052,8 +1052,8 @@ func (s *Store) deleteServiceTxn(tx *memdb.Txn, idx uint64, nodeName, serviceID
}
svc := service.(*structs.ServiceNode)
if remainingServicesItr, err := tx.Get("services", "service", svc.ServiceName); err == nil {
if remainingServicesItr != nil && remainingServicesItr.Next() != nil {
if remainingService, err := tx.First("services", "service", svc.ServiceName); err == nil {
if remainingService != nil {
// We have at least one remaining service, update the index
if err := tx.Insert("index", &IndexEntry{serviceIndexName(svc.ServiceName), idx}); err != nil {
return fmt.Errorf("failed updating index: %s", err)