23
23
_api_function (name:: Symbol ) = isdefined (@__MODULE__ , name) ? eval (name) : nothing
24
24
_api_function (name) = _api_function (Symbol (name))
25
25
26
- function list (ctx:: KuberContext , O:: Symbol , name:: String ; apiversion:: Union{String,Nothing} = nothing , namespace:: Union{String,Nothing} = ctx. namespace, kwargs... )
26
+ function list (ctx:: KuberContext , O:: Symbol , name:: String ; apiversion:: Union{String,Nothing} = nothing , namespace:: Union{String,Nothing} = ctx. namespace, max_tries :: Int = 1 , kwargs... )
27
27
ctx. initialized || set_api_versions! (ctx)
28
28
29
29
apictx = _get_apictx (ctx, O, apiversion)
@@ -32,17 +32,17 @@ function list(ctx::KuberContext, O::Symbol, name::String; apiversion::Union{Stri
32
32
33
33
if allnamespaces
34
34
apicall = eval (Symbol (" list$(O) ForAllNamespaces" ))
35
- return apicall (apictx, name; kwargs... )
35
+ return @retry_on_error apicall (apictx, name; kwargs... )
36
36
elseif namespaced
37
37
apicall = eval (Symbol (" listNamespaced$O " ))
38
- return apicall (apictx, name, namespace; kwargs... )
38
+ return @retry_on_error apicall (apictx, name, namespace; kwargs... )
39
39
else
40
40
apicall = eval (Symbol (" list$O " ))
41
- return apicall (apictx, name; kwargs... )
41
+ return @retry_on_error apicall (apictx, name; kwargs... )
42
42
end
43
43
end
44
44
45
- function list (ctx:: KuberContext , O:: Symbol ; apiversion:: Union{String,Nothing} = nothing , namespace:: Union{String,Nothing} = ctx. namespace, kwargs... )
45
+ function list (ctx:: KuberContext , O:: Symbol ; apiversion:: Union{String,Nothing} = nothing , namespace:: Union{String,Nothing} = ctx. namespace, max_tries :: Int = 1 , kwargs... )
46
46
ctx. initialized || set_api_versions! (ctx)
47
47
48
48
apictx = _get_apictx (ctx, O, apiversion)
@@ -51,13 +51,13 @@ function list(ctx::KuberContext, O::Symbol; apiversion::Union{String,Nothing}=no
51
51
52
52
if allnamespaces
53
53
apicall = eval (Symbol (" list$(O) ForAllNamespaces" ))
54
- return apicall (apictx; kwargs... )
54
+ return @retry_on_error apicall (apictx; kwargs... )
55
55
elseif namespaced
56
56
apicall = eval (Symbol (" listNamespaced$O " ))
57
- return apicall (apictx, namespace; kwargs... )
57
+ return @retry_on_error apicall (apictx, namespace; kwargs... )
58
58
else
59
59
apicall = eval (Symbol (" list$O " ))
60
- return apicall (apictx; kwargs... )
60
+ return @retry_on_error apicall (apictx; kwargs... )
61
61
end
62
62
end
63
63
@@ -66,23 +66,9 @@ function get(ctx::KuberContext, O::Symbol, name::String; apiversion::Union{Strin
66
66
67
67
apictx = _get_apictx (ctx, O, apiversion)
68
68
if (apicall = _api_function (" read$O " )) != = nothing
69
- @repeat max_tries try
70
- return apicall (apictx, name; kwargs... )
71
- catch e
72
- @retry if isa (e, IOError)
73
- @debug (" Retrying " , nameof (apicall))
74
- sleep (2 )
75
- end
76
- end
69
+ return @retry_on_error apicall (apictx, name; kwargs... )
77
70
elseif (apicall = _api_function (" readNamespaced$O " )) != = nothing
78
- @repeat max_tries try
79
- return apicall (apictx, name, ctx. namespace; kwargs... )
80
- catch e
81
- @retry if isa (e, IOError)
82
- @debug (" Retrying " , nameof (apicall))
83
- sleep (2 )
84
- end
85
- end
71
+ return @retry_on_error apicall (apictx, name, ctx. namespace; kwargs... )
86
72
else
87
73
throw (ArgumentError (" No API functions could be located using :$O " ))
88
74
end
@@ -95,23 +81,9 @@ function get(ctx::KuberContext, O::Symbol; apiversion::Union{String,Nothing}=not
95
81
apiname = " list$O "
96
82
namespace === nothing && (apiname *= " ForAllNamespaces" )
97
83
if (apicall = _api_function (apiname)) != = nothing
98
- @repeat max_tries try
99
- return apicall (apictx; labelSelector= label_selector)
100
- catch e
101
- @retry if isa (e, IOError)
102
- @debug (" Retrying " , nameof (apicall))
103
- sleep (2 )
104
- end
105
- end
84
+ return @retry_on_error apicall (apictx; labelSelector= label_selector)
106
85
elseif (apicall = _api_function (" listNamespaced$O " )) != = nothing
107
- @repeat max_tries try
108
- return apicall (apictx, namespace; labelSelector= label_selector)
109
- catch e
110
- @retry if isa (e, IOError)
111
- @debug (" Retrying " , nameof (apicall))
112
- sleep (2 )
113
- end
114
- end
86
+ return @retry_on_error apicall (apictx, namespace; labelSelector= label_selector)
115
87
else
116
88
throw (ArgumentError (" No API functions could be located using :$O " ))
117
89
end
0 commit comments