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

Commit 256d7ea

Browse files
committed
Revert "checkpoint: explicitly load checkpoint manifests"
This reverts commit 17e8cbc.
1 parent ad7c001 commit 256d7ea

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

cmd/checkpoint/main.go

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"io/ioutil"
88
"net/http"
99
"os"
10-
"path"
1110
"path/filepath"
1211
"strings"
1312
"time"
@@ -45,19 +44,13 @@ var (
4544
func main() {
4645
flag.Set("logtostderr", "true")
4746
defer glog.Flush()
48-
checkpoints, err := getCheckpointManifests()
49-
if err != nil {
50-
glog.Fatalf("failed to load existing checkpoint manifests: %v", err)
51-
}
5247
glog.Info("begin pods checkpointing...")
53-
run(kubeAPIServer, tempAPIServer, api.NamespaceSystem, checkpoints)
48+
run(kubeAPIServer, tempAPIServer, api.NamespaceSystem)
5449
}
5550

56-
func run(actualPodName, tempPodName, namespace string, checkpoints map[string]struct{}) {
51+
func run(actualPodName, tempPodName, namespace string) {
5752
client := newAPIClient()
5853
for {
59-
_, checkpointed := checkpoints[checkpointManifest(tempPodName)]
60-
6154
var podList v1.PodList
6255
if err := json.Unmarshal(getPodsFromKubeletAPI(), &podList); err != nil {
6356
glog.Fatal(err)
@@ -72,18 +65,17 @@ func run(actualPodName, tempPodName, namespace string, checkpoints map[string]st
7265
glog.Error(err)
7366
}
7467
case isPodRunning(podList, client, actualPodName, namespace):
75-
glog.Infof("actual pod %v found, creating checkpoint pod manifest", actualPodName)
68+
glog.Infof("actual pod %v found, creating temp pod manifest", actualPodName)
7669
// The actual is running. Let's snapshot the pod,
7770
// clean it up a bit, and then save it to the ignore path for
7871
// later use.
7972
checkpointPod := createCheckpointPod(podList, actualPodName, namespace)
8073
convertSecretsToVolumeMounts(client, &checkpointPod)
8174
writeManifest(checkpointPod, tempPodName)
82-
checkpoints[checkpointManifest(tempPodName)] = struct{}{}
83-
glog.Infof("finished creating checkpoint pod %v manifest at %s\n", tempPodName, checkpointManifest(tempPodName))
75+
glog.Infof("finished creating temp pod %v manifest at %s\n", tempPodName, checkpointManifest(tempPodName))
8476

85-
case checkpointed:
86-
glog.Info("no actual pod running, installing checkpoint pod static manifest")
77+
default:
78+
glog.Info("no actual pod running, installing temp pod static manifest")
8779
b, err := ioutil.ReadFile(checkpointManifest(tempPodName))
8880
if err != nil {
8981
glog.Error(err)
@@ -260,20 +252,3 @@ func activeManifest(name string) string {
260252
func checkpointManifest(name string) string {
261253
return filepath.Join(ignorePath, name+".json")
262254
}
263-
264-
func getCheckpointManifests() (map[string]struct{}, error) {
265-
checkpoints := make(map[string]struct{})
266-
267-
fs, err := ioutil.ReadDir(ignorePath)
268-
if err != nil {
269-
if os.IsNotExist(err) {
270-
return checkpoints, nil
271-
}
272-
return nil, err
273-
}
274-
for _, f := range fs {
275-
glog.Infof("found checkpoint pod manifests %v", f.Name())
276-
checkpoints[path.Join(ignorePath, f.Name())] = struct{}{}
277-
}
278-
return checkpoints, nil
279-
}

0 commit comments

Comments
 (0)