@@ -781,46 +781,36 @@ func CreateCgroupConfig(opts *CreateOpts, defaultDevs []*devices.Device) (*confi
781781 if r .BlockIO .LeafWeight != nil {
782782 c .Resources .BlkioLeafWeight = * r .BlockIO .LeafWeight
783783 }
784- if r .BlockIO .WeightDevice != nil {
785- for _ , wd := range r .BlockIO .WeightDevice {
786- var weight , leafWeight uint16
787- if wd .Weight != nil {
788- weight = * wd .Weight
789- }
790- if wd .LeafWeight != nil {
791- leafWeight = * wd .LeafWeight
792- }
793- weightDevice := configs .NewWeightDevice (wd .Major , wd .Minor , weight , leafWeight )
794- c .Resources .BlkioWeightDevice = append (c .Resources .BlkioWeightDevice , weightDevice )
784+ for _ , wd := range r .BlockIO .WeightDevice {
785+ var weight , leafWeight uint16
786+ if wd .Weight != nil {
787+ weight = * wd .Weight
795788 }
796- }
797- if r .BlockIO .ThrottleReadBpsDevice != nil {
798- for _ , td := range r .BlockIO .ThrottleReadBpsDevice {
799- rate := td .Rate
800- throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
801- c .Resources .BlkioThrottleReadBpsDevice = append (c .Resources .BlkioThrottleReadBpsDevice , throttleDevice )
789+ if wd .LeafWeight != nil {
790+ leafWeight = * wd .LeafWeight
802791 }
792+ weightDevice := configs .NewWeightDevice (wd .Major , wd .Minor , weight , leafWeight )
793+ c .Resources .BlkioWeightDevice = append (c .Resources .BlkioWeightDevice , weightDevice )
803794 }
804- if r .BlockIO .ThrottleWriteBpsDevice != nil {
805- for _ , td := range r .BlockIO .ThrottleWriteBpsDevice {
806- rate := td .Rate
807- throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
808- c .Resources .BlkioThrottleWriteBpsDevice = append (c .Resources .BlkioThrottleWriteBpsDevice , throttleDevice )
809- }
795+ for _ , td := range r .BlockIO .ThrottleReadBpsDevice {
796+ rate := td .Rate
797+ throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
798+ c .Resources .BlkioThrottleReadBpsDevice = append (c .Resources .BlkioThrottleReadBpsDevice , throttleDevice )
810799 }
811- if r .BlockIO .ThrottleReadIOPSDevice != nil {
812- for _ , td := range r .BlockIO .ThrottleReadIOPSDevice {
813- rate := td .Rate
814- throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
815- c .Resources .BlkioThrottleReadIOPSDevice = append (c .Resources .BlkioThrottleReadIOPSDevice , throttleDevice )
816- }
800+ for _ , td := range r .BlockIO .ThrottleWriteBpsDevice {
801+ rate := td .Rate
802+ throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
803+ c .Resources .BlkioThrottleWriteBpsDevice = append (c .Resources .BlkioThrottleWriteBpsDevice , throttleDevice )
817804 }
818- if r .BlockIO .ThrottleWriteIOPSDevice != nil {
819- for _ , td := range r .BlockIO .ThrottleWriteIOPSDevice {
820- rate := td .Rate
821- throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
822- c .Resources .BlkioThrottleWriteIOPSDevice = append (c .Resources .BlkioThrottleWriteIOPSDevice , throttleDevice )
823- }
805+ for _ , td := range r .BlockIO .ThrottleReadIOPSDevice {
806+ rate := td .Rate
807+ throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
808+ c .Resources .BlkioThrottleReadIOPSDevice = append (c .Resources .BlkioThrottleReadIOPSDevice , throttleDevice )
809+ }
810+ for _ , td := range r .BlockIO .ThrottleWriteIOPSDevice {
811+ rate := td .Rate
812+ throttleDevice := configs .NewThrottleDevice (td .Major , td .Minor , rate )
813+ c .Resources .BlkioThrottleWriteIOPSDevice = append (c .Resources .BlkioThrottleWriteIOPSDevice , throttleDevice )
824814 }
825815 }
826816 for _ , l := range r .HugepageLimits {
0 commit comments