Skip to content

Commit

Permalink
Create a GitHub client before mutex
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Hros <roman.hros@dnation.cloud>
  • Loading branch information
chess-knight committed Feb 16, 2024
1 parent abeed44 commit 162b12c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/controller/openstackclusterstackrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ func (r *OpenStackClusterStackReleaseReconciler) Reconcile(ctx context.Context,
if download {
conditions.MarkFalse(openstackclusterstackrelease, apiv1alpha1.ClusterStackReleaseAssetsReadyCondition, apiv1alpha1.ReleaseAssetsNotDownloadedYetReason, clusterv1beta1.ConditionSeverityInfo, "assets not downloaded yet")

// this is the point where we download the release from github
// acquire lock so that only one reconcile loop can download the release
r.openStackClusterStackRelDownloadDirectoryMutex.Lock()

defer r.openStackClusterStackRelDownloadDirectoryMutex.Unlock()

gc, err := r.GitHubClientFactory.NewClient(ctx)
if err != nil {
conditions.MarkFalse(openstackclusterstackrelease,
Expand All @@ -144,6 +138,12 @@ func (r *OpenStackClusterStackReleaseReconciler) Reconcile(ctx context.Context,

conditions.MarkTrue(openstackclusterstackrelease, apiv1alpha1.GitAPIAvailableCondition)

// this is the point where we download the release from github
// acquire lock so that only one reconcile loop can download the release
r.openStackClusterStackRelDownloadDirectoryMutex.Lock()

defer r.openStackClusterStackRelDownloadDirectoryMutex.Unlock()

if err := downloadReleaseAssets(ctx, releaseTag, releaseAssets.LocalDownloadPath, gc); err != nil {
logger.Error(err, "failed to download release assets")
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
Expand Down

0 comments on commit 162b12c

Please sign in to comment.