Skip to content

Commit 0a718e2

Browse files
authored
Merge pull request cloudflare#566 from dqminh/cgroup_id
CgroupIDMap: default key size to CgroupIDMapHashType
2 parents 7c76838 + 9ce5c92 commit 0a718e2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

exporter/cgroup_id_map.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ func newCgroupIDMap(module *libbpfgo.Module, cfg config.Config) (*CgroupIDMap, e
2727
if err != nil {
2828
return nil, fmt.Errorf("failed to get map %q: %w", cfg.CgroupIDMap.Name, err)
2929
}
30+
idMapType := cfg.CgroupIDMap.Type
31+
if idMapType == "" {
32+
// default to CgroupIDMapHashType to accommodate legacy hash-type maps before
33+
// the addition of CgroupIDMapCgrpStorageType
34+
idMapType = config.CgroupIDMapHashType
35+
}
3036

3137
keySize := m.KeySize()
3238
var expectedKeySize int
33-
switch cfg.CgroupIDMap.Type {
39+
switch idMapType {
3440
case config.CgroupIDMapHashType:
3541
expectedKeySize = 8
3642
case config.CgroupIDMapCgrpStorageType:
@@ -46,7 +52,7 @@ func newCgroupIDMap(module *libbpfgo.Module, cfg config.Config) (*CgroupIDMap, e
4652

4753
c := &CgroupIDMap{
4854
bpfMap: m,
49-
bpfMapType: cfg.CgroupIDMap.Type,
55+
bpfMapType: idMapType,
5056
ch: make(chan cgroup.ChangeNotification, 10),
5157
cache: map[string]*regexp.Regexp{},
5258
}

0 commit comments

Comments
 (0)