Lambda update function timeout
Lambda update function timeout causes timeout of a Lambda function to be updated to a specified value for a certain duration.
- It checks the performance of the application (or service) running with a new timeout.
- It also helps determine a safe overall timeout value for the function.
Usage
View fault usage
Hitting a timeout is a very common and frequent scenario we find with lambda functions that can break the service and impacts their delivery. Such scenarios can still occur despite whatever availability aids AWS provides or we determine. Getting timeout errors interrupts the flow of the given function. So this category of chaos fault helps you to build the immunity of the application undergoing any such scenarios.
Prerequisites
- Kubernetes >= 1.17
- Access to operate AWS Lambda service.
- Kubernetes secret that has AWS access configuration(key) in the
CHAOS_NAMESPACE
. A secret file looks like this:
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
cloud_config.yml: |-
# Add the cloud AWS credentials respectively
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXX
- If you change the secret key name (from
cloud_config.yml
), update theAWS_SHARED_CREDENTIALS_FILE
environment variable value onexperiment.yaml
with the same name.
Permissions required
Here is an example AWS policy to execute the fault.
View policy for the fault
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:UpdateFunctionConfiguration",
"lambda:GetFunctionConcurrency",
"lambda:GetFunction",
"lambda:DeleteFunctionConcurrency",
"lambda:PutFunctionConcurrency"
],
"Resource": "*"
}
]
}
Refer to the superset permission/policy to execute all AWS faults.
Default validations
The Lambda function should be up and running.
Fault tunables
Fault tunables
Mandatory fields
Variables | Description | Notes |
---|---|---|
FUNCTION_NAME | Function name of the target lambda function. It support single function name. | For example, test-function |
FUNCTION_TIMEOUT | Provide the value of function timeout in seconds. | The minimum value is 1s and maximum upto 15mins that is 900s |
REGION | The region name of the target lambda function | For example, us-east-2 |
Optional fields
Variables | Description | Notes |
---|---|---|
TOTAL_CHAOS_DURATION | The total time duration for chaos insertion in seconds | Defaults to 30s |
CHAOS_INTERVAL | The interval (in seconds) between successive instance termination. | Defaults to 30s |
SEQUENCE | It defines sequence of chaos execution for multiple instance | Default value: parallel. Supported: serial, parallel |
RAMP_TIME | Period to wait before and after injection of chaos in seconds | For example, 30 |
Fault examples
Common and AWS-specific tunables
Refer to the common attributes and AWS-specific tunables to tune the common tunables for all faults and aws specific tunables.
Timeout value
It can update the lambda function timeout value to a newer value by using FUNCTION_TIMEOUT
environment variable as shown below.
Use the following example to tune this:
# contains the timeout value for the lambda function
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: lambda-update-function-timeout
spec:
components:
env:
# provide the function timeout for 10seconds
- name: FUNCTION_TIMEOUT
value: '10'
# provide the function name for timeout chaos
- name: FUNCTION_NAME
value: 'chaos-function'