-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for Alibaba Cloud OSS artifact #1919
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
2925d8d
oss artifact configure
merlintang 7f12f52
update for the oss configue
merlintang 7b9015b
update with upstream
merlintang 2ced7ad
update for passing the test
merlintang 5327b24
update the codegen
merlintang 7245cb8
triger ci
merlintang 7e06961
test
merlintang 970f130
update the openapi
merlintang 8da9a34
Revert "update the openapi"
merlintang b5a9083
update the oss artifact yaml
merlintang b90167a
update the oss artifact yaml
merlintang ece451e
Merge branch 'oss-artifact' of github.com:merlintang/argo into oss-ar…
merlintang 27621b9
update with codegen
merlintang 6e69f74
update for the ci
merlintang 5441cbe
Merge remote-tracking branch 'upstream/master' into oss-artifact
merlintang 6c407d7
update for the golang
merlintang 9175f3b
fix the goformat
merlintang a6fc3c3
Merge remote-tracking branch 'upstream/master' into oss-artifact
merlintang a7b2f7d
update the link
merlintang 1ebed7f
make go happy
merlintang ecffead
gofrmat
merlintang c318f13
update with goimports
merlintang 1852b37
update goimports
merlintang f4340c5
update go imports
merlintang 4fb1b9f
Merge remote-tracking branch 'upstream/master' into oss-artifact
merlintang 2dbc6e0
Delete Gopkg.toml
alexec 3e476af
Delete Gopkg.lock
alexec b88461d
Update workflow/artifacts/oss/oss.go
alexec 73cfb87
This is a blank commit
merlintang e084ac0
triger the ci
merlintang 896cebd
update with comments
merlintang 527d492
goformat
merlintang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This example demonstrates the loading of a hard-wired input artifact from an OSS compliant | ||
# store. OSS guards access to buckets using an access key and | ||
# secret key, which will be stored as regular Kubernetes secrets, and referenced in the | ||
# workflow using secret selectors. To create the secret required for this example, first | ||
# run the following command: | ||
# $ kubectl create secret generic my-oss-credentials --from-literal=accessKey=<YOUR-OSS-ACCESS-ID> --from-literal=secretKey=<YOUR-OSS-SECRET-KEY> | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: input-artifact-oss- | ||
spec: | ||
entrypoint: input-artifact-oss-example | ||
templates: | ||
- name: input-artifact-oss-example | ||
inputs: | ||
artifacts: | ||
- name: my-art | ||
path: /my-artifact | ||
oss: | ||
endpoint: http://oss-cn-hangzhou-zmf.aliyuncs.com | ||
bucket: test-bucket-name | ||
key: test/mydirectory/ # this is path in the bucket | ||
# accessKeySecret and secretKeySecret are secret selectors. | ||
# It references the k8s secret named 'my-oss-credentials'. | ||
# This secret is expected to have have the keys 'accessKey' | ||
# and 'secretKey', containing the base64 encoded credentials | ||
# to the bucket. | ||
accessKeySecret: | ||
name: my-oss-credentials | ||
key: accessKey | ||
secretKeySecret: | ||
name: my-oss-credentials | ||
key: secretKey | ||
container: | ||
image: debian:latest | ||
command: [sh, -c] | ||
args: ["ls -l /my-artifact"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package oss | ||
|
||
import ( | ||
alexec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"time" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
|
||
"github.com/aliyun/aliyun-oss-go-sdk/oss" | ||
|
||
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" | ||
) | ||
|
||
// OSSArtifactDriver is a driver for OSS | ||
type OSSArtifactDriver struct { | ||
Endpoint string | ||
AccessKey string | ||
SecretKey string | ||
} | ||
|
||
func (ossDriver *OSSArtifactDriver) newOSSClient() (*oss.Client, error) { | ||
client, err := oss.New(ossDriver.Endpoint, ossDriver.AccessKey, ossDriver.SecretKey) | ||
if err != nil { | ||
log.Warnf("Failed to create new OSS client: %v", err) | ||
return nil, err | ||
} | ||
return client, err | ||
} | ||
|
||
// Downloads artifacts from OSS compliant storage, e.g., downloading an artifact into local path | ||
func (ossDriver *OSSArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string) error { | ||
err := wait.ExponentialBackoff(wait.Backoff{Duration: time.Second * 2, Factor: 2.0, Steps: 5, Jitter: 0.1}, | ||
func() (bool, error) { | ||
log.Infof("OSS Load path: %s, key: %s", path, inputArtifact.OSS.Key) | ||
osscli, err := ossDriver.newOSSClient() | ||
if err != nil { | ||
log.Warnf("Failed to create new OSS client: %v", err) | ||
return false, nil | ||
} | ||
bucketName := inputArtifact.OSS.Bucket | ||
bucket, err := osscli.Bucket(bucketName) | ||
if err != nil { | ||
return false, err | ||
} | ||
objectName := inputArtifact.OSS.Key | ||
err = bucket.GetObjectToFile(objectName, path) | ||
if err != nil { | ||
return false, err | ||
} | ||
return true, nil | ||
}) | ||
return err | ||
} | ||
|
||
// Saves an artifact to OSS compliant storage, e.g., uploading a local file to OSS bucket | ||
func (ossDriver *OSSArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact) error { | ||
err := wait.ExponentialBackoff(wait.Backoff{Duration: time.Second * 2, Factor: 2.0, Steps: 5, Jitter: 0.1}, | ||
func() (bool, error) { | ||
log.Infof("OSS Save path: %s, key: %s", path, outputArtifact.OSS.Key) | ||
osscli, err := ossDriver.newOSSClient() | ||
if err != nil { | ||
log.Warnf("Failed to create new OSS client: %v", err) | ||
return false, nil | ||
} | ||
bucketName := outputArtifact.OSS.Bucket | ||
bucket, err := osscli.Bucket(bucketName) | ||
if err != nil { | ||
return false, err | ||
} | ||
objectName := outputArtifact.OSS.Key | ||
err = bucket.PutObjectFromFile(objectName, path) | ||
if err != nil { | ||
return false, err | ||
} | ||
return true, nil | ||
}) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AccessKeyID
? According to https://github.com/aliyun/aliyun-oss-python-sdk#getting-startedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your comments, it is updated.