github.com/smintz/nomad@v0.8.3/website/source/docs/job-specification/reschedule.html.md (about)

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