mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Use glog instead of printing to stderr.
This commit is contained in:
parent
c9676aa2d5
commit
602f7d8112
@ -26,7 +26,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
kube_client "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubecfg"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
@ -52,10 +51,6 @@ var (
|
||||
www = flag.String("www", "", "If -proxy is true, use this directory to serve static files")
|
||||
)
|
||||
|
||||
var (
|
||||
pollPeriod = 20 * time.Second
|
||||
)
|
||||
|
||||
func usage() {
|
||||
fmt.Fprint(os.Stderr, `usage: kubecfg -h [-c config/file.json] [-p :,..., :] <method>
|
||||
|
||||
@ -151,24 +146,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func doVerb(s *kube_client.Client, r *kube_client.Request) kube_client.Result {
|
||||
for {
|
||||
r = r.PollPeriod(0)
|
||||
result := r.Do()
|
||||
if result.Error() == nil {
|
||||
return result
|
||||
}
|
||||
if statusErr, ok := result.Error().(*kube_client.StatusErr); ok && statusErr.Status.Status == api.StatusWorking {
|
||||
fmt.Fprintf(os.Stderr, "Waiting for completion of /operations/%s\n", statusErr.Status.Details)
|
||||
time.Sleep(pollPeriod)
|
||||
pollOp := s.PollFor(statusErr.Status.Details)
|
||||
r = pollOp
|
||||
continue
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to execute an API request
|
||||
func executeAPIRequest(method string, s *kube_client.Client) bool {
|
||||
parseStorage := func() string {
|
||||
@ -198,7 +175,7 @@ func executeAPIRequest(method string, s *kube_client.Client) bool {
|
||||
if method == "create" || method == "update" {
|
||||
r.Body(readConfig(parseStorage()))
|
||||
}
|
||||
result := doVerb(s, r)
|
||||
result := r.Do()
|
||||
obj, err := result.Get()
|
||||
if err != nil {
|
||||
glog.Fatalf("Got request error: %v\n", err)
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// Server contains info locating a kubernetes api server.
|
||||
@ -216,6 +217,7 @@ func (r *Request) Do() Result {
|
||||
if err != nil {
|
||||
if statusErr, ok := err.(*StatusErr); ok {
|
||||
if statusErr.Status.Status == api.StatusWorking && r.pollPeriod != 0 {
|
||||
glog.Infof("Waiting for completion of /operations/%s", statusErr.Status.Details)
|
||||
time.Sleep(r.pollPeriod)
|
||||
// Make a poll request
|
||||
pollOp := r.c.PollFor(statusErr.Status.Details).PollPeriod(r.pollPeriod)
|
||||
|
Loading…
Reference in New Issue
Block a user