Skip to content

Commit

Permalink
pretty output deploy opts
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Oct 19, 2018
1 parent 923940a commit 0f27a31
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
6 changes: 4 additions & 2 deletions cluster/calcium/create_container.go
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand All @@ -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
}

Expand Down
10 changes: 9 additions & 1 deletion cluster/calcium/resource.go
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"sort"

"github.com/sanity-io/litter"

log "github.com/sirupsen/logrus"

"github.com/projecteru2/core/cluster"
Expand Down Expand Up @@ -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)
}

Expand Down
17 changes: 9 additions & 8 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions glide.yaml
Expand Up @@ -64,3 +64,5 @@ import:
- expfmt
- model
- package: github.com/prometheus/procfs
- package: github.com/sanity-io/litter
version: v1.1.0

0 comments on commit 0f27a31

Please sign in to comment.