Yet another Cosmos DB auth fix
This is fixed by upgrading the upstream SDK Also added a missing handling of throttling in the Delete method Signed-off-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
parent
ffc67d3550
commit
407936745e
2
go.mod
2
go.mod
|
@ -23,7 +23,7 @@ require (
|
|||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
github.com/Shopify/sarama v1.23.1
|
||||
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
|
||||
github.com/a8m/documentdb v1.3.1-0.20220331220217-1e66c639b09a
|
||||
github.com/a8m/documentdb v1.3.1-0.20220405205223-5b41ba0aaeb1
|
||||
github.com/aerospike/aerospike-client-go v4.5.0+incompatible
|
||||
github.com/agrea/ptr v0.0.0-20180711073057-77a518d99b7b
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -170,8 +170,8 @@ github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrU
|
|||
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY=
|
||||
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220331220217-1e66c639b09a h1:R6ZVJrvLESkVdoKt5B5ayx8DgS3n7X0dpTHYTs2sahU=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220331220217-1e66c639b09a/go.mod h1:4Z0mpi7fkyqjxUdGiNMO3vagyiUoiwLncaIX6AsW5z0=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220405205223-5b41ba0aaeb1 h1:vdxL7id6rXNHNAh7yHUHiTsTvFupt+c7MBa+1bru+48=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220405205223-5b41ba0aaeb1/go.mod h1:4Z0mpi7fkyqjxUdGiNMO3vagyiUoiwLncaIX6AsW5z0=
|
||||
github.com/aerospike/aerospike-client-go v4.5.0+incompatible h1:6ALev/Ge4jW5avSLoqgvPYTh+FLeeDD9xDhzoMCNgOo=
|
||||
github.com/aerospike/aerospike-client-go v4.5.0+incompatible/go.mod h1:zj8LBEnWBDOVEIJt8LvaRvDG5ARAoa5dBeHaB472NRc=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
|
|
|
@ -320,12 +320,23 @@ func (c *StateStore) Delete(req *state.DeleteRequest) error {
|
|||
options := []documentdb.CallOption{documentdb.PartitionKey(partitionKey)}
|
||||
|
||||
items := []CosmosItem{}
|
||||
_, err = c.client.QueryDocuments(
|
||||
c.getCollectionLink(),
|
||||
documentdb.NewQuery("SELECT * FROM ROOT r WHERE r.id=@id", documentdb.P{Name: "@id", Value: req.Key}),
|
||||
&items,
|
||||
options...,
|
||||
)
|
||||
err = retryOperation(func() error {
|
||||
_, innerErr := c.client.QueryDocuments(
|
||||
c.getCollectionLink(),
|
||||
documentdb.NewQuery("SELECT * FROM ROOT r WHERE r.id=@id", documentdb.P{Name: "@id", Value: req.Key}),
|
||||
&items,
|
||||
options...,
|
||||
)
|
||||
if innerErr != nil {
|
||||
if isTooManyRequestsError(innerErr) {
|
||||
return innerErr
|
||||
}
|
||||
return backoff.Permanent(innerErr)
|
||||
}
|
||||
return nil
|
||||
}, func(err error, d time.Duration) {
|
||||
c.logger.Warnf("CosmosDB state store Delete Query request failed: %v; retrying in %s", err, d)
|
||||
}, 20*time.Second)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if len(items) == 0 {
|
||||
|
@ -491,6 +502,7 @@ func (c *StateStore) getSprocLink(sprocName string) string {
|
|||
|
||||
func (c *StateStore) checkStoredProcedures() error {
|
||||
var ver int
|
||||
// not wrapping this in a retryable block because this method is already used as part of one
|
||||
err := c.client.ExecuteStoredProcedure(c.getSprocLink(versionSpName), nil, &ver, documentdb.PartitionKey("1"))
|
||||
if err == nil {
|
||||
c.logger.Debugf("Cosmos DB stored procedure version: %d", ver)
|
||||
|
@ -506,6 +518,7 @@ func (c *StateStore) ensureStoredProcedures() error {
|
|||
verSpLink := c.getSprocLink(versionSpName)
|
||||
|
||||
// get a link to the sp's
|
||||
// not wrapping this in a retryable block because this method is already used as part of one
|
||||
sp, err := c.client.ReadStoredProcedure(spLink)
|
||||
if err != nil && !isNotFoundError(err) {
|
||||
return err
|
||||
|
|
|
@ -3,7 +3,7 @@ module github.com/dapr/components-contrib/tests/certification/bindings/azure/cos
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/a8m/documentdb v1.3.1-0.20220331220217-1e66c639b09a
|
||||
github.com/a8m/documentdb v1.3.1-0.20220405205223-5b41ba0aaeb1
|
||||
github.com/dapr/components-contrib v1.7.0-rc.1
|
||||
github.com/dapr/components-contrib/tests/certification v0.0.0-20211130185200-4918900c09e1
|
||||
github.com/dapr/dapr v1.7.0-rc.2
|
||||
|
|
|
@ -108,8 +108,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
|
|||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220331220217-1e66c639b09a h1:R6ZVJrvLESkVdoKt5B5ayx8DgS3n7X0dpTHYTs2sahU=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220331220217-1e66c639b09a/go.mod h1:4Z0mpi7fkyqjxUdGiNMO3vagyiUoiwLncaIX6AsW5z0=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220405205223-5b41ba0aaeb1 h1:vdxL7id6rXNHNAh7yHUHiTsTvFupt+c7MBa+1bru+48=
|
||||
github.com/a8m/documentdb v1.3.1-0.20220405205223-5b41ba0aaeb1/go.mod h1:4Z0mpi7fkyqjxUdGiNMO3vagyiUoiwLncaIX6AsW5z0=
|
||||
github.com/agrea/ptr v0.0.0-20180711073057-77a518d99b7b h1:WMhlIaJkDgEQSVJQM06YV+cYUl1r5OY5//ijMXJNqtA=
|
||||
github.com/agrea/ptr v0.0.0-20180711073057-77a518d99b7b/go.mod h1:Tie46d3UWzXpj+Fh9+DQTyaUxEpFBPOLXrnx7nxlKRo=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
|
|
Loading…
Reference in New Issue