@@ -61,11 +61,11 @@ show(io::IO, ctx::KuberContext) = print("Kubernetes namespace ", ctx.namespace,
61
61
get_server (ctx:: KuberContext ) = ctx. client. root
62
62
get_ns (ctx:: KuberContext ) = ctx. namespace
63
63
64
- function set_server (ctx:: KuberContext , uri:: String = DEFAULT_URI, reset_api_versions:: Bool = false ; kwargs... )
64
+ function set_server (ctx:: KuberContext , uri:: String = DEFAULT_URI, reset_api_versions:: Bool = false ; max_tries = 1 , kwargs... )
65
65
rtfn = (default,data)-> kuber_type (ctx, default, data)
66
66
ctx. client = Swagger. Client (uri; get_return_type= rtfn, kwargs... )
67
67
ctx. client. headers[" Connection" ] = " close"
68
- reset_api_versions && set_api_versions! (ctx)
68
+ reset_api_versions && set_api_versions! (ctx; max_tries = max_tries )
69
69
ctx. client
70
70
end
71
71
@@ -113,9 +113,16 @@ function override_pref(name, server_pref, override)
113
113
server_pref
114
114
end
115
115
116
- function fetch_misc_apis_versions (ctx:: KuberContext ; override= nothing , verbose:: Bool = false )
116
+ function fetch_misc_apis_versions (ctx:: KuberContext ; override= nothing , verbose:: Bool = false , max_tries = 1 )
117
117
apis = ctx. apis
118
- vers = getAPIVersions (ApisApi (ctx. client))
118
+ vers = @repeat max_tries try
119
+ getAPIVersions (ApisApi (ctx. client))
120
+ catch e
121
+ @retry if isa (e, IOError)
122
+ @debug (" Retrying getAPIVersions" )
123
+ sleep (2 )
124
+ end
125
+ end
119
126
api_groups = vers. groups
120
127
for apigrp in api_groups
121
128
name = apigrp. name
@@ -150,9 +157,16 @@ function fetch_misc_apis_versions(ctx::KuberContext; override=nothing, verbose::
150
157
apis
151
158
end
152
159
153
- function fetch_core_version (ctx:: KuberContext ; override= nothing , verbose:: Bool = false )
160
+ function fetch_core_version (ctx:: KuberContext ; override= nothing , verbose:: Bool = false , max_tries = 1 )
154
161
apis = ctx. apis
155
- api_vers = getCoreAPIVersions (CoreApi (ctx. client))
162
+ api_vers = @repeat max_tries try
163
+ getCoreAPIVersions (CoreApi (ctx. client))
164
+ catch e
165
+ @retry if isa (e, IOError)
166
+ @debug (" Retrying getCoreAPIVersions" )
167
+ sleep (2 )
168
+ end
169
+ end
156
170
name = " Core"
157
171
pref_vers = override_pref (name, api_vers. versions[1 ], override)
158
172
verbose && @info (" Core versions" , supported= join (api_vers. versions, " , " ), preferred= pref_vers)
@@ -194,7 +208,7 @@ function build_model_api_map(ctx::KuberContext)
194
208
modelapi
195
209
end
196
210
197
- function set_api_versions! (ctx:: KuberContext ; override= nothing , verbose:: Bool = false )
211
+ function set_api_versions! (ctx:: KuberContext ; override= nothing , verbose:: Bool = false , max_tries = 1 )
198
212
empty! (ctx. apis)
199
213
empty! (ctx. modelapi)
200
214
@@ -203,8 +217,8 @@ function set_api_versions!(ctx::KuberContext; override=nothing, verbose::Bool=fa
203
217
build_model_api_map (ctx)
204
218
205
219
# fetch apis and map the types
206
- fetch_core_version (ctx; override= override, verbose= verbose)
207
- fetch_misc_apis_versions (ctx; override= override, verbose= verbose)
220
+ fetch_core_version (ctx; override= override, verbose= verbose, max_tries = max_tries )
221
+ fetch_misc_apis_versions (ctx; override= override, verbose= verbose, max_tries = max_tries )
208
222
build_model_api_map (ctx)
209
223
210
224
# add custom models
0 commit comments