Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09b519f

Browse files
committed
Full re-auth should not clear services list, as that breaks the on-change logic. Fixes #818
1 parent 7f9d028 commit 09b519f

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release notes 1.2.9
2+
3+
## Issues Fixed and Dependency Updates
4+
5+
* github.com/openziti/sdk-golang: [v1.2.8 -> v1.2.9](https://github.com/openziti/sdk-golang/compare/v1.2.8...v1.2.9)
6+
* [Issue #818](https://github.com/openziti/sdk-golang/issues/818) - Full re-auth should not clear services list, as that breaks the on-change logic
7+
* [Issue #817](https://github.com/openziti/sdk-golang/issues/817) - goroutines can get stuck when iterating over randomized HA controller list
8+
19
# Release notes 1.2.8
210

311
## Issues Fixed and Dependency Updates

ziti/contexts.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func NewContextWithOpts(cfg *Config, options *Options) (Context, error) {
9292
routerProxy: cfg.RouterProxy,
9393
maxDefaultConnections: int(cfg.MaxDefaultConnections),
9494
maxControlConnections: int(cfg.MaxControlConnections),
95+
services: cmap.New[*rest_model.ServiceDetail](),
96+
sessions: cmap.New[*rest_model.SessionDetail](),
97+
intercepts: cmap.New[*edge.InterceptV1Config](),
9598
}
9699

97100
if newContext.maxDefaultConnections < 1 {

ziti/sdkinfo/build_info.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ziti/ziti.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ func (context *ContextImpl) processServiceUpdates(services []*rest_model.Service
545545
context.Emit(EventServiceRemoved, svc)
546546

547547
context.deleteServiceSessions(*svc.ID)
548-
549548
}
550549
})
551550

@@ -603,7 +602,9 @@ func (context *ContextImpl) processServiceAddOrUpdated(s *rest_model.ServiceDeta
603602
})
604603

605604
if isChange {
606-
context.Emit(EventServiceChanged, s)
605+
if valuesDiffer {
606+
context.Emit(EventServiceChanged, s)
607+
}
607608
} else {
608609
context.Emit(EventServiceAdded, s)
609610
}
@@ -614,7 +615,6 @@ func (context *ContextImpl) processServiceAddOrUpdated(s *rest_model.ServiceDeta
614615
context.options.OnServiceUpdate(ServiceChanged, s)
615616
}
616617
} else {
617-
context.services.Set(*s.Name, s)
618618
context.options.OnServiceUpdate(ServiceAdded, s)
619619
}
620620
}
@@ -740,17 +740,16 @@ func (context *ContextImpl) refreshServices(forceRefresh, refreshAfterAuth bool)
740740
}
741741

742742
target := &service.ListServicesUnauthorized{}
743-
if errors.As(err, &target) {
744-
log.Info("attempting to re-authenticate")
745-
if authErr := context.Authenticate(); authErr != nil {
746-
log.WithError(authErr).Error("unable to re-authenticate during services refresh")
747-
return err
748-
}
749-
if services, err = context.CtrlClt.GetServices(); err != nil {
750-
return err
751-
}
743+
if !errors.As(err, &target) {
744+
return err
745+
}
752746

753-
} else {
747+
log.Info("attempting to re-authenticate")
748+
if authErr := context.Authenticate(); authErr != nil {
749+
log.WithError(authErr).Error("unable to re-authenticate during services refresh")
750+
return err
751+
}
752+
if services, err = context.CtrlClt.GetServices(); err != nil {
754753
return err
755754
}
756755
}
@@ -955,9 +954,7 @@ func (context *ContextImpl) setUnauthenticated() {
955954

956955
func (context *ContextImpl) authenticate() error {
957956
logrus.Debug("attempting to authenticate")
958-
context.services = cmap.New[*rest_model.ServiceDetail]()
959-
context.sessions = cmap.New[*rest_model.SessionDetail]()
960-
context.intercepts = cmap.New[*edge.InterceptV1Config]()
957+
context.sessions.Clear()
961958

962959
context.setUnauthenticated()
963960

0 commit comments

Comments
 (0)