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:
apiVersion: chaos-mesh.org/v1alpha1
kind: TimeChaos
metadata:
name: time-shift-example
namespace: chaos-testing
spec:
mode: one
selector:
labelSelectors:
'app.kubernetes.io/component': 'pd'
timeOffset: '-10m100ns'
clockIds:
- CLOCK_REALTIME
containerNames:
- pd
duration: '10s'
scheduler:
cron: '@every 15s'
For more sample files, see examples. You can edit them as needed.
Description:
- 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 ofclock_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.
Limitation
- 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.
当前内容版权归 Chaos Mesh 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Chaos Mesh .