maintenance_tasks 1.10.2 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8035a01cd9e715fec1b276b2f1c609266daeca88fa13d49ee1e2993370103f87
4
- data.tar.gz: b6ec7e053b256aa725cd3c23f932fe35b480b2398667cdc2ba9e72b3059ca614
3
+ metadata.gz: de43aad0e8d7479e1f7a88d8f664e20213d42455ca85ef22e074e2321b9a183b
4
+ data.tar.gz: 65bae8e5b9f793e5cd4dc08dfee03611378007d571d5fc027b349faa7c358b74
5
5
  SHA512:
6
- metadata.gz: 49aa01470360b4cde07fe1ce1d6a47158924fe0acca500ca21237374244c23a63560f4ea3fa03ec3f0dfae1ae8bb211817999b79c3057f1486f1c46ac75faab6
7
- data.tar.gz: 85ac09e52d9396e83254fd1f0451e6627542a7fed4238397960b14b4c14112f71dc7f51600a8f650331bc9f74192e98e962537bb472021903e5a7fd93dfcec02
6
+ metadata.gz: 5b088335a8ef4a0e1e92d376f4c5c2d2c05ca2dea2e07aa983f21783ce5a7bff53cf3b4f2a75607d67fea144119078f563882f6e67c6fd09adc3d20ebac285a1
7
+ data.tar.gz: '0128f6891b9b0328b7ba80490b4843a70eb014ddb82295d50f7d22218164ac3e9ef1e7c08bb80e8aab0a4501e932a1d374e755e7f21bd709c996f33b3344575f'
@@ -29,6 +29,7 @@ module MaintenanceTasks
29
29
  STOPPING_STATUSES = [
30
30
  :pausing,
31
31
  :cancelling,
32
+ :cancelled,
32
33
  ]
33
34
  COMPLETED_STATUSES = [:succeeded, :errored, :cancelled]
34
35
  COMPLETED_RUNS_LIMIT = 10
@@ -137,7 +138,7 @@ module MaintenanceTasks
137
138
  backtrace: MaintenanceTasks.backtrace_cleaner.clean(error.backtrace),
138
139
  ended_at: Time.now,
139
140
  )
140
- run_task_callbacks(:error)
141
+ run_error_callback
141
142
  rescue ActiveRecord::StaleObjectError
142
143
  reload_status
143
144
  retry
@@ -168,8 +169,10 @@ module MaintenanceTasks
168
169
  self
169
170
  end
170
171
 
171
- # Returns whether the Run is stopping, which is defined as
172
- # having a status of pausing or cancelled.
172
+ # Returns whether the Run is stopping, which is defined as having a status
173
+ # of pausing or cancelling. The status of cancelled is also considered
174
+ # stopping since a Run can be cancelled while its job still exists in the
175
+ # queue, and we want to handle it the same way as a cancelling run.
173
176
  #
174
177
  # @return [Boolean] whether the Run is stopping.
175
178
  def stopping?
@@ -259,7 +262,7 @@ module MaintenanceTasks
259
262
  # specified by the Task.
260
263
  def start(count)
261
264
  update!(started_at: Time.now, tick_total: count)
262
- run_task_callbacks(:start)
265
+ task.run_callbacks(:start)
263
266
  rescue ActiveRecord::StaleObjectError
264
267
  reload_status
265
268
  retry
@@ -272,6 +275,7 @@ module MaintenanceTasks
272
275
  self.ended_at = Time.now
273
276
  elsif pausing?
274
277
  self.status = :paused
278
+ elsif cancelled?
275
279
  else
276
280
  self.status = :interrupted
277
281
  end
@@ -412,6 +416,12 @@ module MaintenanceTasks
412
416
 
413
417
  def run_task_callbacks(callback)
414
418
  task.run_callbacks(callback)
419
+ rescue Task::NotFoundError
420
+ nil
421
+ end
422
+
423
+ def run_error_callback
424
+ task.run_callbacks(:error)
415
425
  rescue
416
426
  nil
417
427
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maintenance_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -152,7 +152,7 @@ homepage: https://github.com/Shopify/maintenance_tasks
152
152
  licenses:
153
153
  - MIT
154
154
  metadata:
155
- source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.10.2
155
+ source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.10.3
156
156
  allowed_push_host: https://rubygems.org
157
157
  post_install_message:
158
158
  rdoc_options: []