Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 346f38e

Browse files
committed
checkpointer: add test case asserting behavior.
The checkpointer will activate a checkpoint if the local kubelet API parent exists but the CRI shim doesn't report it running. We may want to change this later, but this is the current behavior. Also make the stop and remove orders stable to make the tests consistently pass and also because why not.
1 parent bef27c1 commit 346f38e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/checkpoint/process.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io/ioutil"
66
"os"
7+
"sort"
78
"time"
89

910
"github.com/golang/glog"
@@ -143,6 +144,7 @@ func (cs *checkpoints) process(now time.Time, apiAvailable bool, localRunningPod
143144
stops = append(stops, name)
144145
}
145146
}
147+
sort.Strings(stops) // Ensure stable ordering.
146148
stops = append(stops, cs.selfCheckpoint.name)
147149
return starts, stops, removes
148150
case remove:
@@ -154,6 +156,7 @@ func (cs *checkpoints) process(now time.Time, apiAvailable bool, localRunningPod
154156
delete(cs.checkpoints, name)
155157
}
156158
}
159+
sort.Strings(removes) // Ensure stable ordering.
157160
removes = append(removes, cs.selfCheckpoint.name)
158161
delete(cs.checkpoints, cs.selfCheckpoint.name)
159162
cs.selfCheckpoint = nil

pkg/checkpoint/process_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ func TestProcess(t *testing.T) {
5555
apiParents: map[string]*v1.Pod{"AA": {}},
5656
expectStart: []string{"AA"},
5757
},
58+
{
59+
desc: "Inactive checkpoint and only api and kubelet parents: should start",
60+
inactiveCheckpoints: map[string]*v1.Pod{"AA": {}},
61+
apiParents: map[string]*v1.Pod{"AA": {}},
62+
localParents: map[string]*v1.Pod{"AA": {}},
63+
expectStart: []string{"AA"},
64+
},
5865
{
5966
desc: "Active checkpoint and no local running: no change",
6067
activeCheckpoints: map[string]*v1.Pod{"AA": {}},

0 commit comments

Comments
 (0)