@@ -21,14 +21,11 @@ import (
21
21
"time"
22
22
23
23
"github.com/pkg/errors"
24
- "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
25
24
"k8s.io/apimachinery/pkg/util/wait"
26
- "k8s.io/client-go/rest"
27
25
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/config"
28
26
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/repository"
29
27
yaml "sigs.k8s.io/cluster-api/cmd/clusterctl/client/yamlprocessor"
30
28
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
31
- "sigs.k8s.io/controller-runtime/pkg/client"
32
29
)
33
30
34
31
const (
@@ -61,15 +58,15 @@ type Client interface {
61
58
// Proxy return the Proxy used for operating objects in the management cluster.
62
59
Proxy () Proxy
63
60
64
- // CertManager returns a CertManagerClient that can be user for
61
+ // CertManager returns a CertManagerClient that can be used for
65
62
// operating the cert-manager components in the cluster.
66
63
CertManager () CertManagerClient
67
64
68
- // ProviderComponents returns a ComponentsClient object that can be user for
65
+ // ProviderComponents returns a ComponentsClient object that can be used for
69
66
// operating provider components objects in the management cluster (e.g. the CRDs, controllers, RBAC).
70
67
ProviderComponents () ComponentsClient
71
68
72
- // ProviderInventory returns a InventoryClient object that can be user for
69
+ // ProviderInventory returns a InventoryClient object that can be used for
73
70
// operating provider inventory stored in the management cluster (e.g. the list of installed providers/versions).
74
71
ProviderInventory () InventoryClient
75
72
@@ -219,30 +216,6 @@ func newClusterClient(kubeconfig Kubeconfig, configClient config.Client, options
219
216
return client
220
217
}
221
218
222
- // Proxy defines a client proxy interface.
223
- type Proxy interface {
224
- // GetConfig returns the rest.Config
225
- GetConfig () (* rest.Config , error )
226
-
227
- // CurrentNamespace returns the namespace from the current context in the kubeconfig file
228
- CurrentNamespace () (string , error )
229
-
230
- // ValidateKubernetesVersion returns an error if management cluster version less than minimumKubernetesVersion
231
- ValidateKubernetesVersion () error
232
-
233
- // NewClient returns a new controller runtime Client object for working on the management cluster
234
- NewClient () (client.Client , error )
235
-
236
- // ListResources returns all the Kubernetes objects with the given labels existing the listed namespaces.
237
- ListResources (labels map [string ]string , namespaces ... string ) ([]unstructured.Unstructured , error )
238
-
239
- // GetContexts returns the list of contexts in kubeconfig which begin with prefix.
240
- GetContexts (prefix string ) ([]string , error )
241
-
242
- // GetResourceNames returns the list of resource names which begin with prefix.
243
- GetResourceNames (groupVersion , kind string , options []client.ListOption , prefix string ) ([]string , error )
244
- }
245
-
246
219
// retryWithExponentialBackoff repeats an operation until it passes or the exponential backoff times out.
247
220
func retryWithExponentialBackoff (opts wait.Backoff , operation func () error ) error {
248
221
log := logf .Log
@@ -291,6 +264,20 @@ func newConnectBackoff() wait.Backoff {
291
264
}
292
265
}
293
266
267
+ // newShortConnectBackoff creates a new API Machinery backoff parameter set suitable for use when clusterctl connect to a cluster.
268
+ // Preferred over newConnectBackoff() only when used to perform quick checks to check if a cluster is reachable.
269
+ func newShortConnectBackoff () wait.Backoff {
270
+ // Return a exponential backoff configuration which returns durations for a total time of ~5s.
271
+ // Example: 0, .25s, .6s, 1.2, 2.1s, 3.4s, 5.5s.
272
+ // Jitter is added as a random fraction of the duration multiplied by the jitter factor.
273
+ return wait.Backoff {
274
+ Duration : 250 * time .Millisecond ,
275
+ Factor : 1.5 ,
276
+ Steps : 7 ,
277
+ Jitter : 0.1 ,
278
+ }
279
+ }
280
+
294
281
// newReadBackoff creates a new API Machinery backoff parameter set suitable for use with clusterctl read operations.
295
282
func newReadBackoff () wait.Backoff {
296
283
// Return a exponential backoff configuration which returns durations for a total time of ~15s.
0 commit comments