Skip to content

Commit

Permalink
add zone in rpc node
Browse files Browse the repository at this point in the history
  • Loading branch information
tonicmuroq committed Jan 18, 2017
1 parent be055d9 commit 732d8ba
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 142 deletions.
4 changes: 4 additions & 0 deletions cluster/calcium/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ func (c *calcium) GetContainer(id string) (*types.Container, error) {
func (c *calcium) GetContainers(ids []string) ([]*types.Container, error) {
return c.store.GetContainers(ids)
}

func (c *calcium) GetZone() string {
return c.config.Zone
}
3 changes: 3 additions & 0 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ type Cluster interface {
UpgradeContainer(ids []string, image string) (chan *types.UpgradeContainerMessage, error)
RemoveContainer(ids []string) (chan *types.RemoveContainerMessage, error)
RemoveImage(podname, nodename string, images []string) (chan *types.RemoveImageMessage, error)

// cluster attribute methods
GetZone() string
}
111 changes: 59 additions & 52 deletions devtools/core_pb2.py

Large diffs are not rendered by default.

178 changes: 93 additions & 85 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 @@ -52,6 +52,7 @@ message Node {
map<string, int64> cpu = 5;
string info = 6;
bool available = 7;
string zone = 8;
}

message Nodes {
Expand Down
8 changes: 4 additions & 4 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (v *virbranium) AddNode(ctx context.Context, opts *pb.AddNodeOptions) (*pb.
return nil, err
}

return toRPCNode(n), nil
return toRPCNode(n, v.cluster.GetZone()), nil
}

// AddNode saves a node and returns it to client
Expand All @@ -84,7 +84,7 @@ func (v *virbranium) GetNode(ctx context.Context, opts *pb.GetNodeOptions) (*pb.
return nil, err
}

return toRPCNode(n), nil
return toRPCNode(n, v.cluster.GetZone()), nil
}

// ListPodNodes returns a list of node for pod
Expand All @@ -96,7 +96,7 @@ func (v *virbranium) ListPodNodes(ctx context.Context, opts *pb.ListNodesOptions

nodes := []*pb.Node{}
for _, n := range ns {
nodes = append(nodes, toRPCNode(n))
nodes = append(nodes, toRPCNode(n, v.cluster.GetZone()))
}
return &pb.Nodes{Nodes: nodes}, nil
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (v *virbranium) SetNodeAvailable(ctx context.Context, opts *pb.NodeAvailabl
if err != nil {
return nil, err
}
return toRPCNode(n), nil
return toRPCNode(n, v.cluster.GetZone()), nil
}

// streamed returned functions
Expand Down
3 changes: 2 additions & 1 deletion rpc/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func toRPCNetwork(n *types.Network) *pb.Network {
return &pb.Network{Name: n.Name, Subnets: n.Subnets}
}

func toRPCNode(n *types.Node) *pb.Node {
func toRPCNode(n *types.Node, zone string) *pb.Node {
bytes := []byte("")
if info, err := n.Info(); err == nil {
bytes, _ = json.Marshal(info)
Expand All @@ -37,6 +37,7 @@ func toRPCNode(n *types.Node) *pb.Node {
Cpu: toRPCCPUMap(n.CPU),
Info: string(bytes),
Available: n.Available,
Zone: zone,
}
}

Expand Down
1 change: 1 addition & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Config struct {
EtcdLockPrefix string `yaml:"etcd_lock_prefix"` // etcd lock prefix, all locks will be created under this dir
ResourceAlloc string `yaml:"resource_alloc"` // scheduler or cpu-period TODO give it a good name
Statsd string `yaml:"statsd"` // Statsd host and port
Zone string `yaml:"zone"` // zone for core, e.g. C1, C2

Git GitConfig `yaml:"git"`
Docker DockerConfig `yaml:"docker"`
Expand Down

0 comments on commit 732d8ba

Please sign in to comment.