Skip to content

Commit 9ffbc37

Browse files
authored
MGMT-18689: Add schemes when remote client is created (#149)
Currently we add schemes to the remote client with every call to the `GetRemoteClient` method. But this is called during reconciliation, when there may be other things trying to read those schemes. That can potentially cause a concurrent map read and map write. To reduce the chances of that happening this patch changes the code so that the schemes will be added only when the remote client is created, which happens only once. Related: https://issues.redhat.com/browse/MGMT-18689 Signed-off-by: Juan Hernandez <[email protected]>
1 parent fd64db4 commit 9ffbc37

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

controllers/remote_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type remoteClient struct {
3737
}
3838

3939
func NewRemoteClient(localClient client.Client, scheme *runtime.Scheme) RemoteClientHandler {
40+
scheme = GetKubeClientSchemes(scheme)
4041
return &remoteClient{localClient: localClient, scheme: scheme}
4142
}
4243

@@ -69,8 +70,7 @@ func (r *remoteClient) GetRemoteClient(ctx context.Context, secretNamespace stri
6970
return nil, errors.Wrapf(err, "failed to get restconfig for remote kube client")
7071
}
7172

72-
schemes := GetKubeClientSchemes(r.scheme)
73-
targetClient, err := client.New(restConfig, client.Options{Scheme: schemes})
73+
targetClient, err := client.New(restConfig, client.Options{Scheme: r.scheme})
7474
if err != nil {
7575
return nil, errors.Wrapf(err, "failed to get remote kube client")
7676
}

0 commit comments

Comments
 (0)