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

Address CA config map creation race condition #19

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/v1/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"sync"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -158,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