forked from parca-dev/parca-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/discovery: take user provided systemd cgroup path into account
This patch wires up the --systemd-cgroup-path flag and actually plumbs the user provided value into the systemd config and subsequently into the systemd discoverer to be used when trying to reconcile unit files. Fixes parca-dev#192
- Loading branch information
1 parent
9933b45
commit b02cb76
Showing
3 changed files
with
53 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package discovery | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/go-kit/log" | ||
"github.com/parca-dev/parca-agent/pkg/agent" | ||
) | ||
|
||
func TestReconcileUnitWithCgroupPath(t *testing.T) { | ||
service := "foobar.service" | ||
conf := NewSystemdConfig([]string{service}, "/sys/fs/cgroup/machine.slice/foobar/") | ||
dopts := DiscovererOptions{ | ||
Logger: log.NewNopLogger(), | ||
} | ||
d, err := conf.NewDiscoverer(dopts) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
ls, err := d.(*SystemdDiscoverer).ReconcileUnit(context.TODO(), service) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(ls) != 1 { | ||
t.Fatalf("expected 1 line, got %d", len(ls)) | ||
} | ||
path, ok := ls[agent.CgroupPathLabelName] | ||
if !ok { | ||
t.Fatal("expected cgroup path label") | ||
} | ||
expected := "/sys/fs/cgroup/machine.slice/foobar/foobar.service" | ||
if string(path) != expected { | ||
t.Fatalf("expected %q, got %q", expected, path) | ||
} | ||
} |