Skip to content

Commit

Permalink
remove namespace mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
kabicin committed Oct 30, 2024
1 parent 71d9131 commit 5ddb916
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
9 changes: 0 additions & 9 deletions internal/controller/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,7 @@ func (r *ReconcileOpenLiberty) reconcileBindings(instance *olv1.OpenLibertyAppli
func (r *ReconcileOpenLiberty) reconcilePasswordEncryptionKeyConcurrent(instance *olv1.OpenLibertyApplication, instanceMutex *sync.Mutex, passwordEncryptionMetadata *lutils.PasswordEncryptionMetadata, sharedResourceReconcileResultChan chan<- ReconcileResult, lastRotationChan chan<- string, encryptionSecretNameChan chan<- string) {
// Manage the shared password encryption key Secret if it exists
instanceMutex.Lock()
namespaceLocks, _ := namespaceLockMap.Load(instance.GetNamespace())
namespaceLocks.([]*sync.Mutex)[2].Lock()
message, encryptionSecretName, passwordEncryptionKeyLastRotation, err := r.reconcilePasswordEncryptionKey(instance, passwordEncryptionMetadata)
namespaceLocks.([]*sync.Mutex)[2].Unlock()
instanceMutex.Unlock()
lastRotationChan <- passwordEncryptionKeyLastRotation
encryptionSecretNameChan <- encryptionSecretName
Expand All @@ -439,10 +436,7 @@ func (r *ReconcileOpenLiberty) reconcilePasswordEncryptionKeyConcurrent(instance
func (r *ReconcileOpenLiberty) reconcileLTPAKeysConcurrent(instance *olv1.OpenLibertyApplication, instanceMutex *sync.Mutex, ltpaKeysMetadata *lutils.LTPAMetadata, ltpaConfigMetadata *lutils.LTPAMetadata, reconcileResultChan chan<- ReconcileResult, lastRotationChan chan<- string, ltpaSecretNameChan chan<- string, ltpaKeysLastRotationChan chan<- string) {
// Create and manage the shared LTPA keys Secret if the feature is enabled
instanceMutex.Lock()
namespaceLocks, _ := namespaceLockMap.Load(instance.GetNamespace())
namespaceLocks.([]*sync.Mutex)[0].Lock()
message, ltpaSecretName, ltpaKeysLastRotation, err := r.reconcileLTPAKeys(instance, ltpaKeysMetadata, ltpaConfigMetadata)
namespaceLocks.([]*sync.Mutex)[0].Unlock()
instanceMutex.Unlock()
ltpaSecretNameChan <- ltpaSecretName
lastRotationChan <- ltpaKeysLastRotation
Expand Down Expand Up @@ -483,10 +477,7 @@ func (r *ReconcileOpenLiberty) reconcileLTPAConfigConcurrent(instance *olv1.Open

// Using the LTPA keys and config metadata, create and manage the shared LTPA Liberty server XML if the feature is enabled
instanceMutex.Lock()
namespaceLocks, _ := namespaceLockMap.Load(instance.GetNamespace())
namespaceLocks.([]*sync.Mutex)[1].Lock()
message, ltpaXMLSecretName, err := r.reconcileLTPAConfig(instance, ltpaKeysMetadata, ltpaConfigMetadata, passwordEncryptionMetadata, ltpaKeysLastRotation, lastKeyRelatedRotation)
namespaceLocks.([]*sync.Mutex)[1].Unlock()
instanceMutex.Unlock()
ltpaXMLSecretNameChan <- ltpaXMLSecretName
if err != nil {
Expand Down
13 changes: 0 additions & 13 deletions internal/controller/openlibertyapplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"strings"
"sync"

networkingv1 "k8s.io/api/networking/v1"

Expand Down Expand Up @@ -52,12 +51,6 @@ type ReconcileOpenLiberty struct {
watchNamespaces []string
}

var namespaceLockMap *sync.Map

func init() {
namespaceLockMap = &sync.Map{}
}

const applicationFinalizer = "finalizer.openlibertyapplications.apps.openliberty.io"

// +kubebuilder:rbac:groups=security.openshift.io,resources=securitycontextconstraints,resourceNames=restricted,verbs=use,namespace=open-liberty-operator
Expand Down Expand Up @@ -205,12 +198,6 @@ func (r *ReconcileOpenLiberty) Reconcile(ctx context.Context, request ctrl.Reque

// From here, the Open Liberty Application instance is stored in shared memory and can begin concurrent actions.
if r.isConcurrencyEnabled(instance) {
ns := instance.GetNamespace()
// initialize a mutex for the namespace
if _, found := namespaceLockMap.Load(ns); !found {
namespaceLockMap.Store(ns, []*sync.Mutex{&sync.Mutex{}, &sync.Mutex{}, &sync.Mutex{}})
}

return r.concurrentReconcile(ba, instance, reqLogger, isKnativeSupported, ctx, request)
} else {
return r.sequentialReconcile(ba, instance, reqLogger, isKnativeSupported, ctx, request)
Expand Down

0 comments on commit 5ddb916

Please sign in to comment.