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

Commit

Permalink
Merge pull request #1027 from dghubble/checkpointer-try-secure
Browse files Browse the repository at this point in the history
pkg/checkpoint: Try kubelet secureClient, fallback to read-only
  • Loading branch information
k8s-ci-robot authored Nov 26, 2018
2 parents 49dae0a + 55f0b95 commit 83e25e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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)
}

0 comments on commit 83e25e5

Please sign in to comment.