Skip to content

Add logic for error handling #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/shiva/errors/dock-not-detached-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'
const BaseError = require('error-cat/errors/base-error')

module.exports = class DockNotDetachedError extends BaseError {
constructor (errMessage, originalError, reporting) {
super(errMessage, originalError, reporting)
}
}
7 changes: 5 additions & 2 deletions lib/shiva/tasks/dock.attach.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'
const Promise = require('bluebird')
const WorkerStopError = require('error-cat/errors/worker-stop-error')
const DockNotDetachedError = require('../errors/dock-not-detached-error')
require('loadenv')({ project: 'shiva', debugName: 'astral:shiva:env' })

const AutoScalingGroup = require('../models/auto-scaling-group')
Expand Down Expand Up @@ -35,8 +36,10 @@ DockAttach.task = (job) => {
if (err.getCurrentASG() === targetASGName) {
throw new WorkerStopError('instance already attached to asg', { err, targetASGName })
}

throw err
if (!(new RegExp('is already part of AutoScalingGroup:' + process.env.DOCK_POOL_ASG_NAME).test(err.data.originalError.message))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we still need this worker to retry. if you do this then the worker will stop and not retry. Was you want to happen here is set err.level = debug
OR make a new error class called ignoreable or something and inherit form baseError

new BaseError('message', {}, {
  level: 'critical',      // the reporting level 
  fingerprint: 'mygroup'  // a grouping fingerprint 
})

https://www.npmjs.com/package/error-cat

throw new DockNotDetachedError('Instance still not detached from pool', err, { level: 'info' })
}
throw err;
})
.then(() => {
return publisher.publishTask('dock.initialize', {
Expand Down