mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
[unified-storage/apistore] Fix GuranteedUpdate skipping updates when tryUpdate
is passed (#94557)
`GuranteedUpdate` method of `apistore.Storage` had a bug, where it would errorneously conclude that the object is unchanged, in case a `tryUpdate` function is passed that modifies the existing object itself (as it is the case in many core types in K8s upstream). The modified `existingObj` was compared with `updatedObj`, which would essentially be same and this lead to the update being skipped. This patch fixes this by always passing a copy of the `existingObj`. Signed-off-by: Prem Kumar <prem.saraswat@grafana.com>
This commit is contained in:
parent
95afb3a112
commit
e2672021bc
@ -465,7 +465,7 @@ func (s *Storage) GuaranteedUpdate(
|
||||
return apierrors.NewNotFound(s.gr, req.Key.Name)
|
||||
}
|
||||
|
||||
updatedObj, _, err = tryUpdate(existingObj, res)
|
||||
updatedObj, _, err = tryUpdate(existingObj.DeepCopyObject(), res)
|
||||
if err != nil {
|
||||
if attempt >= MaxUpdateAttempts {
|
||||
return err
|
||||
|
@ -135,12 +135,12 @@ func TestDeleteWithSuggestion(t *testing.T) {
|
||||
storagetesting.RunTestDeleteWithSuggestion(ctx, t, store)
|
||||
}
|
||||
|
||||
//func TestDeleteWithSuggestionAndConflict(t *testing.T) {
|
||||
// ctx, store, destroyFunc, err := testSetup(t)
|
||||
// defer destroyFunc()
|
||||
// assert.NoError(t, err)
|
||||
// storagetesting.RunTestDeleteWithSuggestionAndConflict(ctx, t, store)
|
||||
//}
|
||||
func TestDeleteWithSuggestionAndConflict(t *testing.T) {
|
||||
ctx, store, destroyFunc, err := testSetup(t)
|
||||
defer destroyFunc()
|
||||
assert.NoError(t, err)
|
||||
storagetesting.RunTestDeleteWithSuggestionAndConflict(ctx, t, store)
|
||||
}
|
||||
|
||||
// TODO: this test relies on update
|
||||
//func TestDeleteWithSuggestionOfDeletedObject(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user