Skip to content

Commit

Permalink
citadel knows nothing about core error
Browse files Browse the repository at this point in the history
  • Loading branch information
timfeirg committed Oct 31, 2016
1 parent 8bc542b commit 40c708a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions cluster/calcium/create_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,35 @@ func (c *calcium) CreateContainer(specs types.Specs, opts *types.DeployOptions)
}
}

// when shits go wrong before doCreateContainerWithCPUPeriod, don't just return
// the channel and return an error, because citadel don't know what's going on
func (c *calcium) createErrorMessage(err error) *types.CreateContainerMessage {
log.Errorf("Got error %s", err.Error())
m := &types.CreateContainerMessage{
Podname: "",
Nodename: "",
ContainerID: "",
ContainerName: "",
Error: err.Error(),
Success: false,
CPU: nil,
Memory: 0,
}
return m
}

func (c *calcium) createContainerWithCPUPeriod(specs types.Specs, opts *types.DeployOptions) (chan *types.CreateContainerMessage, error) {
ch := make(chan *types.CreateContainerMessage)

if opts.Memory < 4194304 { // 4194304 Byte = 4 MB, docker 创建容器的内存最低标准
return ch, fmt.Errorf("Minimum memory limit allowed is 4MB")
err := fmt.Errorf("Minimum memory limit allowed is 4MB")
ch <- c.createErrorMessage(err)
return ch, err
}

cpuandmem, _, err := c.getCPUAndMem(opts.Podname, opts.Nodename, 1.0)
if err != nil {
log.Errorf("Got error %v after getCPUAndMem", err)
ch <- c.createErrorMessage(err)
return ch, err
}
nodesInfo := utils.GetNodesInfo(cpuandmem)
Expand Down

0 comments on commit 40c708a

Please sign in to comment.