mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-11 08:32:19 -06:00
backend/oss: Ignore the getting oss endpoint error and using string concat instead; Improves the error message level
This commit is contained in:
parent
6d9dc22834
commit
ec62ca1b70
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -16,6 +15,8 @@ import (
|
||||
"strings"
|
||||
"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/auth/credentials"
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||
@ -379,12 +380,13 @@ func (b *Backend) configure(ctx context.Context) error {
|
||||
if endpoint == "" {
|
||||
endpointsResponse, err := b.getOSSEndpointByRegion(accessKey, secretKey, securityToken, region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, endpointItem := range endpointsResponse.Endpoints.Endpoint {
|
||||
if endpointItem.Type == "openAPI" {
|
||||
endpoint = endpointItem.Endpoint
|
||||
break
|
||||
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 {
|
||||
if endpointItem.Type == "openAPI" {
|
||||
endpoint = endpointItem.Endpoint
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if endpoint == "" {
|
||||
|
@ -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{
|
||||
PutRowChange: putParams,
|
||||
})
|
||||
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()
|
||||
if infoErr != nil {
|
||||
log.Printf("[WARN] Error getting lock info: %#v", err)
|
||||
err = multierror.Append(err, infoErr)
|
||||
err = multierror.Append(err, fmt.Errorf("\ngetting lock info got an error: %#v", infoErr))
|
||||
}
|
||||
lockErr := &statemgr.LockError{
|
||||
Err: err,
|
||||
Info: lockInfo,
|
||||
}
|
||||
log.Printf("[WARN] state lock error: %#v", lockErr)
|
||||
log.Printf("[ERROR] state lock error: %s", lockErr.Error())
|
||||
return "", lockErr
|
||||
}
|
||||
|
||||
@ -386,13 +385,11 @@ func (c *RemoteClient) Unlock(id string) error {
|
||||
},
|
||||
},
|
||||
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)
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user