From bc8e3958ee2ea10a347dd5c80cbaa7f4acdd25a2 Mon Sep 17 00:00:00 2001 From: Markus Maga Date: Tue, 23 Jul 2019 19:29:10 +0200 Subject: [PATCH] fix: add error logg and all in destructuring --- lib/poller.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/poller.js b/lib/poller.js index 2f22f638..465d41f3 100644 --- a/lib/poller.js +++ b/lib/poller.js @@ -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) } } }