Merge pull request #32295 from xiaozhu36/xiaozhu

backend/oss: Ignore the getting oss endpoint error and using string concat instead; Improves the error message level
This commit is contained in:
Alisdair McDiarmid 2022-12-05 10:03:20 -05:00 committed by GitHub
commit 80fddc431e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 15 deletions

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
@ -16,6 +15,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
@ -379,12 +380,13 @@ func (b *Backend) configure(ctx context.Context) error {
if endpoint == "" { if endpoint == "" {
endpointsResponse, err := b.getOSSEndpointByRegion(accessKey, secretKey, securityToken, region) endpointsResponse, err := b.getOSSEndpointByRegion(accessKey, secretKey, securityToken, region)
if err != nil { if err != nil {
return err log.Printf("[WARN] getting oss endpoint failed and using oss-%s.aliyuncs.com instead. Error: %#v.", region, err)
} } else {
for _, endpointItem := range endpointsResponse.Endpoints.Endpoint { for _, endpointItem := range endpointsResponse.Endpoints.Endpoint {
if endpointItem.Type == "openAPI" { if endpointItem.Type == "openAPI" {
endpoint = endpointItem.Endpoint endpoint = endpointItem.Endpoint
break break
}
} }
} }
if endpoint == "" { if endpoint == "" {

View File

@ -180,23 +180,22 @@ func (c *RemoteClient) Lock(info *statemgr.LockInfo) (string, error) {
}, },
} }
log.Printf("[DEBUG] Recording state lock in tablestore: %#v", putParams) log.Printf("[DEBUG] Recording state lock in tablestore: %#v; LOCKID:%s", putParams, c.lockPath())
_, err := c.otsClient.PutRow(&tablestore.PutRowRequest{ _, err := c.otsClient.PutRow(&tablestore.PutRowRequest{
PutRowChange: putParams, PutRowChange: putParams,
}) })
if err != nil { if err != nil {
log.Printf("[WARN] Error storing state lock in tablestore: %#v", err) err = fmt.Errorf("invoking PutRow got an error: %#v", err)
lockInfo, infoErr := c.getLockInfo() lockInfo, infoErr := c.getLockInfo()
if infoErr != nil { if infoErr != nil {
log.Printf("[WARN] Error getting lock info: %#v", err) err = multierror.Append(err, fmt.Errorf("\ngetting lock info got an error: %#v", infoErr))
err = multierror.Append(err, infoErr)
} }
lockErr := &statemgr.LockError{ lockErr := &statemgr.LockError{
Err: err, Err: err,
Info: lockInfo, Info: lockInfo,
} }
log.Printf("[WARN] state lock error: %#v", lockErr) log.Printf("[ERROR] state lock error: %s", lockErr.Error())
return "", lockErr return "", lockErr
} }
@ -386,13 +385,11 @@ func (c *RemoteClient) Unlock(id string) error {
}, },
}, },
Condition: &tablestore.RowCondition{ Condition: &tablestore.RowCondition{
RowExistenceExpectation: tablestore.RowExistenceExpectation_EXPECT_EXIST, RowExistenceExpectation: tablestore.RowExistenceExpectation_IGNORE,
}, },
}, },
} }
log.Printf("[DEBUG] Deleting state lock from tablestore: %#v", params)
_, err = c.otsClient.DeleteRow(params) _, err = c.otsClient.DeleteRow(params)
if err != nil { if err != nil {