@@ -88,11 +88,6 @@ func (c *Connected) Enter(ctx context.Context) statemachine.Event {
88
88
c .unhealthy = false
89
89
}()
90
90
91
- done := func () statemachine.Event {
92
- c .logger .Infof ("Config sync loop done: %s" , ctx .Err ())
93
- return statemachine .EventWaitForExternalEvent
94
- }
95
-
96
91
attempt := 0
97
92
for ctx .Err () == nil {
98
93
attempt ++
@@ -111,9 +106,13 @@ func (c *Connected) Enter(ctx context.Context) statemachine.Event {
111
106
case errors .Is (e , ErrLostConnection ):
112
107
c .logger .Infof ("Lost connection, reconnecting.." )
113
108
attempt = 0
114
- case errors .Is (e , context .Canceled ) || errors .Is (e , context .DeadlineExceeded ):
115
- c .logger .Infof ("syncConfigLoop: %v" , err )
116
- return done ()
109
+ case errors .Is (e , context .DeadlineExceeded ):
110
+ c .logger .Infof ("syncConfigLoop deadline exceeded: %v" , err )
111
+ return statemachine .EventDisconnect
112
+ case errors .Is (e , context .Canceled ):
113
+ // in this case something from the outside canceled us, let them decide next state
114
+ c .logger .Infof ("syncConfigLoop canceled: %v" , err )
115
+ return statemachine .EventWaitForExternalEvent
117
116
case e != nil :
118
117
// Unhandled error: disconnect
119
118
c .logger .Errorf ("error in syncConfigLoop: %v" , err )
@@ -122,7 +121,7 @@ func (c *Connected) Enter(ctx context.Context) statemachine.Event {
122
121
}
123
122
}
124
123
125
- return done ()
124
+ return statemachine . EventDisconnect
126
125
}
127
126
func (c * Connected ) triggerStatusUpdate () {
128
127
select {
0 commit comments