build: only use --cpuset options when the cgroup controller is available

Fixes: #1670
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-12-22 08:58:06 +01:00 committed by mergify[bot]
parent e6b70c494e
commit 415abead1e

View File

@ -16,8 +16,18 @@ CONTAINER_CMD?=$(shell docker version >/dev/null 2>&1 && echo docker)
ifeq ($(CONTAINER_CMD),) ifeq ($(CONTAINER_CMD),)
CONTAINER_CMD=$(shell podman version >/dev/null 2>&1 && echo podman) CONTAINER_CMD=$(shell podman version >/dev/null 2>&1 && echo podman)
endif endif
CPUS?=$(shell nproc --ignore=1)
CPUSET?=--cpuset-cpus=0-${CPUS} # Recent versions of Podman do not allow non-root to use --cpuset options.
# Set HAVE_CPUSET to 1 when cpuset support is available.
ifeq ($(UID),0)
HAVE_CPUSET ?= $(shell grep -c -w cpuset /sys/fs/cgroup/cgroup.controllers 2>/dev/null)
else
HAVE_CPUSET ?= $(shell grep -c -w cpuset /sys/fs/cgroup/user.slice/user-$(UID).slice/cgroup.controllers 2>/dev/null)
endif
ifeq ($(HAVE_CPUSET),1)
CPUS ?= $(shell nproc --ignore=1)
CPUSET ?= --cpuset-cpus=0-${CPUS}
endif
CSI_IMAGE_NAME=$(if $(ENV_CSI_IMAGE_NAME),$(ENV_CSI_IMAGE_NAME),quay.io/cephcsi/cephcsi) CSI_IMAGE_NAME=$(if $(ENV_CSI_IMAGE_NAME),$(ENV_CSI_IMAGE_NAME),quay.io/cephcsi/cephcsi)
USE_PULLED_IMAGE ?= no USE_PULLED_IMAGE ?= no