Slurmを改造するために必要だったこと(3)


改造依頼

Slurmを改造する仕事の依頼がありました(2年前)。

ジョブを実行してみる

Slurmの動作環境を作成してジョブを実行してみる。
翻訳したドキュメントを参考に環境を作成してみた。
なんとか環境はできた。
sleep(5)ジョブを実行してみる。
動作する。
「OK、動いた」
改造作業のスタートラインについた感じである。

何から調査する

今回の改造は、「Slurmの中央管理デーモン」が対象だと思う...くらいの予測で改造する場所を探す。
で、何から?
プロジェクトにはSlurmシステム内いろいろなデーモンプロセスが混在している。
プログラムは何から始まる?
C言語プログラムなのでmain関数だなぁ...で、main関数をgrepする。
39本ありました(テストプログラム関係は除く)。
この中で「Slurmの中央管理デーモン」のmain関数を探す。
どれやん

/slurm-20.02.3/src/slurmctld/controller.c
/*****************************************************************************\
 *  controller.c - main control machine daemon for slurm
 *****************************************************************************
 *  Copyright (C) 2002-2007 The Regents of the University of California.
 *  Copyright (C) 2008-2010 Lawrence Livermore National Security.
 *  Portions Copyright (C) 2010-2016 SchedMD LLC.
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 *  Written by Morris Jette <[email protected]>, Kevin Tew <[email protected]>
 *  CODE-OCEC-09-009. All rights reserved.
 *
 *  This file is part of Slurm, a resource management program.
 *  For details, see <https://slurm.schedmd.com/>.
 *  Please also read the included file: DISCLAIMER.
 *
 *  Slurm is free software; you can redistribute it and/or modify it under
 *  the terms of the GNU General Public License as published by the Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  In addition, as a special exception, the copyright holders give permission
 *  to link the code of portions of this program with the OpenSSL library under
 *  certain conditions as described in each individual source file, and
 *  distribute linked combinations including the two. You must obey the GNU
 *  General Public License in all respects for all of the code used other than
 *  OpenSSL. If you modify file(s) with this exception, you may extend this
 *  exception to your version of the file(s), but you are not obligated to do
 *  so. If you do not wish to do so, delete this exception statement from your
 *  version.  If you delete this exception statement from all source files in
 *  the program, then also delete it here.
 *
 *  Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 *  details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with Slurm; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
\*****************************************************************************/
//. ************************************************** ************************* \
//.   controller.c-slurmのメイン制御マシンデーモン
//. ************************************************** *************************
//.   Copyright(C)2002-2007 The Regents of the University of California。
//.   Copyright(C)2008-2010 Lawrence Livermore National Security。
//.   一部(Copyright(C)2010-2016 SchedMD LLC。
//.   ローレンスリバモア国立研究所で製造(cf、DISCLAIMER)。
//.   Morris Jette <[email protected]>、Kevin Tew <[email protected]>によって作成
//.   CODE-OCEC-09-009。全著作権所有。
//. 
//.   このファイルは、リソース管理プログラムであるSlurmの一部です。
//.   詳細については、<https://slurm.schedmd.com/>を参照してください。
//.   含まれているファイル:免責事項もお読みください。
//. 
//.   Slurmはフリーソフトウェアです。あなたはそれを再配布および/またはそれを修正することができます
//.   Freeが発行したGNU General Public Licenseの条件
//.   ソフトウェア財団; ライセンスのバージョン2、または(オプション)
//.   それ以降のバージョン。
//. 
//.   また、特別な例外として、著作権者は許可を与えます
//.   このプログラムの一部のコードをOpenSSLライブラリとリンクするには
//.   個々のソースファイルに記述されている特定の条件
//.   2つを含むリンクされた組み合わせを配布します。GNUに従う必要があります
//.   使用されるすべてのコードのあらゆる点で一般公衆利用許諾契約書
//.   OpenSSL。この例外を使用してファイルを変更した場合、これを拡張できます
//.   ファイルのバージョンに例外がありますが、実行する義務はありません
//.   そう。そうしたくない場合は、この例外ステートメントを
//.   バージョン。この例外ステートメントをすべてのソースファイルから削除すると、
//.   プログラムを削除し、ここで削除します。
//. 
//.   Slurmは、それが役立つことを期待して配布されていますが、
//.   保証; 商品性または適合性の暗黙の保証さえありません
//.   特定の目的のため。詳細については、GNU General Public Licenseを参照してください
//.   詳細。
//. 
//.   あなたは一緒にGNU General Public Licenseのコピーを受け取っているはずです
//.   スラムと; そうでない場合は、Free Software Foundation、Inc.
//.   51 Franklin Street、Fifth Floor、Boston、MA 02110-1301 USA。
//. \ ************************************************* **************************

/* main - slurmctld main function, start various threads and process RPCs */
//.  main-slurmctld main関数、さまざまなスレッドを開始してRPCを処理します 
int main(int argc, char **argv)
{
    ...

でしょう。という感じでみつける。
プログラムに記述されているコメント(日本語化もしたし)からもみつける。
正しいかどうかは、プログラムにログを書いてデーモン実行時にそのログが出力されるかどうかで判定した。
このmain関数は、500Stepほどある。
呼出される関数もそれなりに多く、デーモンらしく無限ループになっている。

どう調査を進める

ログを入れて実行してどんな構成になっているかを地味に地味に探していくしかない。
まぁ、そんなジョブでした。