Skip to content

Commit

Permalink
Merge pull request #2021 from machine424/gomax-4-13
Browse files Browse the repository at this point in the history
OCPBUGS-15469: Limit the value of GOMAXPROCS on node-exporter to 4.
  • Loading branch information
openshift-merge-robot committed Jul 3, 2023
2 parents 3777e7b + bad6d68 commit a5566ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions assets/node-exporter/daemonset.yaml
Expand Up @@ -41,6 +41,19 @@ spec:
- --collector.cpu.info
- --collector.textfile.directory=/var/node_exporter/textfile
- --no-collector.btrfs
command:
- /bin/sh
- -c
- |
export GOMAXPROCS=4
# We don't take CPU affinity into account as the container doesn't have integer CPU requests.
# In case of error, fallback to the default value.
NUM_CPUS=$(grep -c '^processor' "/proc/cpuinfo" 2>/dev/null || echo "0")
if [ "$NUM_CPUS" -lt "$GOMAXPROCS" ]; then
export GOMAXPROCS="$NUM_CPUS"
fi
echo "ts=$(date --iso-8601=seconds) num_cpus=$NUM_CPUS gomaxprocs=$GOMAXPROCS"
exec /bin/node_exporter "$0" "$@"
image: quay.io/prometheus/node-exporter:v1.5.0
name: node-exporter
resources:
Expand Down
15 changes: 15 additions & 0 deletions jsonnet/components/node-exporter.libsonnet
Expand Up @@ -214,6 +214,21 @@ function(params)
'--collector.textfile.directory=' + textfileDir,
'--no-collector.btrfs',
],
command: [
'/bin/sh',
'-c',
|||
export GOMAXPROCS=4
# We don't take CPU affinity into account as the container doesn't have integer CPU requests.
# In case of error, fallback to the default value.
NUM_CPUS=$(grep -c '^processor' "/proc/cpuinfo" 2>/dev/null || echo "0")
if [ "$NUM_CPUS" -lt "$GOMAXPROCS" ]; then
export GOMAXPROCS="$NUM_CPUS"
fi
echo "ts=$(date --iso-8601=seconds) num_cpus=$NUM_CPUS gomaxprocs=$GOMAXPROCS"
exec /bin/node_exporter "$0" "$@"
|||,
],
terminationMessagePolicy: 'FallbackToLogsOnError',
volumeMounts+: [{
mountPath: textfileDir,
Expand Down

0 comments on commit a5566ce

Please sign in to comment.