github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/reschedule.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: reschedule Stanza - Job Specification
     4  sidebar_title: reschedule
     5  description: >-
     6    The "reschedule" stanza specifies the group's rescheduling strategy upon
     7  
     8    allocation failures. Nomad will only attempt to reschedule failed allocations
     9    on
    10  
    11    to another node only after any local
    12    [restarts](docs/job-specification/restart)
    13  
    14    have been exceeded.
    15  ---
    16  
    17  # `reschedule` Stanza
    18  
    19  <Placement
    20    groups={[
    21      ['job', 'reschedule'],
    22      ['job', 'group', 'reschedule'],
    23    ]}
    24  />
    25  
    26  The `reschedule` stanza specifies the group's rescheduling strategy. If specified at the job
    27  level, the configuration will apply to all groups within the job. If the
    28  reschedule stanza is present on both the job and the group, they are merged with
    29  the group stanza taking the highest precedence and then the job.
    30  
    31  Nomad will attempt to schedule the task on another node if any of its allocation
    32  statuses become "failed". It prefers to create a replacement allocation on a node
    33  that hasn't previously been used.
    34  
    35  ```hcl
    36  job "docs" {
    37    group "example" {
    38      reschedule {
    39        attempts       = 15
    40        interval       = "1h"
    41        delay          = "30s"
    42        delay_function = "exponential"
    43        max_delay      = "120s"
    44        unlimited      = false
    45      }
    46    }
    47  }
    48  ```
    49  
    50  ~> The reschedule stanza does not apply to `system` jobs because they run on
    51  every node.
    52  
    53  ## `reschedule` Parameters
    54  
    55  - `attempts` `(int: <varies>)` - Specifies the number of reschedule attempts
    56    allowed in the configured interval. Defaults vary by job type, see below
    57    for more information.
    58  
    59  - `interval` `(string: <varies>)` - Specifies the sliding window which begins
    60    when the first reschedule attempt starts and ensures that only `attempts`
    61    number of reschedule happen within it. If more than `attempts` number of
    62    failures happen with this interval, Nomad will not reschedule any more.
    63  
    64  - `delay` `(string: <varies>)` - Specifies the duration to wait before attempting
    65    to reschedule a failed task. This is specified using a label suffix like "30s" or "1h".
    66    Delay cannot be less than 5 seconds.
    67  
    68  - `delay_function` `(string: <varies>)` - Specifies the function that is used to
    69    calculate subsequent reschedule delays. The initial delay is specified by the delay parameter.
    70    `delay_function` has three possible values which are described below.
    71  
    72    - `constant` - The delay between reschedule attempts stays constant at the `delay` value.
    73    - `exponential` - The delay between reschedule attempts doubles.
    74    - `fibonacci` - The delay between reschedule attempts is calculated by adding the two most recent
    75      delays applied. For example if `delay` is set to 5 seconds, the next five reschedule attempts will be
    76      delayed by 5 seconds, 5 seconds, 10 seconds, 15 seconds, and 25 seconds respectively.
    77  
    78  - `max_delay` `(string: <varies>)` - is an upper bound on the delay beyond which it will not increase. This parameter
    79    is used when `delay_function` is `exponential` or `fibonacci`, and is ignored when `constant` delay is used.
    80  
    81  - `unlimited` `(boolean:<varies>)` - `unlimited` enables unlimited reschedule attempts. If this is set to true
    82    the `attempts` and `interval` fields are not used.
    83  
    84  Information about reschedule attempts are displayed in the CLI and API for
    85  allocations. Rescheduling is enabled by default for service and batch jobs
    86  with the options shown below.
    87  
    88  ### `reschedule` Parameter Defaults
    89  
    90  The values for the `reschedule` parameters vary by job type. Below are the
    91  defaults by job type:
    92  
    93  - The default batch reschedule policy is:
    94  
    95    ```hcl
    96    reschedule {
    97      attempts       = 1
    98      interval       = "24h"
    99      unlimited      = false
   100      delay          = "5s"
   101      delay_function = "constant"
   102    }
   103    ```
   104  
   105  - The default service reschedule policy is:
   106  
   107    ```hcl
   108    reschedule {
   109     delay          = "30s"
   110     delay_function = "exponential"
   111     max_delay      = "1h"
   112     unlimited      = true
   113    }
   114    ```
   115  
   116  ### Disabling rescheduling
   117  
   118  To disable rescheduling, set the `attempts` parameter to zero and `unlimited` to false.
   119  
   120  ```hcl
   121  job "docs" {
   122    group "example" {
   123      reschedule {
   124        attempts  = 0
   125        unlimited = false
   126      }
   127    }
   128  }
   129  ```