@@ -417,9 +417,6 @@ func (rs *ReplicaSetService) RollbackContainer(name string, spec *models.Rollbac
417
417
}
418
418
419
419
func (rs * ReplicaSetService ) patchGpu (name string , spec * models.GpuPatch , info * models.EtcdContainerInfo ) (* models.EtcdContainerInfo , error ) {
420
- if spec == nil {
421
- return info , nil
422
- }
423
420
running , err := rs .containerStatusRunning (name )
424
421
if err != nil {
425
422
return info , errors .WithMessage (err , "services.containerStatusRunning failed" )
@@ -434,8 +431,16 @@ func (rs *ReplicaSetService) patchGpu(name string, spec *models.GpuPatch, info *
434
431
return info , errors .WithMessage (err , "services.containerDeviceRequestsDeviceIDs failed" )
435
432
}
436
433
437
- if len (uuids ) == spec .GpuCount {
438
- return info , nil
434
+ if spec != nil {
435
+ if len (uuids ) == spec .GpuCount && (running || pause ) {
436
+ return info , nil
437
+ }
438
+ }
439
+
440
+ if spec == nil {
441
+ spec = & models.GpuPatch {
442
+ GpuCount : len (uuids ),
443
+ }
439
444
}
440
445
441
446
if running || pause {
@@ -461,9 +466,6 @@ func (rs *ReplicaSetService) patchGpu(name string, spec *models.GpuPatch, info *
461
466
}
462
467
463
468
func (rs * ReplicaSetService ) patchCpu (name string , spec * models.CpuPatch , info * models.EtcdContainerInfo ) (* models.EtcdContainerInfo , error ) {
464
- if spec == nil {
465
- return info , nil
466
- }
467
469
running , err := rs .containerStatusRunning (name )
468
470
if err != nil {
469
471
return info , errors .WithMessage (err , "services.containerStatusRunning failed" )
@@ -478,8 +480,16 @@ func (rs *ReplicaSetService) patchCpu(name string, spec *models.CpuPatch, info *
478
480
return info , errors .WithMessage (err , "services.containerDeviceRequestsDeviceIDs failed" )
479
481
}
480
482
481
- if len (cpuset ) == spec .CpuCount && (running || pause ) {
482
- return info , nil
483
+ if spec != nil {
484
+ if len (cpuset ) == spec .CpuCount && (running || pause ) {
485
+ return info , nil
486
+ }
487
+ }
488
+
489
+ if spec == nil {
490
+ spec = & models.CpuPatch {
491
+ CpuCount : len (cpuset ),
492
+ }
483
493
}
484
494
485
495
if running || pause {
0 commit comments