@@ -31,6 +31,7 @@ const (
31
31
func (c * calcium ) CreateContainer (specs types.Specs , opts * types.DeployOptions ) (chan * types.CreateContainerMessage , error ) {
32
32
pod , err := c .store .GetPod (opts .Podname )
33
33
if err != nil {
34
+ log .Errorf ("Error during GetPod for %s: %v" , opts .Podname , err )
34
35
return nil , err
35
36
}
36
37
if pod .Favor == types .CPU_PRIOR {
@@ -43,16 +44,17 @@ func (c *calcium) CreateContainer(specs types.Specs, opts *types.DeployOptions)
43
44
func (c * calcium ) createContainerWithMemoryPrior (specs types.Specs , opts * types.DeployOptions ) (chan * types.CreateContainerMessage , error ) {
44
45
ch := make (chan * types.CreateContainerMessage )
45
46
if opts .Memory < MEMORY_LOW_LIMIT { // 4194304 Byte = 4 MB, docker 创建容器的内存最低标准
46
- return ch , fmt .Errorf ("Minimum memory limit allowed is 4MB" )
47
+ return ch , fmt .Errorf ("Minimum memory limit allowed is 4MB, got %d" , opts . Memory )
47
48
}
48
49
if opts .Count <= 0 { // Count 要大于0
49
- return ch , fmt .Errorf ("Count must be positive" )
50
+ return ch , fmt .Errorf ("Count must be positive, got %d" , opts . Count )
50
51
}
51
52
52
53
// TODO RFC 计算当前 app 部署情况的时候需要保证同一时间只有这个 app 的这个 entrypoint 在跑
53
54
// 因此需要在这里加个全局锁,直到部署完毕才释放
54
55
nodesInfo , err := c .allocMemoryPodResource (opts )
55
56
if err != nil {
57
+ log .Errorf ("Error during allocMemoryPodResource with opts %v: %v" , opts , err )
56
58
return ch , err
57
59
}
58
60
@@ -98,12 +100,16 @@ func (c *calcium) doCreateContainerWithMemoryPrior(nodeInfo types.NodeInfo, spec
98
100
99
101
node , err := c .GetNode (opts .Podname , nodeInfo .Name )
100
102
if err != nil {
103
+ log .Errorf ("Error during GetNode for %s, %s: %v" , opts .Podname , nodeInfo .Name , err )
101
104
return ms
102
105
}
103
106
104
107
if err := pullImage (node , opts .Image , c .config .Timeout .CreateContainer ); err != nil {
105
108
for i := 0 ; i < nodeInfo .Deploy ; i ++ {
106
- ms [i ].Error = err .Error ()
109
+ if err != nil {
110
+ log .Errorf ("Error during pullImage %s for %s: %v" , opts .Image , nodeInfo .Name , err )
111
+ ms [i ].Error = err .Error ()
112
+ }
107
113
}
108
114
return ms
109
115
}
@@ -115,6 +121,7 @@ func (c *calcium) doCreateContainerWithMemoryPrior(nodeInfo types.NodeInfo, spec
115
121
ms [i ].Nodename = node .Name
116
122
ms [i ].Memory = opts .Memory
117
123
if err != nil {
124
+ log .Errorf ("Error during makeContainerOptions: %v" , err )
118
125
ms [i ].Error = err .Error ()
119
126
c .store .UpdateNodeMem (opts .Podname , nodeInfo .Name , opts .Memory , "+" ) // 创建容器失败就要把资源还回去对不对?
120
127
continue
@@ -216,6 +223,7 @@ func (c *calcium) createContainerWithCPUPrior(specs types.Specs, opts *types.Dep
216
223
ch := make (chan * types.CreateContainerMessage )
217
224
result , err := c .allocCPUPodResource (opts )
218
225
if err != nil {
226
+ log .Errorf ("Error during allocCPUPodResource with opts %v: %v" , opts , err )
219
227
return ch , err
220
228
}
221
229
@@ -272,6 +280,7 @@ func (c *calcium) doCreateContainerWithCPUPrior(nodeName string, cpuMap []types.
272
280
}
273
281
274
282
if err := pullImage (node , opts .Image , c .config .Timeout .CreateContainer ); err != nil {
283
+ log .Errorf ("Error during pullImage: %v" , err )
275
284
for i := 0 ; i < len (ms ); i ++ {
276
285
ms [i ].Error = err .Error ()
277
286
}
@@ -286,6 +295,7 @@ func (c *calcium) doCreateContainerWithCPUPrior(nodeName string, cpuMap []types.
286
295
ms [i ].Nodename = node .Name
287
296
ms [i ].Memory = opts .Memory
288
297
if err != nil {
298
+ log .Errorf ("Error during makeContainerOptions: %v" , err )
289
299
ms [i ].Error = err .Error ()
290
300
c .releaseQuota (node , quota )
291
301
continue
0 commit comments