Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency safe client factory #4950

Merged
merged 6 commits into from
Oct 1, 2024

Commits on Sep 21, 2024

  1. Remove ClientFactoryInterface.GetRESTClient

    This was accessing the client field without locking the mutex and
    was potentially missing intialization. The dynamic client is actually
    exposing its REST client, so that can be used instead.
    
    Signed-off-by: Tom Wieczorek <[email protected]>
    twz123 committed Sep 21, 2024
    Configuration menu
    Copy the full SHA
    3c8c2ad View commit details
    Browse the repository at this point in the history
  2. Use k0s's clientset in the k0s client factory

    Keep the old CRD specific versions for backwards compatibility.
    
    Signed-off-by: Tom Wieczorek <[email protected]>
    twz123 committed Sep 21, 2024
    Configuration menu
    Copy the full SHA
    3902101 View commit details
    Browse the repository at this point in the history
  3. Lazy initialization for metadata client in AP update checks

    This allows the FakeClientFactory's GetRESTConfig method to panic
    without breaking tests. Code constructed with an empty rest.Config is
    not backed by a fake client at all, so it's better to have tests fail
    up front than to have strange errors when such constructed clients are
    actually used.
    
    Signed-off-by: Tom Wieczorek <[email protected]>
    twz123 committed Sep 21, 2024
    Configuration menu
    Copy the full SHA
    0162090 View commit details
    Browse the repository at this point in the history
  4. Make the client factory's GetRESTConfig fallible

    There's the possiblity that the REST config is not yet loaded when
    GetRESTConfig gets called. Returning a nil pointer along with a nil
    error is a problem.
    
    Signed-off-by: Tom Wieczorek <[email protected]>
    twz123 committed Sep 21, 2024
    Configuration menu
    Copy the full SHA
    e647b38 View commit details
    Browse the repository at this point in the history
  5. Lazy initialization in client factory's GetRESTClient

    Previously, the GetRESTClient method was not synchronized and not
    concurrency safe. Change this by adding mutexes and making it use lazy
    initialization like all other getters.
    
    Signed-off-by: Tom Wieczorek <[email protected]>
    twz123 committed Sep 21, 2024
    Configuration menu
    Copy the full SHA
    e03c794 View commit details
    Browse the repository at this point in the history
  6. Introduce LoadRESTConfig function pointer

    This way, the way the REST config is loaded is up to the client factory
    users. The special "admin" settings are now part of the controller
    command, freeing the client factory from any particular way of loading
    and setting up the config.
    
    Signed-off-by: Tom Wieczorek <[email protected]>
    twz123 committed Sep 21, 2024
    Configuration menu
    Copy the full SHA
    ed0bc7b View commit details
    Browse the repository at this point in the history