-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.Change the caller level from warn to debug when delete the qdisc
2.Implement a dynamic temporary cache that tracks network interfaces that do not support the ethtool operation. 3.Add new test cases for the new changings
- Loading branch information
1 parent
6443991
commit 48e6a60
Showing
6 changed files
with
149 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package linuxutil | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
|
||
lru "github.com/hashicorp/golang-lru/v2" | ||
|
||
"github.com/microsoft/retina/pkg/log" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type CachedEthtool struct { | ||
EthtoolInterface | ||
unsupported *lru.Cache[string, struct{}] | ||
l *log.ZapLogger | ||
} | ||
|
||
func NewCachedEthtool(ethHandle EthtoolInterface, opts *EthtoolOpts) *CachedEthtool { | ||
cache, err := lru.New[string, struct{}](int(opts.limit)) | ||
if err != nil { | ||
log.Logger().Error("failed to create LRU cache: ", zap.Error(err)) | ||
} | ||
|
||
return &CachedEthtool{ | ||
EthtoolInterface: ethHandle, | ||
unsupported: cache, | ||
l: log.Logger().Named(string("EthtoolReader")), | ||
} | ||
} | ||
|
||
var errskip = errors.New("skip interface") | ||
|
||
func (ce *CachedEthtool) Stats(intf string) (map[string]uint64, error) { | ||
// Skip unsupported interfaces | ||
if _, ok := ce.unsupported.Get(intf); ok { | ||
return nil, errskip | ||
} | ||
|
||
ifaceStats, err := ce.EthtoolInterface.Stats(intf) | ||
if err != nil { | ||
if strings.Contains(err.Error(), "operation not supported") { | ||
ce.unsupported.Add(intf, struct{}{}) | ||
return nil, errors.Wrap(err, "interface not supported while retrieving stats") | ||
} | ||
return nil, errors.Wrap(err, "failed to retrieve interface stats") | ||
} | ||
return ifaceStats, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters