Cap installation-hierarchy retries by a max_wait deadline#42
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
De pairing-flow via
Connections::Zaptec#connect!in StekkerWeb roeptget_installation_hierarchyaan. Zaptec antwoordt bij een net-aangemaakte installatie soms met204 No Contenttotdat de provisioning klaar is. De client retryde nu 1× met 2 s pauze en gaf daarna op — voor sommige installaties te vroeg.Achtergrond
Sentry-issue https://sentry2.stekker.app/organizations/sentry/issues/2101/ ving één gebruiker die pairing niet kon afronden. Uit de outbound logs:
RequestFailednaar de userDe gebruiker klikte 4× de wizard opnieuw, gaf toen op, gooide het charge_point en de site weg en begon van nul. Na ~22 minuten was er een nieuwe site + nieuw charge_point met
connected_atgezet. Onnodige moeite die met een langere backoff niet nodig was geweest.Wat er verandert
get_installation_hierarchyaccepteert nu eenmax_wait:kwarg. Exponentiële backoff verdubbelt vanaf 2 s; zodra de cumulatieve wachttijdmax_waitzou overschrijden, wordt de laatste sleep zo gecapt dat de laatste poging op preciesmax_waitseconden gebeurt.Een
ActiveSupport::Duration(zoals30.seconds) of een integer aantal seconden zijn beide geldig.Default
DEFAULT_HIERARCHY_MAX_WAIT = 30.seconds— pogingen op cumulatief t=0, 2, 4, 8, 16, 30 (6 pogingen totaal). Dat vangt de meeste provisioning-vertragingen op zonder de user langer dan een halve minuut op een spinner te laten wachten.Consumenten die per aanroep willen tunen: batchjobs (bv.
refresh_grants_forin StekkerWeb) kunnenmax_wait: 0doorgeven zodat een enkele 204 gewoon wordt overgeslagen; user-facing pairing zou eventueel juistmax_wait: 60.secondskunnen zetten.Test-strategie
max_wait: 50all-204 loopt tot deadline (pogingen op t=0,2,4,8,16,32,50, dus sleeps 2,2,4,8,16,18, WebMock times(7)).max_wait: 5(pogingen op t=0,2,4,5, dus sleeps 2,2,1).ActiveSupport::Duration(5.seconds) werkt identiek aan integer 5.max_wait: 0doet één poging zondersleep.Version bump naar 1.4.0 (nieuwe kwarg, backwards-compatible via default).