@@ -356,9 +356,24 @@ func (v *Validator) CheckLinux() (msgs []string) {
356356 msgs = append (msgs , fmt .Sprintf ("On Linux, hostname requires a new UTS namespace to be specified as well" ))
357357 }
358358
359+ // Linux devices validation
360+ devList := make (map [string ]bool )
361+ typeList := make (map [string ]string )
359362 for index := 0 ; index < len (v .spec .Linux .Devices ); index ++ {
360- if ! deviceValid (v .spec .Linux .Devices [index ]) {
361- msgs = append (msgs , fmt .Sprintf ("device %v is invalid." , v .spec .Linux .Devices [index ]))
363+ device := v .spec .Linux .Devices [index ]
364+ if ! deviceValid (device ) {
365+ msgs = append (msgs , fmt .Sprintf ("device %v is invalid." , device ))
366+ }
367+ if _ , exists := devList [device .Path ]; exists {
368+ msgs = append (msgs , fmt .Sprintf ("device %s is duplicated" , device .Path ))
369+ } else {
370+ devList [device .Path ] = true
371+ }
372+ devId := fmt .Sprintf ("%d:%d" , device .Major , device .Minor )
373+ if existId , exists := typeList [device .Type ]; exists && existId == devId {
374+ logrus .Warnf ("type: %s, major:%d and minor:%d for linux devices is duplicated" , device .Type , device .Major , device .Minor )
375+ } else {
376+ typeList [device .Type ] = devId
362377 }
363378 }
364379
0 commit comments