Skip to main content

Pod JVM method exception

Pod JVM method exception injects chaos into a Java application executing in a Kubernetes pod by invoking an exception.

tip

JVM chaos faults use the Byteman utility to inject chaos faults into the JVM.

Pod JVM method exception

Use cases

Pod JVM method exception:

  • Determines the performance and resilience of an application (or service) on encountering exceptions.
  • Determines how efficiently an application recovers the services.

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. For more information, go to class name.
EXCEPTION The exception you want to throw from the target method. For example, NullPointerException("Something went wrong!"). For more information, go to exception name.
METHOD The method to which exception is applied. For example, Welcome. For more information, go to method name.

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-method-exception
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: welcome
- name: CLASS #mandatory
value: org.framework.appName.system.WelcomeController
- name: EXCEPTION #mandatory
value: "NullPointerException("Something went wrong!")"
- 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: ""