Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Move synchronization to after read to reduce contention.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-barry committed Dec 5, 2023
1 parent 7833346 commit 6ffb68d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions api/v1/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,6 @@ func MutateCaInjection(pod *corev1.Pod, config *Config) error {
}

func EnsureAssetsInNamespace(config *Config) error {
// it is possible that many mutations are requested in succession and this can lead to an "already exists"
// for the create operation. Thus, synchronize around the possible creation by only allowing one of this function
// to execute at any given time
mu := sync.Mutex{}
mu.Lock()
defer mu.Unlock()

// the goal is to ensure this exists already or we'll create it
qtapCaBundleExists := false

Expand All @@ -166,6 +159,13 @@ func EnsureAssetsInNamespace(config *Config) error {
return nil
}

// it is possible that many mutations are requested in succession and this can lead to an "already exists"
// for the create operation. Thus, synchronize around the possible creation by only allowing one of this function
// to execute at any given time
mu := sync.Mutex{}
mu.Lock()
defer mu.Unlock()

// we need to see if we have the qtap ca in the operator namespace
qpointRootCaConfigMap := &corev1.ConfigMap{}
if err := config.Client.Get(config.Ctx, client.ObjectKey{Namespace: config.OperatorNamespace, Name: QPOINT_ROOT_CA}, qpointRootCaConfigMap); err != nil {
Expand Down

0 comments on commit 6ffb68d

Please sign in to comment.