Skip to content

Commit

Permalink
fix: forward context in pkg/cluster (#921)
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Ilario <filario@redhat.com>
Co-authored-by: Alexey Kazakov <alkazako@redhat.com>
Co-authored-by: Matous Jobanek <mjobanek@redhat.com>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent 567e867 commit 18d6497
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (r *Reconciler) deleteSpaceBindingRequest(ctx context.Context, sbrAssociate
logger := log.FromContext(ctx)

spaceBindingRequest := &toolchainv1alpha1.SpaceBindingRequest{}
memberClusterWithSpaceBindingRequest, found, err := cluster.LookupMember(r.MemberClusters, types.NamespacedName{
memberClusterWithSpaceBindingRequest, found, err := cluster.LookupMember(ctx, r.MemberClusters, types.NamespacedName{
Namespace: sbrAssociated.namespace,
Name: sbrAssociated.name,
}, spaceBindingRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
// Fetch the SpaceBindingRequest
// search on all member clusters
spaceBindingRequest := &toolchainv1alpha1.SpaceBindingRequest{}
memberClusterWithSpaceBindingRequest, found, err := cluster.LookupMember(r.MemberClusters, types.NamespacedName{
memberClusterWithSpaceBindingRequest, found, err := cluster.LookupMember(ctx, r.MemberClusters, types.NamespacedName{
Namespace: request.Namespace,
Name: request.Name,
}, spaceBindingRequest)
Expand Down
2 changes: 1 addition & 1 deletion controllers/spacerequest/spacerequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
// Fetch the SpaceRequest
// search on all member clusters
spaceRequest := &toolchainv1alpha1.SpaceRequest{}
memberClusterWithSpaceRequest, found, err := cluster.LookupMember(r.MemberClusters, types.NamespacedName{
memberClusterWithSpaceRequest, found, err := cluster.LookupMember(ctx, r.MemberClusters, types.NamespacedName{
Namespace: request.Namespace,
Name: request.Name,
}, spaceRequest)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ type Cluster struct {
// returns memberCluster/false/error in case the Object was NOT found on any of the given member clusters and there was an error while trying to read one or more of the memberclusters
//
// CAVEAT: if the object was not found and there is an error reading from more than one member cluster, only the last read error will be returned.
func LookupMember(memberClusters map[string]Cluster, namespacedName types.NamespacedName, object runtimeclient.Object) (Cluster, bool, error) {
func LookupMember(ctx context.Context, memberClusters map[string]Cluster, namespacedName types.NamespacedName, object runtimeclient.Object) (Cluster, bool, error) {
var memberClusterWithObject Cluster
var getError error
var found bool
for _, memberCluster := range memberClusters {
err := memberCluster.Client.Get(context.TODO(), namespacedName, object)
err := memberCluster.Client.Get(ctx, namespacedName, object)
if err != nil {
if !errors.IsNotFound(err) {
// Error reading the object
Expand Down

0 comments on commit 18d6497

Please sign in to comment.