SPANK

Section: Slurm Component (8)
Updated: Slurm Component
Index

 

NAME

SPANK - Slurm Plug-in Architecture for Node and job (K)control
SPANK-ノードおよびジョブ(K)制御用のSlurmプラグインアーキテクチャ

 

DESCRIPTION

This manual briefly describes the capabilities of the Slurm Plug-in architecture for Node and job Kontrol (SPANK) as well as the SPANK configuration file: (By default: plugstack.conf.)
このマニュアルでは、ノードおよびジョブKontrol(SPANK)のSlurmプラグインアーキテクチャの機能と、SPANK構成ファイルについて簡単に説明します(デフォルトでは、plugstack.conf)。

SPANK provides a very generic interface for stackable plug-ins which may be used to dynamically modify the job launch code in Slurm.
SPANKは、Slurmのジョブ起動コードを動的に変更するために使用できるスタック可能なプラグイン用の非常に一般的なインターフェイスを提供します。
SPANK plugins may be built without access to Slurm source code.
SPANKプラグインは、Slurmソースコードにアクセスせずにビルドできます。
They need only be compiled against Slurm's spank.h header file, added to the SPANK config file plugstack.conf, and they will be loaded at runtime during the next job launch.
これらは、Slurmのspank.hヘッダーファイルに対してコンパイルして、SPANK構成ファイルplugstack.confに追加するだけでよく、次回のジョブの起動時に実行時にロードされます。
Thus, the SPANK infrastructure provides administrators and other developers a low cost, low effort ability to dynamically modify the runtime behavior of Slurm job launch.
したがって、SPANKインフラストラクチャは、管理者やその他の開発者に、Slurmジョブ起動のランタイム動作を動的に変更するための低コスト、低労力の機能を提供します。

Note: SPANK plugins using the Slurm APIs need to be recompiled when upgrading Slurm to a new major release.
注:Slurmを新しいメジャーリリースにアップグレードする場合、Slurm APIを使用するSPANKプラグインを再コンパイルする必要があります。

 

SPANK PLUGINS

SPANK plugins are loaded in up to five separate contexts during a Slurm job. Briefly, the five contexts are:
SPANKプラグインは、Slurmジョブ中に最大5つの個別のコンテキストに読み込まれます。簡単に言えば、5つのコンテキストは次のとおりです。
local
In local context, the plugin is loaded by srun. (i.e. the "local" part of a parallel job).
ローカルコンテキストでは、プラグインはsrunによってロードされます。(つまり、並列ジョブの「ローカル」部分)。
remote
In remote context, the plugin is loaded by slurmstepd. (i.e. the "remote" part of a parallel job).
リモートコンテキストでは、プラグインはslurmstepdによってロードされます。(つまり、並列ジョブの「リモート」部分)。
allocator
In allocator context, the plugin is loaded in one of the job allocation utilities sbatch or salloc.
アロケータのコンテキストでは、プラグインはジョブ割り当てユーティリティsbatchまたはsallocのいずれかに読み込まれます。

slurmd In slurmd context, the plugin is loaded in the
slurmd daemon itself.
slurmd slurmdコンテキストでは、プラグインはslurmdデーモン自体にロードされます。
Note: Plugins loaded in slurmd context persist for the entire time slurmd is running, so if configuration is changed or plugins are updated, slurmd must be restarted for the changes to take effect.
注:slurmdコンテキストでロードされたプラグインは、slurmdの実行中ずっと持続するため、構成を変更したりプラグインを更新したりした場合、変更を有効にするにはslurmdを再起動する必要があります。

job_script
In the job_script context, plugins are loaded in the context of the job prolog or epilog.
job_scriptコンテキストでは、プラグインはジョブのプロローグまたはエピローグのコンテキストでロードされます。
Note: Plugins are loaded in job_script context on each run on the job prolog or epilog, in a separate address space from plugins in slurmd context.
注:プラグインは、slurmdコンテキストのプラグインとは別のアドレス空間で、ジョブのプロローグまたはエピローグで実行されるたびにjob_scriptコンテキストに読み込まれます。
This means there is no state shared between this context and other contexts, or even between one call to slurm_spank_job_prolog or slurm_spank_job_epilog and subsequent calls.
つまり、このコンテキストと他のコンテキストの間、またはslurm_spank_job_prologまたはslurm_spank_job_epilogへの1つの呼び出しと後続の呼び出しの間で共有される状態はありません。

In local context, only the init, exit, init_post_opt, and local_user_init functions are called.
ローカルコンテキストでは、init、exit、init_post_opt、およびlocal_user_init関数のみが呼び出されます。
In allocator context, only the init, exit, and init_post_opt functions are called.
アロケータコンテキストでは、init、exit、およびinit_post_opt関数のみが呼び出されます。
Similarly, in slurmd context, only the init and slurmd_exit callbacks are active, and in the job_script context, only the job_prolog and job_epilog callbacks are used.
同様に、slurmdコンテキストでは、initコールバックとslurmd_exitコールバックのみがアクティブになり、job_scriptコンテキストでは、job_prologとjob_epilogコールバックのみが使用されます。
Plugins may query the context in which they are running with the spank_context and spank_remote functions defined in <slurm/spank.h>.
プラグインは、定義されているspank_contextおよびspank_remote関数を使用して、プラグインが実行されているコンテキストをクエリできます。 。

SPANK plugins may be called from multiple points during the Slurm job launch. A plugin may define the following functions:
SPANKプラグインは、Slurmジョブの起動中に複数のポイントから呼び出される場合があります。プラグインは、次の関数を定義できます。

slurm_spank_init
Called just after plugins are loaded. In remote context, this is just after job step is initialized.
プラグインが読み込まれた直後に呼び出されます。リモートコンテキストでは、これはジョブステップが初期化された直後です。
This function is called before any plugin option processing.
この関数は、プラグインオプション処理の前に呼び出されます。
slurm_spank_job_prolog
Called at the same time as the job prolog. If this function returns a negative value and the SPANK plugin that contains it is required in the plugstack.conf, the node that this is run on will be drained.
ジョブプロローグと同時に呼び出されます。この関数が負の値を返し、それを含むSPANKプラグインがplugstack.confで必要な場合、これが実行されるノードはドレインされます。

slurm_spank_init_post_opt
Called at the same point as slurm_spank_init, but after all user options to the plugin have been processed.
slurm_spank_initと同じ時点で呼び出されますが、プラグインへのすべてのユーザーオプションが処理された後。
The reason that the init and init_post_opt callbacks are separated is so that plugins can process system-wide options specified in plugstack.conf in the init callback, then process user options, and finally take some action in slurm_spank_init_post_opt if necessary.
initとinit_post_optのコールバックが分離されている理由は、プラグインがinitコールバックのplugstack.confで指定されたシステム全体のオプションを処理し、次にユーザーオプションを処理し、必要に応じてslurm_spank_init_post_optで最終的にアクションを実行できるようにするためです。
In the case of a heterogeneous job, slurm_spank_init is invoked once per job component.
異機種混合ジョブの場合、slurm_spank_initはジョブコンポーネントごとに1回呼び出されます。
slurm_spank_local_user_init
Called in local (srun) context only after all options have been processed.
すべてのオプションが処理された後にのみ、ローカル(実行)コンテキストで呼び出されます。
This is called after the job ID and step IDs are available.
これは、ジョブIDとステップIDが使用可能になった後に呼び出されます。
This happens in srun after the allocation is made, but before tasks are launched.
これは、割り当てが行われた後、タスクが起動される前のsrunで発生します。
slurm_spank_user_init
Called after privileges are temporarily dropped. (remote context only)
特権が一時的に削除された後に呼び出されます。(リモートコンテキストのみ)
slurm_spank_task_init_privileged
Called for each task just after fork, but before all elevated privileges are dropped. (remote context only)
forkの後、すべての昇格された特権が削除される前に、各タスクに対して呼び出されます。(リモートコンテキストのみ)
slurm_spank_task_init
Called for each task just before execve (2). If you are restricing memory with cgroups, memory allocated here will be in the job's cgroup. (remote context only)
execve(2)の直前に各タスクに対して呼び出されます。cgroupでメモリを制限している場合、ここで割り当てられたメモリはジョブのcgroupにあります。(リモートコンテキストのみ)
slurm_spank_task_post_fork
Called for each task from parent process after fork (2) is complete.
fork(2)が完了した後、親プロセスからタスクごとに呼び出されます。
Due to the fact that slurmd does not exec any tasks until all tasks have completed fork (2), this call is guaranteed to run before the user task is executed. (remote context only)
slurmdはすべてのタスクがfork(2)を完了するまでタスクを実行しないため、この呼び出しはユーザータスクが実行される前に実行されることが保証されています。(リモートコンテキストのみ)
slurm_spank_task_exit
Called for each task as its exit status is collected by Slurm.
終了ステータスがSlurmによって収集されるときに、各タスクに対して呼び出されます。
(remote context only)
slurm_spank_exit
Called once just before slurmstepd exits in remote context.
slurmstepdがリモートコンテキストで終了する直前に1回呼び出されます。
In local context, called before srun exits.
ローカルコンテキストでは、srunが終了する前に呼び出されます。
slurm_spank_job_epilog
Called at the same time as the job epilog. If this function returns a negative value and the SPANK plugin that contains it is required in the plugstack.conf, the node that this is run on will be drained.
ジョブのエピローグと同時に呼び出されます。この関数が負の値を返し、それを含むSPANKプラグインがplugstack.confで必要な場合、これが実行されるノードはドレインされます。
slurm_spank_slurmd_exit
Called in slurmd when the daemon is shut down.
デーモンのシャットダウン時にslurmdで呼び出されます。

All of these functions have the same prototype, for example:
これらの関数はすべて同じプロトタイプを持っています。次に例を示します。


   int slurm_spank_init (spank_t spank, int ac, char *argv[])

Where spank is the SPANK handle which must be passed back to Slurm when the plugin calls functions like spank_get_item and spank_getenv.
ここで、spankは、プラグインがspank_get_itemやspank_getenvなどの関数を呼び出すときにSlurmに返される必要があるSPANKハンドルです。
Configured arguments (See CONFIGURATION below) are passed in the argument vector argv with argument count ac.
構成された引数(以下のCONFIGURATIONを参照)は、引数ベクトルargvに引数カウントacで渡されます。

SPANK plugins can query the current list of supported slurm_spank symbols to determine if the current version supports a given plugin hook.
SPANKプラグインは、サポートされているslurm_spankシンボルの現在のリストを照会して、現在のバージョンが特定のプラグインフックをサポートしているかどうかを判断できます。
This may be useful because the list of plugin symbols may grow in the future.
プラグインシンボルのリストは将来的に大きくなる可能性があるため、これは役立ちます。
The query is done using the spank_symbol_supported function, which has the following prototype:
クエリは、次のプロトタイプを持つspank_symbol_supported関数を使用して行われます。


    int spank_symbol_supported (const char *sym);

The return value is 1 if the symbol is supported, 0 if not.
シンボルがサポートされている場合、戻り値は1、サポートされていない場合、0です。

SPANK plugins do not have direct access to internally defined Slurm data structures.
SPANKプラグインは、内部で定義されたSlurmデータ構造に直接アクセスできません。
Instead, information about the currently executing job is obtained via the spank_get_item function call.
代わりに、現在実行中のジョブに関する情報は、spank_get_item関数呼び出しを介して取得されます。


  spank_err_t spank_get_item (spank_t spank, spank_item_t item, ...);

The spank_get_item call must be passed the current SPANK handle as well as the item requested, which is defined by the passed spank_item_t.
spank_get_item呼び出しには、現在のSPANKハンドルと、渡されたspank_item_tで定義されているリクエストされたアイテムを渡す必要があります。
A variable number of pointer arguments are also passed, depending on which item was requested by the plugin.
プラグインによって要求された項目に応じて、可変数のポインター引数も渡されます。
A list of the valid values for item is kept in the spank.h header file. Some examples are:
itemの有効な値のリストは、spank.hヘッダーファイルに保持されます。次に例を示します。
S_JOB_UID
User id for running job. (uid_t *) is third arg of spank_get_item
ジョブを実行するためのユーザーID。(uid_t *)はspank_get_itemの3番目の引数です
S_JOB_STEPID
Job step id for running job. (uint32_t *) is third arg of spank_get_item.
実行中のジョブのジョブステップID。(uint32_t *)はspank_get_itemの3番目の引数です。
S_TASK_EXIT_STATUS
Exit status for exited task. Only valid from slurm_spank_task_exit.
終了したタスクの終了ステータス。slurm_spank_task_exitからのみ有効です。
(int *) is third arg of spank_get_item.
S_JOB_ARGV
Complete job command line. Third and fourth args to spank_get_item are (int *, char ***).
完全なジョブコマンドライン。spank_get_itemの3番目と4番目の引数は(int *、char ***)です。

See spank.h for more details, and EXAMPLES below for an example of spank_get_item usage.
詳細についてはspank.hを、spank_get_itemの使用例については以下の例を参照してください。

SPANK functions in the local and allocator environment should use the getenv, setenv, and unsetenv functions to view and modify the job's environment.
ローカル環境およびアロケーター環境のSPANK関数は、getenv、setenv、およびunsetenv関数を使用して、ジョブの環境を表示および変更する必要があります。
SPANK functions in the remote environment should use the spank_getenv, spank_setenv, and spank_unsetenv functions to view and modify the job's environment.
リモート環境のSPANK関数は、spank_getenv、spank_setenv、およびspank_unsetenv関数を使用して、ジョブの環境を表示および変更する必要があります。
spank_getenv searches the job's environment for the environment variable var and copies the current value into a buffer buf of length len.
spank_getenvは、ジョブの環境で環境変数varを検索し、現在の値を長さlenのバッファーbufにコピーします。
spank_setenv allows a SPANK plugin to set or overwrite a variable in the job's environment, and spank_unsetenv unsets an environment variable in the job's environment.
spank_setenvを使用すると、SPANKプラグインでジョブの環境の変数を設定または上書きでき、spank_unsetenvを使用すると、ジョブの環境の環境変数を設定解除できます。
The prototypes are:
プロトタイプは次のとおりです。


 spank_err_t spank_getenv (spank_t spank, const char *var,
                           char *buf, int len);
 spank_err_t spank_setenv (spank_t spank, const char *var,
                           const char *val, int overwrite);
 spank_err_t spank_unsetenv (spank_t spank, const char *var);

These are only necessary in remote context since modifications of the standard process environment using setenv (3), getenv (3), and unsetenv (3) may be used in local context.
setenv(3)、getenv(3)、およびunsetenv(3)を使用した標準プロセス環境の変更はローカルコンテキストで使用できるため、これらはリモートコンテキストでのみ必要です。

Functions are also available from within the SPANK plugins to establish environment variables to be exported to the Slurm PrologSlurmctld, Prolog, Epilog and EpilogSlurmctld programs (the so-called job control environment).
SPANKプラグイン内からも関数を使用して、Slurm PrologSlurmctld、Prolog、Epilog、およびEpilogSlurmctldプログラム(いわゆるジョブ制御環境)にエクスポートされる環境変数を確立できます。
The name of environment variables established by these calls will be prepended with the string SPANK_ in order to avoid any security implications of arbitrary environment variable control. (After all, the job control scripts do run as root or the Slurm user.).
これらの呼び出しによって確立された環境変数の名前には、任意の環境変数制御によるセキュリティへの影響を回避するために、文字列SPANK_が先頭に追加されます。(結局のところ、ジョブ制御スクリプトはrootまたはSlurmユーザーとして実行されます。)

These functions are available from local context only.
これらの関数は、ローカルコンテキストからのみ使用できます。


  spank_err_t spank_job_control_getenv(spank_t spank, const char *var,
                             char *buf, int len);
  spank_err_t spank_job_control_setenv(spank_t spank, const char *var,
                             const char *val, int overwrite);
  spank_err_t spank_job_control_unsetenv(spank_t spank, const char *var);

See spank.h for more information, and EXAMPLES below for an example for spank_getenv usage.
詳細についてはspank.hを、spank_getenvの使用例については以下の例を参照してください。

Many of the described SPANK functions available to plugins return errors via the spank_err_t error type.
プラグインで使用できる説明されているSPANK関数の多くは、エラータイプspank_err_tを介してエラーを返します。
On success, the return value will be set to ESPANK_SUCCESS, while on failure, the return value will be set to one of many error values defined in slurm/spank.h.
成功した場合、戻り値はESPANK_SUCCESSに設定され、失敗した場合、戻り値はslurm / spank.hで定義されている多くのエラー値の1つに設定されます。
The SPANK interface provides a simple function
SPANKインターフェースはシンプルな機能を提供します


  const char * spank_strerror(spank_err_t err);

which may be used to translate a spank_err_t value into its string representation.
これは、spank_err_t値を文字列表現に変換するために使用できます。

The slurm_spank_log function can be used to print messages back to the user at an error level.
slurm_spank_log関数を使用して、エラーレベルでメッセージをユーザーに返すことができます。
This is to keep users from having to rely on the slurm_error function, which can be confusing because it prepends "error:" to every message.
これは、ユーザーがslurm_error関数に依存する必要がないようにするためです。この関数は、すべてのメッセージに「error:」を付加するため、混乱を招く可能性があります。

 

SPANK OPTIONS

SPANK plugins also have an interface through which they may define and implement extra job options.
SPANKプラグインには、追加のジョブオプションを定義および実装するためのインターフェイスもあります。
These options are made available to the user through Slurm commands such as srun(1), salloc(1), and sbatch(1).
これらのオプションは、srun(1)、salloc(1)、sbatch(1)などのSlurmコマンドを介してユーザーが利用できます。
If the option is specified by the user, its value is forwarded and registered with the plugin in slurmd when the job is run.
ユーザーがオプションを指定した場合、その値は転送され、ジョブの実行時にslurmdのプラグインに登録されます。
In this way, SPANK plugins may dynamically provide new options and functionality to Slurm.
このようにして、SPANKプラグインは新しいオプションと機能をSlurmに動的に提供できます。

Each option registered by a plugin to Slurm takes the form of a struct spank_option which is declared in <slurm/spank.h> as
プラグインによってSlurmに登録された各オプションは、以下で宣言されているstruct spank_optionの形式を取ります。 なので


   struct spank_option {
      char *         name;
      char *         arginfo;
      char *         usage;
      int            has_arg;
      int            val;
      spank_opt_cb_f cb;
   };

Where

name
is the name of the option. Its length is limited to SPANK_OPTION_MAXLEN defined in <slurm/spank.h>.
オプションの名前です。その長さは、で定義されているSPANK_OPTION_MAXLENに制限されています。。
arginfo
is a description of the argument to the option, if the option does take an argument.
オプションが引数を取る場合の、オプションの引数の説明です。
usage
is a short description of the option suitable for --help output.
--helpの出力に適したオプションの簡単な説明です。
has_arg
0 if option takes no argument, 1 if option takes an argument, and 2 if the option takes an optional argument. (See getopt_long (3)).
オプションが引数を取らない場合は0、オプションが引数を取る場合は1、オプションがオプションの引数を取る場合は2。(getopt_long(3)を参照してください)。
val
A plugin-local value to return to the option callback function.
オプションのコールバック関数に戻るためのプラグインローカル値。
cb
A callback function that is invoked when the plugin option is registered with Slurm.
プラグインオプションがSlurmに登録されたときに呼び出されるコールバック関数。
spank_opt_cb_f is typedef'd in <slurm/spank.h> as
spank_opt_cb_fはtypedefされています なので

  typedef int (*spank_opt_cb_f) (int val, const char *optarg,
                                 int remote);

Where val is the value of the val field in the spank_option struct, optarg is the supplied argument if applicable, and remote is 0 if the function is being called from the "local" host (e.g. host where srun or sbatch/salloc are invoked) or 1 from the "remote" host (host where slurmd/slurmstepd run) but only executed by slurmstepd (remote context) if the option was registered for such context.
valはspank_option構造体のvalフィールドの値であり、optargは該当する場合は指定された引数であり、remoteは、関数が「ローカル」ホスト(たとえば、srunまたはsbatch / sallocが呼び出されるホスト)から呼び出されている場合は0です。または「リモート」ホスト(slurmd / slurmstepdが実行されるホスト)から1ですが、オプションがそのようなコンテキストに登録されている場合、slurmstepd(リモートコンテキスト)によってのみ実行されます。

Plugin options may be registered with Slurm using the spank_option_register function.
プラグインオプションは、spank_option_register関数を使用してSlurmに登録できます。
This function is only valid when called from the plugin's slurm_spank_init handler, and registers one option at a time. The prototype is
この関数は、プラグインのslurm_spank_initハンドラーから呼び出されたときにのみ有効で、一度に1つのオプションを登録します。プロトタイプは


   spank_err_t spank_option_register (spank_t sp,
                   struct spank_option *opt);

This function will return ESPANK_SUCCESS on successful registration of an option, or ESPANK_BAD_ARG for errors including invalid spank_t handle, or when the function is not called from the slurm_spank_init function.
この関数は、オプションが正常に登録されるとESPANK_SUCCESSを返し、無効なspank_tハンドルを含むエラーの場合、または関数がslurm_spank_init関数から呼び出されない場合はESPANK_BAD_ARGを返します。
All options need to be registered from all contexts in which they will be used.
すべてのオプションは、それらが使用されるすべてのコンテキストから登録する必要があります。
For instance, if an option is only used in local (srun) and remote (slurmd) contexts, then spank_option_register should only be called from within those contexts. For example:
たとえば、オプションがローカル(srun)およびリモート(slurmd)コンテキストでのみ使用されている場合、spank_option_registerはこれらのコンテキスト内からのみ呼び出す必要があります。例えば:

   if (spank_context() != S_CTX_ALLOCATOR)
      spank_option_register (sp, opt);

If, however, the option is used in all contexts, the spank_option_register needs to be called everywhere.
ただし、オプションがすべてのコンテキストで使用される場合は、spank_option_registerをどこでも呼び出す必要があります。

In addition to spank_option_register, plugins may also export options to Slurm by defining a table of struct spank_option with the symbol name spank_options.
spank_option_registerに加えて、プラグインは、シンボル名spank_optionsでstruct spank_optionのテーブルを定義することにより、オプションをSlurmにエクスポートすることもできます。
This method, however, is not supported for use with sbatch and salloc (allocator context), thus the use of spank_option_register is preferred.
ただし、このメソッドはsbatchおよびsalloc(アロケーターコンテキスト)での使用はサポートされていないため、spank_option_registerの使用をお勧めします。
When using the spank_options table, the final element in the array must be filled with zeros.
spank_optionsテーブルを使用する場合、配列の最後の要素はゼロで埋める必要があります。
A SPANK_OPTIONS_TABLE_END macro is provided in <slurm/spank.h> for this purpose.
SPANK_OPTIONS_TABLE_ENDマクロは この目的のために。

When an option is provided by the user on the local side, either by command line options or by environment variables, Slurm will immediately invoke the option's callback with remote=0.
ローカル側のユーザーがオプションをコマンドラインオプションまたは環境変数によって提供すると、Slurmは、remote = 0を指定してオプションのコールバックをすぐに呼び出します。
This is meant for the plugin to do local sanity checking of the option before the value is sent to the remote side during job launch.
これは、ジョブの起動中に値がリモート側に送信される前に、プラグインがオプションのローカルサニティチェックを行うことを目的としています。
If the argument the user specified is invalid, the plugin should issue an error and issue a non-zero return code from the callback.
ユーザーが指定した引数が無効な場合、プラグインはエラーを発行し、コールバックからゼロ以外の戻りコードを発行します。
The plugin should be able to handle cases where the spank option is set multiple times through environment variables and command line options.
プラグインは、spankオプションが環境変数とコマンドラインオプションを介して複数回設定されている場合を処理できる必要があります。
Environment variables are processed before command line options.
環境変数は、コマンドラインオプションの前に処理されます。

On the remote side, options and their arguments are registered just after SPANK plugins are loaded and before the spank_init handler is called.
リモート側では、オプションとその引数は、SPANKプラグインがロードされた直後で、spank_initハンドラーが呼び出される前に登録されます。
This allows plugins to modify behavior of all plugin functionality based on the value of user-provided options.
これにより、プラグインは、ユーザーが提供するオプションの値に基づいて、すべてのプラグイン機能の動作を変更できます。
(See EXAMPLES below for a plugin that registers an option with Slurm).
(オプションをSlurmに登録するプラグインについては、以下の例を参照してください)。

As an alternative to use of an option callback and global variable, plugins can use the spank_option_getopt option to check for supplied options after option processing. This function has the prototype:
オプションコールバックとグローバル変数を使用する代わりに、プラグインはspank_option_getoptオプションを使用して、オプション処理後に指定されたオプションを確認できます。この関数にはプロトタイプがあります:


   spank_err_t spank_option_getopt(spank_t sp,
       struct spank_option *opt, char **optargp);

This function returns ESPANK_SUCCESS if the option defined in the
struct spank_option opt has been used by the user. If optargp
is non-NULL then it is set to any option argument passed (if the option
takes an argument). The use of this method is required to process
options in job_script context (slurm_spank_job_prolog and
slurm_spank_job_epilog). This function is valid in the following contexts:
slurm_spank_job_prolog, slurm_spank_local_user_init, slurm_spank_user_init,
slurm_spank_task_init_privileged, slurm_spank_task_init, slurm_spank_task_exit,
and slurm_spank_job_epilog.

 

CONFIGURATION

The default SPANK plug-in stack configuration file is plugstack.conf in the same directory as slurm.conf(5), though this may be changed via the Slurm config parameter PlugStackConfig.
デフォルトのSPANKプラグインスタック構成ファイルは、slurm.conf(5)と同じディレクトリにあるplugstack.confですが、Slurm構成パラメーターPlugStackConfigを使用して変更できます。
Normally the plugstack.conf file should be identical on all nodes of the cluster.
通常、plugstack.confファイルは、クラスターのすべてのノードで同一である必要があります。
The config file lists SPANK plugins, one per line, along with whether the plugin is required or optional, and any global arguments that are to be passed to the plugin for runtime configuration.
設定ファイルには、SPANKプラグインが1行に1つずつ、プラグインが必須かオプションか、およびランタイム設定のためにプラグインに渡されるグローバル引数がリストされています。
Comments are preceded with '#' and extend to the end of the line.
コメントの前には「#」が付き、行末まで続きます。
If the configuration file is missing or empty, it will simply be ignored.
構成ファイルがないか空の場合、単に無視されます。

The format of each non-comment line in the configuration file is:
構成ファイルのコメント行以外の各行の形式は次のとおりです。


  required/optional   plugin   arguments

For example:

  optional /usr/lib/slurm/test.so

Tells slurmd to load the plugin test.so passing no arguments.
引数を渡さずにプラグインtest.soをロードするようにslurmdに指示します。
If a SPANK plugin is required, then failure of any of the plugin's functions will cause slurmd to terminate the job, while optional plugins only cause a warning.
SPANKプラグインが必要な場合、プラグインの機能のいずれかが失敗するとslurmdはジョブを終了しますが、オプションのプラグインは警告のみを発生させます。

If a fully-qualified path is not specified for a plugin, then the currently configured PluginDir in slurm.conf(5) is searched.
プラグインに完全修飾パスが指定されていない場合、slurm.conf(5)で現在構成されているPluginDirが検索されます。

SPANK plugins are stackable, meaning that more than one plugin may be placed into the config file.
SPANKプラグインはスタック可能です。つまり、構成ファイルに複数のプラグインを配置できます。
The plugins will simply be called in order, one after the other, and appropriate action taken on failure given that state of the plugin's optional flag.
プラグインは、順番に順番に呼び出され、プラグインのオプションフラグの状態に応じて、失敗時に適切なアクションが実行されます。

Additional config files or directories of config files may be included in plugstack.conf with the include keyword. The include keyword must appear on its own line, and takes a glob as its parameter, so multiple files may be included from one include line.
追加の構成ファイルまたは構成ファイルのディレクトリは、includeキーワードを使用してplugstack.confに含めることができます。includeキーワードは独自の行に表示する必要があり、globをパラメーターとして使用するため、1つのinclude行から複数​​のファイルを含めることができます。
For example, the following syntax will load all config files in the /etc/slurm/plugstack.conf.d directory, in local collation order:
たとえば、次の構文は、/ etc / slurm / plugstack.conf.dディレクトリ内のすべての構成ファイルをローカルの照合順序でロードします。


  include /etc/slurm/plugstack.conf.d/*

which might be considered a more flexible method for building up a spank plugin stack.
これは、spankプラグインスタックを構築するためのより柔軟な方法と考えられます。

The SPANK config file is re-read on each job launch, so editing the config file will not affect running jobs.
SPANK構成ファイルはジョブの起動ごとに再読み取りされるため、構成ファイルを編集しても、実行中のジョブには影響しません。
However care should be taken so that a partially edited config file is not read by a launching job.
ただし、部分的に編集された構成ファイルが起動ジョブによって読み取られないように注意する必要があります。

 

EXAMPLES

Simple SPANK config file:


#
# SPANK config file
#
# required?       plugin                     args
#
optional          renice.so                  min_prio=-10
required          /usr/lib/slurm/test.so

The following is a simple SPANK plugin to modify the nice value of job tasks.
以下は、ジョブタスクのnice値を変更する単純なSPANKプラグインです。
This plugin adds a --renice=[prio] option to srun which users can use to set the priority of all remote tasks.
このプラグインは--renice = [prio]オプションをsrunに追加し、ユーザーがすべてのリモートタスクの優先順位を設定するために使用できるようにします。
Priority may also be specified via a SLURM_RENICE environment variable.
優先順位は、SLURM_RENICE環境変数を介して指定することもできます。
A minimum priority may be established via a "min_prio" parameter in plugstack.conf (See above for example).
最小の優先度は、plugstack.confの「min_prio」パラメータを使用して設定できます(上記を参照)。


/*
 *   To compile:
 *    gcc -shared -o renice.so renice.c
 *
 */
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/resource.h>

#include <slurm/spank.h>

/*
 * All spank plugins must define this macro for the
 * Slurm plugin loader.
 */
SPANK_PLUGIN(renice, 1);

#define PRIO_ENV_VAR "SLURM_RENICE"
#define PRIO_NOT_SET 42

/*
 * Minimum allowable value for priority. May be
 * set globally via plugin option min_prio=<prio>
 */
static int min_prio = -20;

static int prio = PRIO_NOT_SET;

static int _renice_opt_process (int val,
                                const char *optarg,
                                int remote);
static int _str2prio (const char *str, int *p2int);

/*
 *  Provide a --renice=[prio] option to srun:
 */
struct spank_option spank_options[] =
{
    { "renice", "[prio]",
      "Re-nice job tasks to priority [prio].", 2, 0,
      (spank_opt_cb_f) _renice_opt_process
    },
    SPANK_OPTIONS_TABLE_END
};

/*
 *  Called from both srun and slurmd.
 */
int slurm_spank_init (spank_t sp, int ac, char **av)
{
    int i;

    /* Don't do anything in sbatch/salloc */
    if (spank_context () == S_CTX_ALLOCATOR)
        return (0);

    for (i = 0; i < ac; i++) {
        if (strncmp ("min_prio=", av[i], 9) == 0) {
            const char *optarg = av[i] + 9;
            if (_str2prio (optarg, &min_prio) < 0)
                slurm_error ("Ignoring invalid min_prio value: %s",
                             av[i]);
        } else {
            slurm_error ("renice: Invalid option: %s", av[i]);
        }
    }

    if (!spank_remote (sp))
        slurm_verbose ("renice: min_prio = %d", min_prio);

    return (0);
}


int slurm_spank_task_post_fork (spank_t sp, int ac, char **av)
{
    pid_t pid;
    int taskid;

    if (prio == PRIO_NOT_SET) {
        /* See if SLURM_RENICE env var is set by user */
        char val [1024];

        if (spank_getenv (sp, PRIO_ENV_VAR, val, 1024)
            != ESPANK_SUCCESS)
            return (0);

        if (_str2prio (val, &prio) < 0) {
            slurm_error ("Bad value for %s: %s",
                         PRIO_ENV_VAR, optarg);
            return (-1);
        }

        if (prio < min_prio) {
            slurm_error ("%s=%d not allowed, using min=%d",
                         PRIO_ENV_VAR, prio, min_prio);
        }
    }

    if (prio < min_prio)
        prio = min_prio;

    spank_get_item (sp, S_TASK_GLOBAL_ID, &taskid);
    spank_get_item (sp, S_TASK_PID, &pid);

    slurm_info ("re-nicing task%d pid %ld to %ld",
                taskid, pid, prio);

    if (setpriority (PRIO_PROCESS, (int) pid,
                     (int) prio) < 0) {
        slurm_error ("setpriority: %m");
        return (-1);
    }

    return (0);
}

static int _str2prio (const char *str, int *p2int)
{
    long int l;
    char *p;

    l = strtol (str, &p, 10);
    if ((*p != ' ') || (l < -20) || (l > 20))
        return (-1);

    *p2int = (int) l;

    return (0);
}

static int _renice_opt_process (int val,
                                const char *optarg,
                                int remote)
{
    if (optarg == NULL) {
        slurm_error ("renice: invalid argument!");
        return (-1);
    }

    if (_str2prio (optarg, &prio) < 0) {
        slurm_error ("Bad value for --renice: %s",
                     optarg);
        return (-1);
    }

    if (prio < min_prio) {
        slurm_error ("--renice=%d not allowed, will use min=%d",
                     prio, min_prio);
    }

    return (0);
}

 

COPYING

Portions copyright (C) 2010-2018 SchedMD LLC. Copyright (C) 2006 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved.

This file is part of Slurm, a resource management program. For details, see <https://slurm.schedmd.com/>.

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.

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.  

FILES

/etc/slurm/slurm.conf - Slurm configuration file.
/etc/slurm/plugstack.conf - SPANK configuration file.
/usr/include/slurm/spank.h - SPANK header file.  

SEE ALSO

srun(1), slurm.conf(5)


 

Index

NAME
DESCRIPTION
SPANK PLUGINS
SPANK OPTIONS
CONFIGURATION
EXAMPLES
COPYING
FILES
SEE ALSO

This document was created by man2html using the manual pages.
Time: 20:44:46 GMT, May 21, 2020