cli_filter Plugin API

Overview

This document describes Slurm cli_filter plugins and the API that defines them. It is intended as a resource to programmers wishing to write their own Slurm cli_filter plugins.
このドキュメントでは、Slurm cli_filterプラグインとそれらを定義するAPIについて説明します。独自のSlurm cli_filterプラグインを作成したいプログラマ向けのリソースとして意図されています。

The purpose of the cli_filter plugins is to provide programmatic hooks during the execution of the salloc, sbatch, and srun command line interface (CLI) programs. Three hooks are defined:
cli_filterプラグインの目的は、salloc、sbatch、およびsrunコマンドラインインターフェイス(CLI)プログラムの実行中にプログラムフックを提供することです。3つのフックが定義されています。

  • setup_defaults — Called before any option processing is done, per job-pack, allowing a plugin to replace default option values.
    setup_defaults —オプション処理が完了する前にジョブパックごとに呼び出され、プラグインがデフォルトのオプション値を置き換えることを可能にします。
  • pre_submit — Called after option processing per job-pack but before any communication is made with the slurm controller. This location is ideal for policy enforcement because the plugin can read all the options supplied by the user (as well as the environment) - thus invalid job requests can be stopped before they ever reach the slurmctld.
    pre_submit —ジョブパックごとのオプション処理の後、ただしslurmコントローラーとの通信が行われる前に呼び出されます。プラグインはユーザー(および環境)が提供するすべてのオプションを読み取ることができるため、この場所はポリシーの施行に最適です。したがって、slurmctldに到達する前に無効なジョブ要求を停止できます。
  • post_submit — Called after the jobid (and, in the case of srun, after the stepid) is generated, and typically before or in parallel with job execution. In combination with data collected in the pre_submit() hook, this is an ideal location for logging activity.
    post_submit —ジョブID(srunの場合はステップIDの後)が生成された後で、通常はジョブ実行の前またはそれと並行して呼び出されます。pre_submit()フックで収集されたデータと組み合わせると、これはアクティビティのロギングに理想的な場所です。
  • cli_filter plugins vary from the job_submit plugin as it is entirely executed client-side, whereas job_submit is processed server-side (within the slurm controller). The benefit of the cli_filter is that it has access to all command line options in a simple and consistent interface as well as being safer to run disruptive operations (e.g., quota checks or other long running operations you might want to use for integrating policy decisions), which can be problematic if run from the controller. The disadvantage of the cli_filter is that it must not be relied upon for security purposes as an enterprising user can circumvent it simply by providing loading an alternate slurm.conf with the CliFilterPlugins option disabled. If you plan to use the cli_filter for managing policies, you should also configure a job_submit plugin to reinforce those policies.
    cli_filterプラグインは、完全にクライアント側で実行されるため、job_submitプラグインとは異なりますが、job_submitはサーバー側で(slurmコントローラー内で)処理されます。cli_filterの利点は、シンプルで一貫性のあるインターフェースですべてのコマンドラインオプションにアクセスできるだけでなく、破壊的な操作(たとえば、クォータチェックや、ポリシーの決定を統合するために使用したい他の長時間実行する操作)を安全に実行できることです。 、コントローラから実行すると問題が発生する可能性があります。cli_filterの不利な点は、進取的なユーザーがCliFilterPluginsオプションを無効にして別のslurm.confをロードすることで簡単に回避できるため、セキュリティの目的でこれを信頼してはならないことです。ポリシーの管理にcli_filterを使用する予定の場合は、job_submitプラグインを構成して、それらのポリシーを強化する必要もあります。

    Slurm cli_filter plugins must conform to the Slurm Plugin API with the following specifications:
    Slurm cli_filterプラグインは、次の仕様のSlurmプラグインAPIに準拠する必要があります。

    const char plugin_name[]="full text name"

    A free-formatted ASCII text string that identifies the plugin.
    プラグインを識別する自由形式のASCIIテキスト文字列。

    const char plugin_type[]="major/minor"

    The major type must be "cli_filter." The minor type can be any suitable name for the type of job submission package. We include samples in the Slurm distribution for
    主なタイプは「cli_filter」である必要があります。マイナータイプは、ジョブ送信パッケージのタイプに適した任意の名前にすることができます。サンプルをSlurmディストリビューションに含めます。

    • none — An empty plugin with no actions taken, a useful starting template for a new plugin.
      none —アクションを実行しない空のプラグイン。新しいプラグインの開始テンプレートとして役立ちます。

    const uint32_t plugin_version
    If specified, identifies the version of Slurm used to build this plugin and any attempt to load the plugin from a different version of Slurm will result in an error. If not specified, then the plugin may be loaded by Slurm commands and daemons from any version, however this may result in difficult to diagnose failures due to changes in the arguments to plugin functions or changes in other Slurm functions used by the plugin.
    指定した場合、このプラグインのビルドに使用されたSlurmのバージョンを識別し、異なるバージョンのSlurmからプラグインをロードしようとすると、エラーが発生します。指定されていない場合、プラグインはSlurmコマンドとデーモンによって任意のバージョンから読み込まれる可能性がありますが、プラグイン関数の引数の変更やプラグインで使用される他のSlurm関数の変更が原因で障害を診断することが困難になる場合があります。

    Slurm can be configured to use multiple cli_filter plugins if desired, however the lua plugin will only execute one lua script named "cli_filter.lua" located in the default script directory (typically the subdirectory "etc" of the installation directory).
    Slurmは、必要に応じて複数のcli_filterプラグインを使用するように構成できますが、luaプラグインは、デフォルトのスクリプトディレクトリ(通常はインストールディレクトリのサブディレクトリなど)にある「cli_filter.lua」という名前の1つのluaスクリプトのみを実行します。

    API Functions

    All of the following functions are required. Functions which are not implemented must be stubbed.
    以下の機能がすべて必要です。実装されていない関数はスタブする必要があります。

    int init(void)

    Description:
    Called when the plugin is loaded, before any other functions are called. Put global initialization here.
    プラグインがロードされたとき、他の関数が呼び出される前に呼び出されます。ここにグローバル初期化を配置します。

    Returns:
    SLURM_SUCCESS on success, or
    SLURM_ERROR on failure.

    void fini(void)

    Description:
    Called when the plugin is removed. Clear any allocated storage here.
    プラグインが削除されたときに呼び出されます。ここで割り当て済みのストレージをすべてクリアします。

    Returns: None.

    Note: These init and fini functions are not the same as those described in the dlopen (3) system library. The C run-time system co-opts those symbols for its own initialization. The system _init() is called before the Slurm init(), and the Slurm fini() is called before the system's _fini().
    注:これらのinitおよびfini関数は、dlopen(3)システムライブラリで説明されているものと同じではありません。Cランタイムシステムは、これらのシンボルを独自の初期化用にco-optします。システムの_init()はSlurm init()の前に呼び出され、Slurm fini()はシステムの_fini()の前に呼び出されます。

    int setup_defaults(slurm_opt_t *options, bool early)

    Description:
    This function is called by the salloc, sbatch, or srun command line interface (CLI) programs shortly before processing any options from the environment, command line, or script (#SBATCH). The hook may be run multiple times per job-pack, once for an early pass (if implemented by the CLI), and again for the main pass. The options and early arguments are meant to be passed to slurm_option_set() which will set the option if it is in the appropriate pass. Failures to set an option may be a symptom of trying to set the option on the wrong pass. Given that you should not return SLURM_ERROR simply because of a failure to set an option.
    この関数は、環境、コマンドライン、またはスクリプト(#SBATCH)からのオプションを処理する直前に、salloc、sbatch、またはsrunコマンドラインインターフェイス(CLI)プログラムによって呼び出されます。フックは、ジョブパックごとに複数回、初期パス(CLIで実装されている場合)、およびメインパスで1回実行できます。オプションと初期引数は、適切なパスにある場合にオプションを設定するslurm_option_set()に渡されることを意図しています。オプションの設定に失敗すると、間違ったパスでオプションを設定しようとする症状になる場合があります。オプションの設定に失敗したからといって、単にSLURM_ERRORを返すべきではないことを考えると。

    Arguments:
    options (input) slurm option data structure; meant to be passed to the slurm_option_* API within src/common/slurm_opt.h.
    オプション(入力)slurmオプションデータ構造; src / common / slurm_opt.h内のslurm_option_ * APIに渡されることを意図しています。

    early (input) boolean indicating if this is the early pass or not; meant to be passed to the slurm_option_* API within src/common/slurm_opt.h.
    アーリー(入力)ブール値。これがアーリーパスかどうかを示します。src / common / slurm_opt.h内のslurm_option_ * APIに渡されることを意図しています。

    Returns:
    SLURM_SUCCESS on success, or
    成功した場合はSLURM_SUCCESS、または

    SLURM_ERROR on failure, will terminate execution of the CLI.
    失敗するとSLURM_ERROR。CLIの実行を終了します。

    int pre_submit(slurm_opt_t *options, int pack_offset)

    Description:
    This function is called by the CLI after option processing but before any communication with the slurmctld is made. This is after all setup_defaults() hooks are executed (for the current job-pack), environment variables processed, command line options and #SBATCH directives interpreted. pre_submit() is called before any parts of the data structure are rewritten, so it is safe to both read and write or unset any options from the plugin that you desire. Note that post_submit() cannot safely read (or write) the options, so you should save any state for logging in post_submit() during pre_submit(). This function is called once per job pack.
    この関数は、オプション処理の後、slurmctldとの通信が行われる前にCLIによって呼び出されます。これは、すべてのsetup_defaults()フックが実行され(現在のジョブパックに対して)、環境変数が処理され、コマンドラインオプションと#SBATCHディレクティブが解釈された後です。pre_submit()は、データ構造の一部が書き換えられる前に呼び出されるので、読み取りと書き込みの両方を行うか、必要なプラグインからオプションを設定解除しても安全です。post_submit()はオプションを安全に読み取る(または書き込む)ことができないので、pre_submit()中にpost_submit()にログインするための状態を保存する必要があることに注意してください。この関数は、ジョブパックごとに1回呼び出されます。

    Arguments:
    options (input/output) the job allocation request specifications.
    オプション(入力/出力)ジョブ割り当て要求の仕様。

    pack_offset (input) integer value for the current pack offset; should be used as a key when storing data for communication between pre_submit() and post_submit().
    pack_offset(入力)現在のパックオフセットの整数値。pre_submit()とpost_submit()の間の通信用データを格納するときにキーとして使用する必要があります。

    Returns:
    SLURM_SUCCESS on success, or
    成功した場合はSLURM_SUCCESS、または

    SLURM_ERROR on failure, will terminate execution of the CLI.
    失敗するとSLURM_ERROR。CLIの実行を終了します。

    void post_submit(int pack_offset, uint32_t jobid, uint32_t stepid)

    Description:
    This function is called by the CLI after a jobid (and, if srun, a stepid) has been assigned by the controller. It is no longer safe to read or write to the options data structure, so it has been removed from this function. You should save any state you need in pre_submit() using pack_offset as a key and access it here. This function is called once per job-pack.
    この関数は、コントローラーによってジョブID(およびsrunの場合はステップID)が割り当てられた後にCLIによって呼び出されます。オプションデータ構造の読み取りまたは書き込みは安全ではなくなったため、この関数から削除されました。pack_offsetをキーとして使用して、必要な状態をpre_submit()に保存し、ここにアクセスする必要があります。この関数は、ジョブパックごとに1回呼び出されます。

    Arguments:
    options pack_offset (input) integer value for the current pack offset; should be used as a key when storing data for communication between pre_submit() and post_submit().
    pack_offset(入力)現在のパックオフセットの整数値。pre_submit()とpost_submit()の間の通信用データを格納するときにキーとして使用する必要があります。

    jobid (input) job id of the job
    jobid(入力)ジョブのジョブID

    stepid (input) step id of the job if appropriate, NO_VAL otherwise
    stepid(入力)該当する場合はジョブのステップID、それ以外の場合はNO_VAL

    Last modified 29 April 2019