Skip to content

Commit

Permalink
fix: Surface error during wait timeout for OSS artifact driver API ca…
Browse files Browse the repository at this point in the history
…lls (#5601)
  • Loading branch information
terrytangyuan authored Apr 8, 2021
1 parent ec4c662 commit 88917cb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions workflow/artifacts/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
waitutil "github.com/argoproj/argo-workflows/v3/util/wait"
"github.com/argoproj/argo-workflows/v3/workflow/artifacts/common"
)

Expand All @@ -22,10 +23,13 @@ type ArtifactDriver struct {
SecurityToken string
}

var _ common.ArtifactDriver = &ArtifactDriver{}
var (
_ common.ArtifactDriver = &ArtifactDriver{}
defaultRetry = wait.Backoff{Duration: time.Second * 2, Factor: 2.0, Steps: 5, Jitter: 0.1}

// OSS error code reference: https://error-center.alibabacloud.com/status/product/Oss
var ossTransientErrorCodes = []string{"RequestTimeout", "QuotaExceeded.Refresh", "Default", "ServiceUnavailable", "Throttling", "RequestTimeTooSkewed", "SocketException", "SocketTimeout", "ServiceBusy", "DomainNetWorkVisitedException", "ConnectionTimeout", "CachedTimeTooLarge"}
// OSS error code reference: https://error-center.alibabacloud.com/status/product/Oss
ossTransientErrorCodes = []string{"RequestTimeout", "QuotaExceeded.Refresh", "Default", "ServiceUnavailable", "Throttling", "RequestTimeTooSkewed", "SocketException", "SocketTimeout", "ServiceBusy", "DomainNetWorkVisitedException", "ConnectionTimeout", "CachedTimeTooLarge"}
)

func (ossDriver *ArtifactDriver) newOSSClient() (*oss.Client, error) {
var options []oss.ClientOption
Expand All @@ -41,7 +45,7 @@ func (ossDriver *ArtifactDriver) newOSSClient() (*oss.Client, error) {

// Downloads artifacts from OSS compliant storage, e.g., downloading an artifact into local path
func (ossDriver *ArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string) error {
err := wait.ExponentialBackoff(wait.Backoff{Duration: time.Second * 2, Factor: 2.0, Steps: 5, Jitter: 0.1},
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
log.Infof("OSS Load path: %s, key: %s", path, inputArtifact.OSS.Key)
osscli, err := ossDriver.newOSSClient()
Expand Down Expand Up @@ -77,7 +81,7 @@ func (ossDriver *ArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string)

// Saves an artifact to OSS compliant storage, e.g., uploading a local file to OSS bucket
func (ossDriver *ArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact) error {
err := wait.ExponentialBackoff(wait.Backoff{Duration: time.Second * 2, Factor: 2.0, Steps: 5, Jitter: 0.1},
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
log.Infof("OSS Save path: %s, key: %s", path, outputArtifact.OSS.Key)
osscli, err := ossDriver.newOSSClient()
Expand Down Expand Up @@ -122,7 +126,7 @@ func (ossDriver *ArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact

func (ossDriver *ArtifactDriver) ListObjects(artifact *wfv1.Artifact) ([]string, error) {
var files []string
err := wait.ExponentialBackoff(wait.Backoff{Duration: time.Second * 2, Factor: 2.0, Steps: 5, Jitter: 0.1},
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
osscli, err := ossDriver.newOSSClient()
if err != nil {
Expand Down

0 comments on commit 88917cb

Please sign in to comment.