Skip to content

Commit

Permalink
feat: implement Delete func of OSS ArtifactDriver. Fixes #9349 (#12907)
Browse files Browse the repository at this point in the history
Signed-off-by: AlbeeSo <suyashi1321@163.com>
Co-authored-by: shuangkun <tsk2013uestc@163.com>
  • Loading branch information
AlbeeSo and shuangkun committed Apr 7, 2024
1 parent 496802e commit 00101c6
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions workflow/artifacts/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,32 @@ func (ossDriver *ArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact
return err
}

// Delete is unsupported for the oss artifacts
func (ossDriver *ArtifactDriver) Delete(s *wfv1.Artifact) error {
return common.ErrDeleteNotSupported
// Delete deletes an artifact from an OSS compliant storage
func (ossDriver *ArtifactDriver) Delete(artifact *wfv1.Artifact) error {
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
log.Infof("OSS Delete artifact: key: %s", artifact.OSS.Key)
osscli, err := ossDriver.newOSSClient()
if err != nil {
return !isTransientOSSErr(err), err
}
bucketName := artifact.OSS.Bucket
err = setBucketLogging(osscli, bucketName)
if err != nil {
return !isTransientOSSErr(err), err
}
bucket, err := osscli.Bucket(bucketName)
if err != nil {
return !isTransientOSSErr(err), err
}
objectName := artifact.OSS.Key
err = bucket.DeleteObject(objectName)
if err != nil {
return !isTransientOSSErr(err), err
}
return true, nil
})
return err
}

func (ossDriver *ArtifactDriver) ListObjects(artifact *wfv1.Artifact) ([]string, error) {
Expand Down

0 comments on commit 00101c6

Please sign in to comment.