Pod JVM modify return
Pod JVM modify return modifies the return value of a method in a Java application executing on a Kubernetes pod, for a specific duration.
tip
JVM chaos faults use the Byteman utility to inject chaos faults into the JVM.
Use cases
Pod JVM modify return:
- Helps test the functionality of snippets of code by replacing specific portions of the request or response body to simulate different scenarios and validate how your application handles different data variations.
- Helps obscure or redact personally identifiable information (PII), such as email addresses or phone numbers, before logging or transmitting the data for security and privacy compliance.
- Determines how efficiently an application recovers and returns to normalcy.
Mandatory tunables
Tunable | Description | Notes |
---|---|---|
CLASS | Specify as packageName.className that specifies the class in which you define the target method. | For example, org.framework.appName.system.WelcomeController . |
METHOD | The method whose return value is modified. | For example, Welcome . |
RETURN | The modified return value of the method. | For example, "modified string" . |
Optional tunables
Tunable | Description | Notes |
---|---|---|
TOTAL_CHAOS_DURATION | Duration through which chaos is injected into the target resource. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. | Default: 30s . Examples: 1m25s , 1h3m2s , 1h3s . For more information, go to duration of the chaos. |
POD_AFFECTED_PERC | Percentage of total pods to target. Provide numeric values. | Default: 0 (corresponds to 1 replica). For more information, go to pods affected percentage |
JAVA_HOME | Path to the Java installation directory. | For example, /tmp/dir/jdk. |
BYTEMAN_PORT | Port used by the Byteman agent. | Default: 9091 . |
CONTAINER_RUNTIME | Container runtime interface for the cluster | Default: containerd. Support values: docker, containerd and crio. For more information, go to container runtime. |
SOCKET_PATH | Path of the containerd or crio or docker socket file. | Default: /run/containerd/containerd.sock . For more information, go to socket path. |
RAMP_TIME | Period to wait before and after injecting chaos. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. | Default: 0s . Examples: 1m25s , 1h3m2s , 1h3s . For more information, go to ramp time. |
SEQUENCE | Sequence of chaos execution for multiple target pods. | Default: parallel. Supports serial and parallel. For more information, go to sequence of chaos execution. |
TARGET_CONTAINER | Name of the container subject to API header modification. | None. For more information, go to target specific container |
TARGET_PODS | Comma-separated list of application pod names subject to pod HTTP modify body. | If not provided, the fault selects target pods randomly based on provided appLabels. For more information, go to target specific pods. |
NODE_LABEL | Node label used to filter the target node if TARGET_NODE environment variable is not set. | It is mutually exclusive with the TARGET_NODE environment variable. If both are provided, the fault uses TARGET_NODE . For more information, go to node label. |
LIB_IMAGE | Image used to inject chaos. | Default: harness/chaos-go-runner:main-latest . For more information, go to image used by the helper pod. |
Parameters
The following YAML snippet illustrates the use of these tunables:
apiVersion: litmuschaos.io/v1alpha1
kind: KubernetesChaosExperiment
metadata:
name: pod-jvm-modify-return
namespace: hce
env:
- name: TOTAL_CHAOS_DURATION
value: "60"
- name: POD_AFFECTED_PERCENTAGE
value: ""
- name: BYTEMAN_PORT
value: "9091"
- name: JAVA_HOME
value: ""
- name: METHOD #mandatory
value: ""
- name: CLASS #mandatory
value: ""
- name: RETURN #mandatory
value: modifiedValue
- name: CONTAINER_RUNTIME
value: containerd
- name: SOCKET_PATH
value: /run/containerd/containerd.sock
- name: LIB_IMAGE
value: docker.io/harness/chaos-ddcr-faults:1.49.2
- name: RAMP_TIME
value: ""
- name: SEQUENCE
value: parallel
- name: TARGET_CONTAINER
value: ""
- name: TARGET_PODS
value: ""
- name: NODE_LABEL
value: ""