Skip to content

Commit

Permalink
Fix trust bundle propagation already exists error (#7906)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
  • Loading branch information
pierDipi committed May 8, 2024
1 parent e9b3af6 commit 1ce7074
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/eventingtls/trust_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,32 @@ func PropagateTrustBundles(ctx context.Context, k8s kubernetes.Interface, trustB
if p.userCm == nil {
// Update owner references
expected.OwnerReferences = withOwnerReferences(obj, gvk, []metav1.OwnerReference{})

if err := createConfigMap(ctx, k8s, expected); err != nil {
err := createConfigMap(ctx, k8s, expected)
if err != nil && !apierrors.IsAlreadyExists(err) {
return err
}
if apierrors.IsAlreadyExists(err) {
// Update existing ConfigMap
cm, getErr := k8s.CoreV1().
ConfigMaps(obj.GetNamespace()).
Get(ctx, userCMName(p.sysCM.Name), metav1.GetOptions{})
if getErr != nil {
return err // return original error
}

cm.ObjectMeta.DeepCopyInto(&expected.ObjectMeta)
expected.OwnerReferences = withOwnerReferences(obj, gvk, cm.OwnerReferences)

if !equality.Semantic.DeepDerivative(expected, cm) {
if err := updateConfigMap(ctx, k8s, expected); err != nil {
return err
}
}
}
continue
}

p.userCm.ObjectMeta.DeepCopyInto(&expected.ObjectMeta)
// Update owner references
expected.OwnerReferences = withOwnerReferences(obj, gvk, p.userCm.OwnerReferences)

Expand Down

0 comments on commit 1ce7074

Please sign in to comment.