FaultInjectionPolicy
FaultInjectionPolicy API reference.
Proto: fault_injection_policy.proto
Package: resilience.policy.gloo.solo.io
Test the resilience of your apps by injecting delays and connection failures. Inject faults in a percentage of your requests to test how your app handles the errors. By using the policy, you can avoid deleting pods, delaying packets, or corrupting packets. Fault specification is part of a VirtualService rule.
Faults include aborts and/or delays.
- Aborts are crash failures, such as HTTP error codes or TCP connection failures.
- Delays are timing failures, such as network latency or overloaded upstreams.
Fault injection policies are applied at the Route level. For more information, see the fault injection policy guide.
Examples
Abort: The following example is for a simple fault injection abort policy with a default value for the percentage. No delay is configured.
apiVersion: resilience.policy.gloo.solo.io/v2
kind: FaultInjectionPolicy
metadata:
annotations:
cluster.solo.io/cluster: ""
name: faultinjection-basic
namespace: bookinfo
spec:
applyToRoutes:
- route:
labels:
route: ratings
config:
abort:
httpStatus: 418
Delay: The following example is for a simple fault injection delay policy with a default value for the percentage. No abort is configured.
apiVersion: resilience.policy.gloo.solo.io/v2
kind: FaultInjectionPolicy
metadata:
name: faultinjection-basic-delay
namespace: bookinfo
annotations:
cluster.solo.io/cluster: $REMOTE_CLUSTER1
spec:
applyToRoutes:
- route:
labels:
route: ratings
config:
delay:
fixedDelay: 5s
Abort and delay: The following example is for a fault injection policy that both delays and aborts requests. Delays and aborts are independent of one another. When both are set, both happen, with the delay happening first.
apiVersion: resilience.policy.gloo.solo.io/v2
kind: FaultInjectionPolicy
metadata:
name: faultinjection-basic-abort-and-delay
namespace: bookinfo
annotations:
cluster.solo.io/cluster: $REMOTE_CLUSTER1
spec:
applyToRoutes:
- route:
labels:
route: ratings
config:
abort:
httpStatus: 418
percentage: 10
delay:
percentage: 40
fixedDelay: 5s
FaultInjectionPolicyReport
The resources that the policy selects after it is successfully applied.
Field | Description |
---|---|
workspaces | (repeated FaultInjectionPolicyReport.WorkspacesEntry )The state of the resource in each workspace that receives its configuration. |
selectedRoutes | (repeated common.gloo.solo.io.RouteReference )A list of references to all routes selected by the policy. |
FaultInjectionPolicyReport.WorkspacesEntry
Field | Description |
---|---|
key | (string ) |
value | (common.gloo.solo.io.Report ) |
FaultInjectionPolicySpec
Specifications for the policy.
Field | Description |
---|---|
applyToRoutes | (repeated common.gloo.solo.io.RouteSelector )Routes to apply the policy to. If empty, the policy applies to all routes in the workspace. Configuration constraints: Only one fault injection policy can apply to a route. Subsequent policies (sorted by creation time) are ignored and put into a FAILED state. |
config | (FaultInjectionPolicySpec.Config )The details of the fault injection policy to apply to the selected routes. Implementation notes: Delays and aborts are independent of one another. When both are set, both happen, with the delay happening first. Configuration constraints: A fault injection rule must specify a delay, an abort, or both. |
FaultInjectionPolicySpec.Config
The details of the fault injection policy to apply to the selected routes.
Implementation notes: Delays and aborts are independent of one another. When both are set, both happen, with the delay happening first.
Configuration constraints: A fault injection rule must specify a delay, an abort, or both.
Field | Description |
---|---|
delay | (FaultInjectionPolicySpec.Config.Delay )Delay requests before forwarding them to the upstream service, which emulates various failures such as network issues or overloaded upstream services. |
abort | (FaultInjectionPolicySpec.Config.Abort )Abort HTTP request attempts, and return an error code to the traffic source. |
FaultInjectionPolicySpec.Config.Abort
Abort HTTP request attempts and return an error code to the traffic source, giving the impression that the upstream service is faulty.
Field | Description |
---|---|
httpStatus | (int32 )Required: The HTTP status code to use to abort the request. Configuration constraints: The status code must be in the range 200 - 599, inclusive. |
percentage | (google.protobuf.DoubleValue )Percentage of requests to be aborted. If omitted, all requests are aborted. Configuration constraints:
|
FaultInjectionPolicySpec.Config.Delay
Delay requests before forwarding them to the upstream service, which emulates various failures such as network issues or overloaded upstream services.
Field | Description |
---|---|
fixedDelay | (google.protobuf.Duration )Required: Add a delay of a fixed duration before sending the request. Configuration constraints:
|
percentage | (google.protobuf.DoubleValue )Delay only a certain percentage of requests. If omitted, all requests are delayed. Configuration constraints:
|
FaultInjectionPolicyStatus
The status of the policy after it is applied to your Gloo environment.
Field | Description |
---|---|
common | (common.gloo.solo.io.Status )The common status of the object |
numSelectedRoutes | (uint32 )The number of routes selected by the policy. |