Skip to content

Commit f3cc20b

Browse files
committed
make cgroup imports linux-only
1 parent 27afdba commit f3cc20b

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

pkg/build/builder/util.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strings"
1313

1414
docker "github.com/fsouza/go-dockerclient"
15-
"github.com/opencontainers/runc/libcontainer/cgroups"
1615

1716
s2iapi "github.com/openshift/source-to-image/pkg/api"
1817

@@ -174,17 +173,6 @@ func addBuildLabels(labels map[string]string, build *buildapi.Build) {
174173
labels[buildapi.DefaultDockerLabelNamespace+"build.namespace"] = build.Namespace
175174
}
176175

177-
// getCgroupParent determines the parent cgroup for a container from
178-
// within that container.
179-
func getCgroupParent() (string, error) {
180-
cgMap, err := cgroups.ParseCgroupFile("/proc/self/cgroup")
181-
if err != nil {
182-
return "", err
183-
}
184-
glog.V(6).Infof("found cgroup values map: %v", cgMap)
185-
return extractParentFromCgroupMap(cgMap)
186-
}
187-
188176
// extractParentFromCgroupMap finds the cgroup parent in the cgroup map
189177
func extractParentFromCgroupMap(cgMap map[string]string) (string, error) {
190178
memory, ok := cgMap["memory"]

pkg/build/builder/util_linux.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// +build linux
2+
3+
package builder
4+
5+
import (
6+
"github.com/opencontainers/runc/libcontainer/cgroups"
7+
)
8+
9+
// getCgroupParent determines the parent cgroup for a container from
10+
// within that container.
11+
func getCgroupParent() (string, error) {
12+
cgMap, err := cgroups.ParseCgroupFile("/proc/self/cgroup")
13+
if err != nil {
14+
return "", err
15+
}
16+
glog.V(6).Infof("found cgroup values map: %v", cgMap)
17+
return extractParentFromCgroupMap(cgMap)
18+
}

pkg/build/builder/util_unsupported.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// +build !linux
2+
3+
package builder
4+
5+
import "errors"
6+
7+
// getCgroupParent determines the parent cgroup for a container from
8+
// within that container.
9+
func getCgroupParent() (string, error) {
10+
return "", errors.New("getCgroupParent is unsupported on this platform")
11+
}

0 commit comments

Comments
 (0)