Version: 1.0.3

TimeChaos Experiment

This document describe how to add TimeChaos experiments in Chaos Mesh.

TimeChaos is used to modify the return value of clock_gettime, which causes time offset on Go's time.Now() and Rust std's std::time::Instant::now() etc.

Configuration file#

Below is a sample TimeChaos configuration file:

kind: TimeChaos
name: time-shift-example
namespace: chaos-testing
mode: one
'': 'pd'
timeOffset: '-10m100ns'
- pd
duration: '10s'
cron: '@every 15s'

For more sample files, see examples. You can edit them as needed.


  • mode defines the mode to select pods.
  • selector specifies the target pods for chaos injection. For more details, see Define the Scope of Chaos Experiment.
  • timeOffset specifies the time offset. It is a duration string with specified unit, such as 300ms, -1.5h. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
  • clockIds defines all affected clk_id. clk_id refers to the first argument of clock_gettime call. For most application, CLOCK_REALTIME is enough.
  • containerNames selects affected containers' names. If not set, all containers will be injected.
  • duration defines the duration for each chaos experiment. In the sample file above, the time chaos lasts for 10 seconds.
  • scheduler defines the scheduler rules for the running time of the chaos experiment. For more rule information, see robfig/cron.


  • Time modification can only be injected into the main process of container.
  • Time chaos has no effect on pure system call clock_gettime.
  • All injected vDSO calls use pure system calls to get the real time, so clock-related function calls can be much slower.