UnifiedStorage: Default to running unified-grpc in integration tests (#93492)

This commit is contained in:
Ryan McKinley
2024-10-31 16:29:32 +03:00
committed by GitHub
parent a93de5f0d8
commit 4e1f0dadbd
9 changed files with 56 additions and 40 deletions
+4 -2
View File
@@ -80,16 +80,18 @@ func (s *Storage) prepareObjectForUpdate(ctx context.Context, updateObject runti
if previous.GetUID() == "" {
klog.Errorf("object is missing UID: %s, %s", obj.GetGroupVersionKind().String(), obj.GetName())
} else if obj.GetUID() != previous.GetUID() {
klog.Errorf("object UID mismatch: %s, was:%s, now: %s", obj.GetGroupVersionKind().String(), previous.GetName(), obj.GetUID())
obj.SetUID(previous.GetUID())
}
if obj.GetName() != previous.GetName() {
return nil, fmt.Errorf("name mismatch between existing and updated object")
}
obj.SetUID(previous.GetUID())
obj.SetCreatedBy(previous.GetCreatedBy())
obj.SetCreationTimestamp(previous.GetCreationTimestamp())
obj.SetResourceVersion("")
obj.SetResourceVersion("") // removed from saved JSON because the RV is not yet calculated
// Read+write will verify that origin format is accurate
origin, err := obj.GetOriginInfo()
+10 -4
View File
@@ -29,6 +29,7 @@ import (
"github.com/grafana/grafana/pkg/apimachinery/utils"
grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic"
"github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/storage/unified/resource"
)
@@ -468,11 +469,16 @@ func (s *Storage) GuaranteedUpdate(
mmm.SetResourceVersionInt64(rsp.ResourceVersion)
res.ResourceVersion = uint64(rsp.ResourceVersion)
if err := preconditions.Check(key, existingObj); err != nil {
if attempt >= MaxUpdateAttempts {
return fmt.Errorf("precondition failed: %w", err)
if rest.IsDualWriteUpdate(ctx) {
// Ignore the RV when updating legacy values
mmm.SetResourceVersion("")
} else {
if err := preconditions.Check(key, existingObj); err != nil {
if attempt >= MaxUpdateAttempts {
return fmt.Errorf("precondition failed: %w", err)
}
continue
}
continue
}
} else if !ignoreNotFound {
return apierrors.NewNotFound(s.gr, req.Key.Name)