@@ -439,6 +439,22 @@ func getMemBwInfo() (*MemBwInfo, error) {
439
439
return memBwInfo , nil
440
440
}
441
441
442
+ // Get diagnostics for last filesystem operation error from file info/last_cmd_status
443
+ func getLastCmdStatus () (string , error ) {
444
+ rootPath , err := getIntelRdtRoot ()
445
+ if err != nil {
446
+ return "" , err
447
+ }
448
+
449
+ path := filepath .Join (rootPath , "info" )
450
+ lastCmdStatus , err := getIntelRdtParamString (path , "last_cmd_status" )
451
+ if err != nil {
452
+ return "" , err
453
+ }
454
+
455
+ return lastCmdStatus , nil
456
+ }
457
+
442
458
// WriteIntelRdtTasks writes the specified pid into the "tasks" file
443
459
func WriteIntelRdtTasks (dir string , pid int ) error {
444
460
if dir == "" {
@@ -637,21 +653,21 @@ func (m *IntelRdtManager) Set(container *configs.Config) error {
637
653
// Write a single joint schema string to schemata file
638
654
if l3CacheSchema != "" && memBwSchema != "" {
639
655
if err := writeFile (path , "schemata" , l3CacheSchema + "\n " + memBwSchema ); err != nil {
640
- return err
656
+ return NewLastCmdError ( err )
641
657
}
642
658
}
643
659
644
660
// Write only L3 cache schema string to schemata file
645
661
if l3CacheSchema != "" && memBwSchema == "" {
646
662
if err := writeFile (path , "schemata" , l3CacheSchema ); err != nil {
647
- return err
663
+ return NewLastCmdError ( err )
648
664
}
649
665
}
650
666
651
667
// Write only memory bandwidth schema string to schemata file
652
668
if l3CacheSchema == "" && memBwSchema != "" {
653
669
if err := writeFile (path , "schemata" , memBwSchema ); err != nil {
654
- return err
670
+ return NewLastCmdError ( err )
655
671
}
656
672
}
657
673
}
@@ -662,11 +678,11 @@ func (m *IntelRdtManager) Set(container *configs.Config) error {
662
678
func (raw * intelRdtData ) join (id string ) (string , error ) {
663
679
path := filepath .Join (raw .root , id )
664
680
if err := os .MkdirAll (path , 0755 ); err != nil {
665
- return "" , err
681
+ return "" , NewLastCmdError ( err )
666
682
}
667
683
668
684
if err := WriteIntelRdtTasks (path , raw .pid ); err != nil {
669
- return "" , err
685
+ return "" , NewLastCmdError ( err )
670
686
}
671
687
return path , nil
672
688
}
@@ -692,3 +708,23 @@ func IsNotFound(err error) bool {
692
708
_ , ok := err .(* NotFoundError )
693
709
return ok
694
710
}
711
+
712
+ type LastCmdError struct {
713
+ LastCmdStatus string
714
+ Err error
715
+ }
716
+
717
+ func (e * LastCmdError ) Error () string {
718
+ return fmt .Sprintf (e .Err .Error () + ", last_cmd_status: " + e .LastCmdStatus )
719
+ }
720
+
721
+ func NewLastCmdError (err error ) error {
722
+ lastCmdStatus , err1 := getLastCmdStatus ()
723
+ if err1 == nil {
724
+ return & LastCmdError {
725
+ LastCmdStatus : lastCmdStatus ,
726
+ Err : err ,
727
+ }
728
+ }
729
+ return err
730
+ }
0 commit comments