Skip to content

Commit d5f9e52

Browse files
authored
Closes #748. Pad the injector pod durations so they usually complete … (#779)
* Closes #748. Pad the injector pod durations so they usually complete later than the chaos-controller
1 parent 572f91f commit d5f9e52

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

services/chaospod.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,11 @@ func (m *chaosPodService) GenerateChaosPodOfDisruption(disruption *chaosv1beta1.
310310
// to give time for cleaning
311311
activeDeadlineSeconds := int64(disruption.RemainingDuration().Seconds()) + 10
312312

313+
// It can cause abnormalities in the status of a Disruption if injector pods consider themselves complete in the ~second before the chaos-controller believes the disruption is complete.
314+
// To avoid making our termination state machine logic more complicated, we will pad the injector pod duration by two seconds.
315+
// See https://github.com/DataDog/chaos-controller/issues/748
313316
args = append(args,
314-
"--deadline", time.Now().Add(disruption.RemainingDuration()).Format(time.RFC3339))
317+
"--deadline", time.Now().Add(chaostypes.InjectorPadDuration).Add(disruption.RemainingDuration()).Format(time.RFC3339))
315318

316319
chaosPod = corev1.Pod{
317320
ObjectMeta: metav1.ObjectMeta{

services/chaospod_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ var _ = Describe("Chaos Pod Service", func() {
728728
args.NotInjectedBefore = notInjectedBefore
729729

730730
expectedArgs = args.CreateCmdArgs(subSpec.GenerateArgs())
731-
expectedArgs = append(expectedArgs, "--deadline", time.Now().Add(disruption.RemainingDuration()).Format(time.RFC3339))
731+
expectedArgs = append(expectedArgs, "--deadline", time.Now().Add(chaostypes.InjectorPadDuration).Add(disruption.RemainingDuration()).Format(time.RFC3339))
732732

733733
// Action
734734
chaosPods, err = chaosPodService.GenerateChaosPodsOfDisruption(&disruption, DefaultTargetName, DefaultTargetNodeName, targetContainers, DefaultTargetPodIp)

types/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ const (
125125
ChaosPodFinalizer = finalizerPrefix + "/chaos-pod"
126126

127127
PulsingDisruptionMinimumDuration = 500 * time.Millisecond
128+
// InjectorPadDuration is the length of time we extend the injector's duration on top of the disruption's duration,
129+
// in order to ensure the manager stops the disruption prior to the injectors dying
130+
InjectorPadDuration = 2 * time.Second
128131

129132
// InjectorCgroupClassID is linked to the TC tree in the injector network disruption.
130133
// Also used in the DNS Disruption to allow combined Network + DNS Disruption

0 commit comments

Comments
 (0)