[SURE-9419] Move agent registration into controller container #3416
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.
Since we have changed the agent from using a StatefulSet to a Deployment, we also needed and have implemented leader election for every container of the agent pod. This ensures that
even if the replicas are temporarily (as in a rollout) or permanently (as in replica size) above one.
Now, if replicas are to be set to anything above one, this will currently lead to the agent of the second pod to perform the cluster registration, even though the agent cannot run after it completed the registration. The cluster registration will complete, but the controller will wait for the lease. This state potentially leads to confusion, as there are cluster registrations in the upstream cluster that have never and may never be used. Apparently this state is also considered inconsistent with the UI. Lastly, we use more leases than necessary.
While theoretically possible that the name for the lease is the same for the cluster registration container as well as for the agent controller, this may lead to extended waiting times, as the leases need to be acquired. Also, it is not guaranteed that the agent controller of the same pod will get the lease after the cluster registration container has let go of the lease , potentially leading to the same problem with unused cluster registrations (imagine replica size 3 from 1).
For those reasons the agent registration is to be moved into the controller container.
Part of #3377