We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73bbe7b commit d8aa021Copy full SHA for d8aa021
context.go
@@ -157,10 +157,11 @@ type Docker struct {
157
func GetCurrentContainerID() string {
158
file, err := os.Open("/proc/self/cgroup")
159
160
- if os.IsNotExist(err) {
161
- return ""
162
- } else if err != nil {
163
- log.Printf("Fail to open /proc/self/cgroup: %s\n", err)
+ if err != nil {
+ if os.IsExist(err) {
+ log.Printf("Fail to open /proc/self/cgroup: %s\n", err)
+ }
164
+
165
return ""
166
}
167
context_test.go
@@ -7,7 +7,7 @@ import (
7
func TestGetCurrentContainerID(t *testing.T) {
8
currentContainerID := GetCurrentContainerID()
9
10
- if len(currentContainerID) != 64 {
+ if len(currentContainerID) != 0 && len(currentContainerID) != 64 {
11
t.Fail()
12
13
0 commit comments