Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
fix: add error logg and all in destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
Flydiverny committed Jul 23, 2019
1 parent f6399c5 commit bc8e395
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,23 @@ class Poller {

try {
const {
body: { metadata: { annotations = {} } = {} } = {}
body: {
metadata: {
annotations: { [LAST_POLL]: lastPoll = '0' } = {}
} = {}
} = {}
} = await kubeNamespace.secrets(secretName).get()

const lastPoll = parseInt(annotations[LAST_POLL] || '0', 10)
const nextPollIn = Math.max(lastPoll - (Date.now() - this._intervalMilliseconds), 0)
const lastPollNbr = parseInt(lastPoll, 10)
const nextPollIn = Math.max(lastPollNbr - (Date.now() - this._intervalMilliseconds), 0)

this._setNextPoll(nextPollIn)
} catch (err) {
if (err.statusCode === 404) {
this._logger.info('Secret does not exist, polling right away')
this._poll()
} else {
this._logger.error(err, 'Secret check went boom for %s in %s', secretName, this._namespace)
}
}
}
Expand Down

0 comments on commit bc8e395

Please sign in to comment.