Extract controller-runtime's manager.GetClient() for other methods in CNS to use #4036
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.
Basically, CNS will need to be able to create the MTPNC on the apiserver with a new feature coming up in #4002
In preparation for that, I'm extracting out the controller-runtime manager's kubernetes client, from
InitializeCRDState()
, for it to be used later on in CNSOther consideration taken and why I did not go with it:
One other way I could think of doing this was to have a separate function
makeManager()
called beforeInitializeCRDState()
, that would do this:So then, we'd give that manager, into
InitializeCRDState()
as a param, and pass it around too to other methods:Thing about this though, is it's dangerous! 😱
Because, the manager client, is not ready to use until
InitializeCRDState()
finishes:So I don't want people to call
makeManger()
, thinking "Oh this client is ready to go", when in reality, bothcnsConfig.ChannelMode
needs to beCRD
, which in turns runsInitializeCRDState()
, and then it's finally readySo I think it makes more sense to just pass it out of
InitializeCRDState()
(already initialized, ready to be used), and move the http service logic after thatThoughts?