Skip to content

Commit

Permalink
fix makefile, show container meta if container not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Jun 4, 2019
1 parent f0fb6c1 commit e061e0d
Show file tree
Hide file tree
Showing 9 changed files with 435 additions and 440 deletions.
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ grpc:
deps:
env GO111MODULE=on go mod download
env GO111MODULE=on go mod vendor
# fix mock docker client bug, see https://github.com/moby/moby/pull/34383 [docker 17.05.0-ce]
sed -i.bak "143s/\*http.Transport/http.RoundTripper/" ./vendor/github.com/docker/docker/client/client.go

binary:
go build -ldflags "$(GO_LDFLAGS)" -a -tags "netgo osusergo" -installsuffix netgo -o eru-core

build: deps binary

test: deps
# fix mock docker client bug, see https://github.com/moby/moby/pull/34383 [docker 17.05.0-ce]
sed -i.bak "143s/\*http.Transport/http.RoundTripper/" ./vendor/github.com/docker/docker/client/client.go
# fix fucking etcd bug
sudo rm -fr $(GOPATH)/pkg/mod/github.com/coreos/[email protected]+incompatible/client/keys.generated.go
rm -rf vendor/github.com/coreos/etcd/client/keys.generated.go
go vet `go list ./... | grep -v '/vendor/' | grep -v '/tools'`
go test -cover ./utils/... ./types/... ./store/etcdv3/... ./scheduler/complex/... ./source/common/... ./lock/etcdlock/... ./auth/simple/... ./cluster/calcium/...

Expand Down
5 changes: 1 addition & 4 deletions cluster/calcium/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"fmt"
"sort"

"github.com/sanity-io/litter"

log "github.com/sirupsen/logrus"

"github.com/projecteru2/core/cluster"
Expand Down Expand Up @@ -140,8 +138,7 @@ func (c *Calcium) doAllocResource(ctx context.Context, opts *types.DeployOptions
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)
log.Infof("[allocResource] deploy %d to %s", nodeInfo.Deploy, nodeInfo.Name)
}
}()
return nodesInfo, c.doBindProcessStatus(ctx, opts, nodesInfo)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/codegangsta/cli v1.20.0
github.com/containerd/continuity v0.0.0-20180612233548-246e49050efd // indirect
github.com/coreos/bbolt v1.3.1-coreos.6 // indirect
github.com/coreos/etcd v3.3.10+incompatible
github.com/coreos/etcd v3.3.13+incompatible
github.com/coreos/go-semver v0.2.0 // indirect
github.com/coreos/go-systemd v0.0.0-20170731111925-d21964639418 // indirect
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf // indirect
Expand Down
36 changes: 5 additions & 31 deletions go.sum

Large diffs are not rendered by default.

523 changes: 266 additions & 257 deletions rpc/gen/core.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions rpc/gen/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ message Container {
string image = 11;
bytes inspect = 12;
bytes status_data = 13;
bool verification = 14;
}

message ContainerDeployedOptions {
Expand Down
243 changes: 125 additions & 118 deletions rpc/gen/core_pb2.py

Large diffs are not rendered by default.

56 changes: 33 additions & 23 deletions rpc/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,40 +335,50 @@ func toRPCContainers(ctx context.Context, containers []*types.Container, labels
}

func toRPCContainer(ctx context.Context, c *types.Container) (*pb.Container, error) {
verification := true
info, err := c.Inspect(ctx)
if err != nil {
return nil, err
// return nil, err
verification = false
}

meta := utils.DecodeMetaInLabel(info.Labels)
publish := map[string]string{}
if info.Networks != nil && info.Running {
publish = utils.EncodePublishInfo(
utils.MakePublishInfo(info.Networks, meta.Publish),
)
}
inspectData := []byte{}
image := ""
labels := map[string]string{}
if verification {
meta := utils.DecodeMetaInLabel(info.Labels)
if info.Networks != nil && info.Running {
publish = utils.EncodePublishInfo(
utils.MakePublishInfo(info.Networks, meta.Publish),
)
}

bytes, err := json.Marshal(info)
if err != nil {
return nil, err
if inspectData, err = json.Marshal(info); err != nil {
return nil, err
}

image = info.Image
labels = info.Labels
}

cpu := toRPCCPUMap(c.CPU)

return &pb.Container{
Id: c.ID,
Podname: c.Podname,
Nodename: c.Nodename,
Name: c.Name,
Cpu: cpu,
Quota: c.Quota,
Memory: c.Memory,
Privileged: c.Privileged,
Publish: publish,
Image: info.Image,
Labels: info.Labels,
Inspect: bytes,
StatusData: c.StatusData,
Id: c.ID,
Podname: c.Podname,
Nodename: c.Nodename,
Name: c.Name,
Cpu: cpu,
Quota: c.Quota,
Memory: c.Memory,
Privileged: c.Privileged,
Publish: publish,
Image: image,
Labels: labels,
Inspect: inspectData,
StatusData: c.StatusData,
Verification: verification,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion store/etcdv3/mercury.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (m *Mercury) BatchUpdate(ctx context.Context, data map[string]string, opts
return resp, err
}
if !resp.Succeeded {
return resp, types.ErrKeyExists
return resp, types.ErrKeyNotExists
}
return resp, nil
}
Expand Down

0 comments on commit e061e0d

Please sign in to comment.