From 0f27a31898ca5c382cb702cf127629e9d60c3f07 Mon Sep 17 00:00:00 2001 From: CMGS Date: Fri, 19 Oct 2018 10:59:03 +0800 Subject: [PATCH] pretty output deploy opts --- cluster/calcium/create_container.go | 6 ++++-- cluster/calcium/resource.go | 10 +++++++++- glide.lock | 17 +++++++++-------- glide.yaml | 2 ++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/cluster/calcium/create_container.go b/cluster/calcium/create_container.go index 4b4f5f54a..3bcc56cf4 100644 --- a/cluster/calcium/create_container.go +++ b/cluster/calcium/create_container.go @@ -17,6 +17,7 @@ import ( "github.com/projecteru2/core/metrics" "github.com/projecteru2/core/types" "github.com/projecteru2/core/utils" + "github.com/sanity-io/litter" log "github.com/sirupsen/logrus" ) @@ -28,7 +29,8 @@ func (c *Calcium) CreateContainer(ctx context.Context, opts *types.DeployOptions log.Errorf("[CreateContainer %s] Error during GetPod for %s: %v", opts.ProcessIdent, opts.Podname, err) return nil, err } - log.Infof("[CreateContainer] Creating container with options: %v", opts) + log.Infof("[CreateContainer %s] Creating container with options:", opts.ProcessIdent) + litter.Dump(opts) // 4194304 Byte = 4 MB, docker 创建容器的内存最低标准 if opts.Memory < minMemory { @@ -54,7 +56,7 @@ func (c *Calcium) createContainer(ctx context.Context, opts *types.DeployOptions // 通过 Processing 状态跟踪达成这个 RFC 了 18 Oct, 2018 nodesInfo, err := c.allocResource(ctx, opts, pod.Favor) if err != nil { - log.Errorf("[createContainer] Error during alloc resource with opts %v: %v", opts, err) + log.Errorf("[createContainer] Error during alloc resource: %v", err) return ch, err } diff --git a/cluster/calcium/resource.go b/cluster/calcium/resource.go index 61a6b88b7..aa87c71a6 100644 --- a/cluster/calcium/resource.go +++ b/cluster/calcium/resource.go @@ -4,6 +4,8 @@ import ( "context" "sort" + "github.com/sanity-io/litter" + log "github.com/sirupsen/logrus" "github.com/projecteru2/core/cluster" @@ -85,7 +87,13 @@ func (c *Calcium) allocResource(ctx context.Context, opts *types.DeployOptions, return nil, err } } - log.Debugf("[allocResource] result %v", nodesInfo) + go func() { + log.Info("[allocResource] result") + for _, nodeInfo := range nodesInfo { + s := litter.Sdump(nodeInfo.CPUPlan) + log.Infof("[allocResource] deploy %d to %s \n%s", nodeInfo.Deploy, nodeInfo.Name, s) + } + }() return nodesInfo, c.bindProcessStatus(ctx, opts, nodesInfo) } diff --git a/glide.lock b/glide.lock index afac79eee..d7a571149 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 44a405ea33bb9e89bd4d3445a04b86b42464555742634273e1e25eace9a09c3e -updated: 2018-09-12T14:10:03.779929+08:00 +hash: 3fbc0d6fa78d5474ddd859aa337161259ab8b9618b9a01aba1440b648a0cb4d6 +updated: 2018-10-19T10:40:06.16545+08:00 imports: - name: github.com/Azure/go-ansiterm version: d6e3b3328b783f23731bc4d058875b0371ff8109 @@ -18,7 +18,7 @@ imports: subpackages: - pathdriver - name: github.com/coreos/etcd - version: fca8add78a9d926166eb739b8e4a124434025ba3 + version: 27fc7e2296f506182f58ce846e48f36b34fe6842 subpackages: - auth/authpb - client @@ -53,7 +53,7 @@ imports: - registry/storage/cache - registry/storage/cache/memory - name: github.com/docker/docker - version: 738994f77d0c0332455ebfeec0858c3feb6d6994 + version: f7e5154f37a45dc2e576abbef404f3032e9823bf subpackages: - api - api/types @@ -160,8 +160,10 @@ imports: version: a6e9df898b1336106c743392c48ee0b71f5c4efa subpackages: - xfs +- name: github.com/sanity-io/litter + version: ae543b7ba8fd6af63e4976198f146e1348ae53c1 - name: github.com/sirupsen/logrus - version: 3e01752db0189b9157070a0e1668a620f9a85da2 + version: ad15b42461921f1fb3529b058c6786c6a45d5162 - name: github.com/stretchr/objx version: 0ab728f62c7f6fcd754334f7931c2dd659dce1d1 - name: github.com/stretchr/testify @@ -181,7 +183,6 @@ imports: version: 66aacef3dd8a676686c7ae3716979581e8b03c47 subpackages: - context - - context/ctxhttp - http2 - http2/hpack - idna @@ -190,7 +191,7 @@ imports: - proxy - trace - name: golang.org/x/sys - version: d0be0721c37eeb5299f245a996a483160fc36940 + version: ebfc5b4631820b793c9010c87fd8fef0f39eb082 subpackages: - unix - windows @@ -206,7 +207,7 @@ imports: subpackages: - googleapis/rpc/status - name: google.golang.org/grpc - version: 9cc4fdbde2304827ffdbc7896f49db40c5536600 + version: 39444b99c097c9f53536ad8f16cd9f0288c7f695 subpackages: - balancer - balancer/base diff --git a/glide.yaml b/glide.yaml index a21810cdb..a509b4ff0 100644 --- a/glide.yaml +++ b/glide.yaml @@ -64,3 +64,5 @@ import: - expfmt - model - package: github.com/prometheus/procfs +- package: github.com/sanity-io/litter + version: v1.1.0