Skip to content

Commit ff134fd

Browse files
committed
make batchupdate idempotent
1 parent 2f1ff34 commit ff134fd

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

store/etcdv3/meta/etcd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (e *ETCD) Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantRespon
308308
func (e *ETCD) batchUpdate(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) {
309309
limit := map[string]map[string]string{}
310310
for key := range data {
311-
limit[key] = map[string]string{cmpVersion: "!=", cmpValue: "!="} // ignore same data
311+
limit[key] = map[string]string{cmpVersion: "!="}
312312
}
313313
resp, err := e.batchPut(ctx, data, limit, opts...)
314314
if err != nil {

store/etcdv3/node_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func TestUpdateNode(t *testing.T) {
205205
},
206206
}
207207
assert.Error(t, m.UpdateNodes(ctx, fakeNode))
208-
assert.Error(t, m.UpdateNodes(ctx, node), "ETCD Txn condition failed")
208+
assert.NoError(t, m.UpdateNodes(ctx, node))
209209
node.Available = false
210210
assert.NoError(t, m.UpdateNodes(ctx, node))
211211
}

store/etcdv3/workload_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestAddORUpdateWorkload(t *testing.T) {
3636
assert.NoError(t, err)
3737
// success updat
3838
err = m.UpdateWorkload(ctx, workload)
39-
assert.Error(t, err, "ETCD Txn condition failed")
39+
assert.NoError(t, err)
4040
// success updat
4141
workload.Name = "test_app_2"
4242
err = m.UpdateWorkload(ctx, workload)

0 commit comments

Comments
 (0)