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

pkg/checkpoint: Try kubelet secureClient, fallback to read-only #1027

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/checkpoint/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *checkpointer) run() {
for {
time.Sleep(defaultPollingFrequency)

// We must use both the :10255/pods endpoint and CRI shim, because /pods
// We must use both the kubelet /pods endpoint and CRI shim, because /pods
// endpoint could have stale data. The /pods endpoint will only show the last cached
// status which has successfully been written to an apiserver. However, if there is
// no apiserver, we may get stale state (e.g. saying pod is running, when it really is
Expand Down
11 changes: 8 additions & 3 deletions pkg/checkpoint/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package checkpoint

import (
"fmt"
"time"

"github.com/golang/glog"
"k8s.io/api/core/v1"
Expand Down Expand Up @@ -49,9 +50,13 @@ func newKubeletClient(config *rest.Config) (*kubeletClient, error) {
// localParentPods will retrieve all pods from kubelet api that are parents & should be checkpointed
func (k *kubeletClient) localParentPods() map[string]*v1.Pod {
podList := new(v1.PodList)
if err := k.insecureClient.Get().AbsPath("/pods/").Do().Into(podList); err != nil {
// Assume there are no local parent pods.
glog.Errorf("failed to list local parent pods, assuming none are running: %v", err)
timeout := 15 * time.Second
if err := k.secureClient.Get().AbsPath("/pods/").Timeout(timeout).Do().Into(podList); err != nil {
glog.Errorf("failed to secure list local parent pods, fallback to insecure: %v", err)
if err := k.insecureClient.Get().AbsPath("/pods/").Timeout(timeout).Do().Into(podList); err != nil {
// Assume there are no local parent pods.
glog.Errorf("failed to insecure list local parent pods, assuming none are running: %v", err)
}
}
return podListToParentPods(podList)
}