@@ -20,14 +20,17 @@ import (
20
20
"fmt"
21
21
"strconv"
22
22
"strings"
23
+ "time"
23
24
24
25
"github.com/go-openapi/runtime/middleware"
25
26
client_native "github.com/haproxytech/client-native/v3"
26
27
"github.com/haproxytech/client-native/v3/models"
28
+ "github.com/haproxytech/client-native/v3/runtime"
27
29
28
30
cn "github.com/haproxytech/dataplaneapi/client-native"
29
31
dataplaneapi_config "github.com/haproxytech/dataplaneapi/configuration"
30
32
"github.com/haproxytech/dataplaneapi/haproxy"
33
+ "github.com/haproxytech/dataplaneapi/log"
31
34
"github.com/haproxytech/dataplaneapi/misc"
32
35
"github.com/haproxytech/dataplaneapi/operations/configuration"
33
36
)
@@ -196,7 +199,22 @@ func (h *PostRawConfigurationHandlerImpl) reconfigureRuntime(runtimeAPIsOld []*m
196
199
dpapiCfg := dataplaneapi_config .Get ()
197
200
haproxyOptions := dpapiCfg .HAProxy
198
201
return true , func () {
199
- h .Client .ReplaceRuntime (cn .ConfigureRuntimeClient (context .Background (), cfg , haproxyOptions ))
202
+ var rnt runtime.Runtime
203
+ i := 1
204
+ for i < 10 {
205
+ rnt = cn .ConfigureRuntimeClient (context .Background (), cfg , haproxyOptions )
206
+ if rnt != nil {
207
+ break
208
+ }
209
+ time .Sleep (time .Duration (i ) * time .Second )
210
+ i += i // exponential backoof
211
+ }
212
+ h .Client .ReplaceRuntime (rnt )
213
+ if rnt == nil {
214
+ log .Debugf ("reload callback completed, no runtime API" )
215
+ } else {
216
+ log .Debugf ("reload callback completed, runtime API reconfigured" )
217
+ }
200
218
}, nil
201
219
}
202
220
0 commit comments