Skip to content

Commit ef49da9

Browse files
author
kranurag7
committed
defer unlocking of mutex
defer works even when there's a panic so we are always unlocking the mutex. Signed-off-by: kranurag7 <[email protected]>
1 parent c7b714d commit ef49da9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/controller/clusterstackrelease_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ func (r *ClusterStackReleaseReconciler) Reconcile(ctx context.Context, req recon
113113
// acquire lock so that only one reconcile loop can download the release
114114
r.clusterStackRelDownloadDirectoryMutex.Lock()
115115

116+
defer r.clusterStackRelDownloadDirectoryMutex.Unlock()
117+
116118
gc, err := r.GitHubClientFactory.NewClient(ctx)
117119
if err != nil {
118120
conditions.MarkFalse(clusterStackRelease,
@@ -131,8 +133,6 @@ func (r *ClusterStackReleaseReconciler) Reconcile(ctx context.Context, req recon
131133
return reconcile.Result{}, fmt.Errorf("failed to download release assets: %w", err)
132134
}
133135

134-
r.clusterStackRelDownloadDirectoryMutex.Unlock()
135-
136136
// requeue to make sure release assets can be accessed
137137
return reconcile.Result{Requeue: true}, nil
138138
}

0 commit comments

Comments
 (0)