From 9651bc70281afc885a6ae11d1fb7bf668611181c Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Mon, 28 Oct 2019 11:54:11 +0000 Subject: [PATCH] Ensure that we reset rate limits after a successful target apply Change-type: patch Closes: #1117 Signed-off-by: Cameron Diver --- src/device-config.ts | 6 ++++++ src/device-state.coffee | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/device-config.ts b/src/device-config.ts index 9157a9c2..e15f6328 100644 --- a/src/device-config.ts +++ b/src/device-config.ts @@ -324,6 +324,12 @@ export class DeviceConfig { ); } + public resetRateLimits() { + _.each(this.rateLimits, action => { + action.lastAttempt = null; + }); + } + private bootConfigChangeRequired( configBackend: DeviceConfigBackend | null, current: Dictionary, diff --git a/src/device-state.coffee b/src/device-state.coffee index 88b4fd97..89ab51aa 100644 --- a/src/device-state.coffee +++ b/src/device-state.coffee @@ -146,6 +146,10 @@ module.exports = class DeviceState extends EventEmitter log.error('Device state apply error', err) else log.success('Device state apply success') + # We also let the device-config module know that we + # successfully reached the target state and that it + # should clear any rate limiting it's applied + @deviceConfig.resetRateLimits() @applications.on('change', @reportCurrentState) healthcheck: =>