Skip to content

Commit 8e76abd

Browse files
rahulaiteljohnson92
authored andcommitted
allow configuring timeout value for linodeclient
1 parent a857b88 commit 8e76abd

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

.github/workflows/e2e-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ jobs:
135135
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
136136
LINODE_MACHINE_TYPE: g6-standard-2
137137
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/gha-clusterctl-config.yaml
138+
LINODE_CLIENT_TIMEOUT: 30
138139
run: make e2etest
139140

140141
- name: cleanup stale clusters

Tiltfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ for resource in manager_yaml:
196196
resource["spec"]["template"]["spec"].pop("securityContext")
197197
for container in resource["spec"]["template"]["spec"]["containers"]:
198198
container.pop("securityContext")
199+
timeout_value = os.getenv("LINODE_CLIENT_TIMEOUT")
200+
if timeout_value:
201+
env = container.setdefault("env", [])
202+
env.append({
203+
"name": "LINODE_CLIENT_TIMEOUT",
204+
"value": timeout_value
205+
})
199206

200207
k8s_yaml(encode_yaml_stream(manager_yaml))
201208

cmd/main.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,23 @@ func validateEnvironment() (linodeConfig, dnsConfig scope.ClientConfig) {
178178
linodeDNSToken = linodeToken
179179
}
180180

181-
return scope.ClientConfig{Token: linodeToken},
182-
scope.ClientConfig{Token: linodeDNSToken, BaseUrl: linodeDNSURL, RootCertificatePath: linodeDNSCA}
181+
linodeClientTimeout := 0
182+
if raw, ok := os.LookupEnv("LINODE_CLIENT_TIMEOUT"); ok {
183+
if timeout, err := strconv.Atoi(raw); timeout > 0 && err == nil {
184+
linodeClientTimeout = timeout
185+
setupLog.Info("LINODE_CLIENT_TIMEOUT set", "timeout", linodeClientTimeout)
186+
} else {
187+
setupLog.Error(fmt.Errorf("invalid LINODE_CLIENT_TIMEOUT value: %s", raw), "using default timeout")
188+
}
189+
}
190+
191+
linodeConfig = scope.ClientConfig{Token: linodeToken}
192+
dnsConfig = scope.ClientConfig{Token: linodeDNSToken, BaseUrl: linodeDNSURL, RootCertificatePath: linodeDNSCA}
193+
if linodeClientTimeout > 0 {
194+
linodeConfig.Timeout = time.Duration(linodeClientTimeout) * time.Second
195+
dnsConfig.Timeout = time.Duration(linodeClientTimeout) * time.Second
196+
}
197+
return linodeConfig, dnsConfig
183198
}
184199

185200
// setupManager initializes and returns a new manager instance with the provided configurations.

docs/src/topics/troubleshooting.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,20 @@ You can also see which images have cloud-init support via the [linode-cli](https
7373

7474
Please refer to the [Troubleshoot Metadata and Cloud-Init section of the Linode Metadata Service Guide](https://www.linode.com/docs/products/compute/compute-instances/guides/metadata/?tabs=linode-api%2Cmacos#troubleshoot-metadata-and-cloud-init).
7575

76+
## Increasing Linode API timeout values
77+
If the Linode API is slow to provision resources and you need to increase the timeout for API calls, you can set the LINODE_CLIENT_TIMEOUT environment variable to a higher value (in seconds). CAPL will automatically use this value when interacting with the Linode API.
78+
79+
```bash
80+
apiVersion: apps/v1
81+
kind: Deployment
82+
metadata:
83+
name: capl-controller-manager
84+
spec:
85+
template:
86+
spec:
87+
containers:
88+
- name: manager
89+
env:
90+
- name: LINODE_CLIENT_TIMEOUT
91+
value: "60" # Timeout in seconds
92+
```

0 commit comments

Comments
 (0)