This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git
The following commit(s) were added to refs/heads/main by this push:
new 96bfd2a Fixed reading process paths incorrect when running as a
container (#42)
96bfd2a is described below
commit 96bfd2a51e582f34ccbbedfd4bceb7407559de2a
Author: mrproliu <[email protected]>
AuthorDate: Tue Jul 26 13:22:50 2022 +0800
Fixed reading process paths incorrect when running as a container (#42)
---
CHANGES.md | 1 +
pkg/tools/host/file.go | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/CHANGES.md b/CHANGES.md
index 5f025b4..1cd7a8a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,7 @@ Release Notes.
* Let the logger as a configurable module.
#### Bug Fixes
+* Fixed reading process paths incorrect when running as a container.
#### Issues and PR
- All issues are
[here](https://github.com/apache/skywalking/milestone/144?closed=1)
diff --git a/pkg/tools/host/file.go b/pkg/tools/host/file.go
index 4d26ef1..63f6de3 100644
--- a/pkg/tools/host/file.go
+++ b/pkg/tools/host/file.go
@@ -22,7 +22,15 @@ import (
"strings"
)
-var hostMappingPath = os.Getenv("ROVER_HOST_MAPPING")
+var hostMappingPath string
+
+func init() {
+ hostMappingPath = os.Getenv("ROVER_HOST_MAPPING")
+ // adapt with gopsutil framework to read the right process directory of
host
+ if hostMappingPath != "" {
+ os.Setenv("HOST_PROC", hostMappingPath+"/proc")
+ }
+}
// GetFileInHost means add the host root mapping prefix, it's dependent when
the rover is deploy in a container
func GetFileInHost(absPath string) string {