Use glog instead of printing to stderr.

This commit is contained in:
Yuki Yugui Sonoda 2014-07-09 14:35:58 +09:00
parent c9676aa2d5
commit 602f7d8112
2 changed files with 3 additions and 24 deletions

View File

@ -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)

View File

@ -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)