Fix bug with enterpriseURL for multi-tenancy #1781
Merged
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.
Addresses and fixes #1764.
Changes:
IsEnterprise
bool to the GitHub client struct. It is set when the client is an enterprise client.conf.EnterpriseURL
for clients created usinggithubAPICredentialsFrom
.EnterpriseURL
in GitHub config.Reasoning
Currently, ARC creates a GitHub client (let's call it client A) when the controller is created - this client is passed to the
RunnerReconciler
. As part of the multi-tenancy feature, a new client (let's call it client B) is created when aRunnerDeployment
is added with the fieldgithubAPICredentialsFrom
.The GitHub wrapper creates a client from a
config
struct. When creating client B, it sets theenterpriseURL
in its config to theGithubBaseURL
of client A1. This causes issues when client A is not an enterprise client, as client B now has itsenterpriseURL
defined. The GitHub wrapper behaves differently when anenterpriseURL
defined in theconfig
struct, leading to the newly created client B calling the wrong API endpoint for tasks such as runner registration.To fix this, client A needs a basic idea of whether it is using an
enterpriseURL
. We have decided to use a bool (as opposed to doing checks on the baseURL) as it's just cleaner and less likely to go wrong.Also, added command line support for
enterpriseURL
as it was the only thing that was missing.1 This was introduced as part of #1725 and issue #1714. The concern was valid because if the config for client B has no
enterpriseURL
defined it should be using the enterpriseURL of the original client (A). Nevertheless, the above bug was introduced.