[unifi] Fix online/blocked channels after client is disconnected #11451
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.
Fixes #7001
Signed-off-by: Jacob Laursen [email protected]
Fixes a problem with the online channel never being updated to OFF after client disconnects. This was most likely introduced by Uni-Fi Controller 5.12.35. The same problem impacted the blocked channel also in the way that unblocking was not possible.
This pull request replaces #11410 with a better approach. Previous PR would keep clients in the cache after they are no longer connected to the access point. This worked for the online channel, but broke the blocked channel as a blocked client would immediately be disconnected from AP, but kept in client cache. This resulted in blocked status going back to unblocked since this was last known status.
New approach chosen is to keep a map of cid (configured key) -> _id values. When _id is returned by controller for the first time, it's kept in this cache and preferred for subsequent lookups. When client disconnects, it can no longer be found in client cache by either _id nor cid. It can however still be found in insights cache by _id. This fixes the problem as the insights cache doesn't contain IP address since controller version 5.12.35 release in beginning of 2020.
Example
When online (other clients/insights removed):
After going offline: