sigs.k8s.io/cluster-api-provider-azure@v1.17.0/util/reconciler/defaults.go (about) 1 /* 2 Copyright 2020 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package reconciler 18 19 import ( 20 "time" 21 ) 22 23 const ( 24 // DefaultLoopTimeout is the default timeout for a reconcile loop (defaulted to the max ARM template duration). 25 DefaultLoopTimeout = 90 * time.Minute 26 // DefaultMappingTimeout is the default timeout for a controller request mapping func. 27 DefaultMappingTimeout = 60 * time.Second 28 // DefaultAzureServiceReconcileTimeout is the default timeout for an Azure service reconcile. 29 DefaultAzureServiceReconcileTimeout = 12 * time.Second 30 // DefaultAzureCallTimeout is the default timeout for an Azure request after which an Azure operation is considered long running. 31 DefaultAzureCallTimeout = 2 * time.Second 32 // DefaultReconcilerRequeue is the default value for the reconcile retry. 33 DefaultReconcilerRequeue = 15 * time.Second 34 // DefaultHTTP429RetryAfter is a default backoff wait time when we get a HTTP 429 response with no Retry-After data. 35 DefaultHTTP429RetryAfter = 1 * time.Minute 36 ) 37 38 // Timeouts defines the timeouts for a reconciler. 39 type Timeouts struct { 40 // Loop is the timeout for a reconcile loop (defaulted to the max ARM template duration). 41 Loop time.Duration 42 // AzureServiceReconcile is the timeout for an Azure service reconcile. 43 AzureServiceReconcile time.Duration 44 // AzureCall is the timeout for an Azure request after which an Azure operation is considered long-running. 45 AzureCall time.Duration 46 // Requeue is the value for the reconcile retry. 47 Requeue time.Duration 48 } 49 50 // DefaultedAzureCallTimeout will default the timeout if it is zero-valued. 51 func (t Timeouts) DefaultedAzureCallTimeout() time.Duration { 52 if t.AzureCall <= 0 { 53 return DefaultAzureCallTimeout 54 } 55 56 return t.AzureCall 57 } 58 59 // DefaultedAzureServiceReconcileTimeout will default the timeout if it is zero-valued. 60 func (t Timeouts) DefaultedAzureServiceReconcileTimeout() time.Duration { 61 if t.AzureServiceReconcile <= 0 { 62 return DefaultAzureServiceReconcileTimeout 63 } 64 65 return t.AzureServiceReconcile 66 } 67 68 // DefaultedReconcilerRequeue will default the timeout if it is zero-valued. 69 func (t Timeouts) DefaultedReconcilerRequeue() time.Duration { 70 if t.Requeue <= 0 { 71 return DefaultReconcilerRequeue 72 } 73 74 return t.Requeue 75 } 76 77 // DefaultedLoopTimeout will default the timeout if it is zero-valued. 78 func (t Timeouts) DefaultedLoopTimeout() time.Duration { 79 if t.Loop <= 0 { 80 return DefaultLoopTimeout 81 } 82 83 return t.Loop 84 }