[MM-54232] Implement automatic client registration #38
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.
Summary
To make the service play nicely with K8S (or with any other form of load balancing of multiple instances) we added some very hacky logic in mattermost/mattermost-plugin-calls#479 to essentially re-attempt actions due to failed authentication. Not only was this pretty horrible code to implement but also it didn't work particularly well with round-robin load balancers which would distribute each request to a different backend, causing the client to just give up after reaching the maximum failed attempts.
To alleviate these issues and simplify the flow we are adding some functionality to automatically register a client (if missing) upon authentication attempt. This has the huge benefit of removing the need to make separate HTTP requests which could all hit different endpoints. Instead, both registration and authentication are now coupled with whatever action the client is making (e.g. starting a job). This means that a call with valid credentials is guaranteed to succeed, no matter which endpoint it hits.
Related PR
mattermost/mattermost-plugin-calls#501
Ticket Link
https://mattermost.atlassian.net/browse/MM-54232