@@ -40,7 +40,6 @@ func (c *calcium) createContainerWithCPUPeriod(specs types.Specs, opts *types.De
40
40
41
41
cpuandmem , _ , err := c .getCPUAndMem (opts .Podname , opts .Nodename , 1.0 )
42
42
if err != nil {
43
- log .Errorf ("Got error %v after getCPUAndMem" , err )
44
43
return ch , err
45
44
}
46
45
go utils .SendMemCap (cpuandmem , "before-alloc" )
@@ -100,7 +99,6 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
100
99
ms [i ].Nodename = node .Name
101
100
ms [i ].Memory = opts .Memory
102
101
if err != nil {
103
- log .Errorf ("Error when creating CreateContainerOptions, %v" , err )
104
102
c .store .UpdateNodeMem (opts .Podname , nodename , opts .Memory , "+" ) // 创建容器失败就要把资源还回去对不对?
105
103
ms [i ].Error = err .Error ()
106
104
continue
@@ -109,7 +107,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
109
107
//create container
110
108
container , err := node .Engine .ContainerCreate (context .Background (), config , hostConfig , networkConfig , containerName )
111
109
if err != nil {
112
- log .Errorf ("Error when creating container , %v" , err )
110
+ log .Errorf ("Error during ContainerCreate , %v" , err )
113
111
ms [i ].Error = err .Error ()
114
112
c .store .UpdateNodeMem (opts .Podname , nodename , opts .Memory , "+" )
115
113
continue
@@ -125,7 +123,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
125
123
for networkID , ipv4 := range opts .Networks {
126
124
if err = c .network .ConnectToNetwork (ctx , container .ID , networkID , ipv4 ); err != nil {
127
125
c .store .UpdateNodeMem (opts .Podname , nodename , opts .Memory , "+" )
128
- log .Errorf ("Error when connecting container %q to network %q, %q " , container .ID , networkID , err . Error () )
126
+ log .Errorf ("Error during connecting container %q to network %q, %v " , container .ID , networkID , err )
129
127
breaked = true
130
128
break
131
129
}
@@ -135,7 +133,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
135
133
// only when user defined networks is given
136
134
if len (opts .Networks ) != 0 {
137
135
if err := c .network .DisconnectFromNetwork (ctx , container .ID , "bridge" ); err != nil {
138
- log .Errorf ("Error when disconnecting container %q from network %q, %q " , container .ID , "bridge" , err . Error () )
136
+ log .Errorf ("Error during disconnecting container %q from network %q, %v " , container .ID , "bridge" , err )
139
137
}
140
138
}
141
139
@@ -150,7 +148,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
150
148
151
149
err = node .Engine .ContainerStart (context .Background (), container .ID , enginetypes.ContainerStartOptions {})
152
150
if err != nil {
153
- log .Errorf ("Error when starting container , %v" , err )
151
+ log .Errorf ("Error during ContainerStart , %v" , err )
154
152
ms [i ].Error = err .Error ()
155
153
c .store .UpdateNodeMem (opts .Podname , nodename , opts .Memory , "+" )
156
154
go node .Engine .ContainerRemove (context .Background (), container .ID , enginetypes.ContainerRemoveOptions {})
@@ -163,7 +161,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
163
161
164
162
info , err := node .Engine .ContainerInspect (context .Background (), container .ID )
165
163
if err != nil {
166
- log .Errorf ("Error when inspecting container , %v" , err )
164
+ log .Errorf ("Error during ContainerInspect , %v" , err )
167
165
ms [i ].Error = err .Error ()
168
166
c .store .UpdateNodeMem (opts .Podname , nodename , opts .Memory , "+" )
169
167
continue
@@ -172,7 +170,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
172
170
173
171
// after start
174
172
if err := runExec (node .Engine , info , AFTER_START ); err != nil {
175
- log .Errorf ("Run exec at %s error: %s " , AFTER_START , err . Error () )
173
+ log .Errorf ("Run exec at %s error: %v " , AFTER_START , err )
176
174
}
177
175
178
176
_ , err = c .store .AddContainer (info .ID , opts .Podname , node .Name , containerName , nil , opts .Memory )
@@ -189,7 +187,6 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
189
187
go func (podname string , nodename string ) {
190
188
cpuandmem , _ , err := c .getCPUAndMem (podname , nodename , 1.0 )
191
189
if err != nil {
192
- log .Errorf ("Got error %v after getCPUAndMem" , err )
193
190
return
194
191
}
195
192
utils .SendMemCap (cpuandmem , "after-alloc" )
@@ -289,7 +286,9 @@ func (c *calcium) getCPUAndMem(podname, nodename string, quota float64) (map[str
289
286
}
290
287
291
288
if len (nodes ) == 0 {
292
- return result , nil , fmt .Errorf ("No available nodes" )
289
+ err := fmt .Errorf ("No available nodes" )
290
+ log .Errorf ("Error during getCPUAndMem: %v" , err )
291
+ return result , nil , err
293
292
}
294
293
295
294
result = makeCPUAndMem (nodes )
@@ -349,15 +348,18 @@ func filterNodes(nodes []*types.Node, public bool) []*types.Node {
349
348
// Pull an image
350
349
// Blocks until it finishes.
351
350
func pullImage (node * types.Node , image string ) error {
351
+ log .Debugf ("Pulling image %s" , image )
352
352
if image == "" {
353
- return fmt .Errorf ("No image found for version " )
353
+ return fmt .Errorf ("Goddamn empty image, WTF? " )
354
354
}
355
355
356
356
resp , err := node .Engine .ImagePull (context .Background (), image , enginetypes.ImagePullOptions {})
357
357
if err != nil {
358
+ log .Errorf ("Error during pulling image %s: %v" , image , err )
358
359
return err
359
360
}
360
361
ensureReaderClosed (resp )
362
+ log .Debugf ("Done pulling image %s" , image )
361
363
return nil
362
364
}
363
365
@@ -374,7 +376,6 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
374
376
}
375
377
376
378
if err := pullImage (node , opts .Image ); err != nil {
377
- log .Errorf ("Pull image error %v" , err )
378
379
return ms
379
380
}
380
381
@@ -386,7 +387,6 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
386
387
ms [i ].Nodename = node .Name
387
388
ms [i ].Memory = opts .Memory
388
389
if err != nil {
389
- log .Errorf ("Error when creating CreateContainerOptions, %v" , err )
390
390
ms [i ].Error = err .Error ()
391
391
c .releaseQuota (node , quota )
392
392
continue
@@ -410,7 +410,7 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
410
410
// need to ensure all networks are correctly connected
411
411
for networkID , ipv4 := range opts .Networks {
412
412
if err = c .network .ConnectToNetwork (ctx , container .ID , networkID , ipv4 ); err != nil {
413
- log .Errorf ("Error when connecting container %q to network %q, %q " , container .ID , networkID , err . Error () )
413
+ log .Errorf ("Error when connecting container %q to network %q, %v " , container .ID , networkID , err )
414
414
breaked = true
415
415
break
416
416
}
@@ -420,7 +420,7 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
420
420
// only when user defined networks is given
421
421
if len (opts .Networks ) != 0 {
422
422
if err := c .network .DisconnectFromNetwork (ctx , container .ID , "bridge" ); err != nil {
423
- log .Errorf ("Error when disconnecting container %q from network %q, %q " , container .ID , "bridge" , err . Error () )
423
+ log .Errorf ("Error when disconnecting container %q from network %q, %v " , container .ID , "bridge" , err )
424
424
}
425
425
}
426
426
@@ -457,7 +457,7 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
457
457
458
458
// after start
459
459
if err := runExec (node .Engine , info , AFTER_START ); err != nil {
460
- log .Errorf ("Run exec at %s error: %s " , AFTER_START , err . Error () )
460
+ log .Errorf ("Run exec at %s error: %v " , AFTER_START , err )
461
461
}
462
462
463
463
_ , err = c .store .AddContainer (info .ID , opts .Podname , node .Name , containerName , quota , opts .Memory )
@@ -492,7 +492,9 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
492
492
493
493
entry , ok := specs .Entrypoints [opts .Entrypoint ]
494
494
if ! ok {
495
- return nil , nil , nil , "" , fmt .Errorf ("Entrypoint %q not found in image %q" , opts .Entrypoint , opts .Image )
495
+ err := fmt .Errorf ("Entrypoint %q not found in image %q" , opts .Entrypoint , opts .Image )
496
+ log .Errorf ("Error during makeContainerOptions: %v" , err )
497
+ return nil , nil , nil , "" , err
496
498
}
497
499
498
500
user := specs .Appname
@@ -781,7 +783,6 @@ func (c *calcium) doUpgradeContainer(containers []*types.Container, image string
781
783
782
784
// prepare new image
783
785
if err := pullImage (node , image ); err != nil {
784
- log .Errorf ("Pull image error %v" , err )
785
786
return ms
786
787
}
787
788
@@ -868,7 +869,7 @@ func (c *calcium) doUpgradeContainer(containers []*types.Container, image string
868
869
869
870
// after start
870
871
if err := runExec (engine , newInfo , AFTER_START ); err != nil {
871
- log .Errorf ("Run exec at %s error: %s " , AFTER_START , err . Error () )
872
+ log .Errorf ("Run exec at %s error: %v " , AFTER_START , err )
872
873
}
873
874
874
875
// if so, add a new container in etcd
0 commit comments