Skip to content

Commit

Permalink
bug: avoid conflicts on start
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Oct 25, 2024
1 parent 2eaca44 commit 6de1815
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/controller/handlers/reference/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package reference

import (
"github.com/acorn-io/baaah/pkg/router"
"github.com/acorn-io/baaah/pkg/uncached"
v1 "github.com/otto8-ai/otto8/pkg/storage/apis/otto.gptscript.ai/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -36,8 +37,12 @@ func AssociateWithReference(req router.Request, _ router.Response) error {

var existingRef v1.Reference
if err := req.Get(&existingRef, ref.Namespace, ref.Name); apierrors.IsNotFound(err) {
if err := req.Client.Create(req.Ctx, &ref); err != nil {
return err
if err := req.Client.Create(req.Ctx, &ref); apierrors.IsAlreadyExists(err) {
if err := req.Get(uncached.Get(&existingRef), ref.Namespace, ref.Name); err != nil {
return err
}
} else if err != nil {
return nil
}
} else if err != nil {
return nil
Expand Down

0 comments on commit 6de1815

Please sign in to comment.