LoginSignup
8
6

More than 5 years have passed since last update.

Jenkinsから見えるulimitの結果がおかしい場合

Last updated at Posted at 2015-06-30

前提

jenkinsを公式リポジトリからダウンロードして実行している場合。

問題

/etc/security/limits.conf などを弄ってjenkinsユーザから触れるulimitの値を変更することができる。一例としてはこんな感じ。

/etc/security/limits.conf
jenkins   soft   nofile  655360
jenkins   hard   nofile  655360

その結果を確認するには

 $ sudo su jenkins
 $ ulimit -a

で可能である…と思われるが。
jenkinsの実行中で ulimit -a した場合と結果がズレる事がある。

+ ulimit -a
(前略)
nofiles              8192  # <= 655360 に設定したはずなのに 8192に 減ってる
(後略)

これではjenkinsで想定通りの実行ができなくて不便である。

原因

そういう時は /etc/default/jenkins の中身を疑ってみる。

/etc/default/jenkins
(前略)
# OS LIMITS SETUP
#   comment this out to observe /etc/security/limits.conf
#   this is on by default because http://github.com/jenkinsci/jenkins/commit/2fb288474e980d0e7ff9c4a3b768874835a3e92e
#   reported that Ubuntu's PAM configuration doesn't include pam_limits.so, and as a result the # of file
#   descriptors are forced to 1024 regardless of /etc/security/limits.conf
MAXOPENFILES=8192

jenkins起動時にここの数値でulimitの値を上書きするので結果が狂う。
詳細に関しては /etc/init.d/jenkins スクリプト中に書いてある。

/etc/init.d/jenkins/
    (中略)
    # If the var MAXOPENFILES is enabled in /etc/default/jenkins then set the max open files to the 
    # proper value
    if [ -n "$MAXOPENFILES" ]; then
        [ "$VERBOSE" != no ] && echo Setting up max open files limit to $MAXOPENFILES
        ulimit -n $MAXOPENFILES
    fi
    (後略)

対策

  1. /etc/default/jenkins から該当行を削除する
  2. /etc/default/jenkinsMAXOPENFILES の値を自分好みにする
8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6