Skip to content
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

Implement vfs with openstack swift #3708

Merged
merged 1 commit into from
Nov 4, 2017

Conversation

zengchen1024
Copy link
Contributor

@zengchen1024 zengchen1024 commented Oct 27, 2017

Add a new implementation of VFS to store the state of cluster in order to support deploying k8s on openstack.
Which issue this PR fixes: #3676

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 27, 2017
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 27, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @zengchen1024. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 27, 2017
@justinsb
Copy link
Member

@zengchen1024 scanned this and it looks great (are you able to sign the CLA?)

If you want to be able to use swift paths transparently throughout kops (and you probably do!), you'll have to plug it into the VFSContext here: https://github.com/kubernetes/kops/blob/master/util/pkg/vfs/context.go#L95

I don't know if swift has a "default" url prefix, like s3 has s3:// and Google cloud storage has gs:// ? (is it swift://) It doesn't really matter, we just want to use something that is consistent and unambiguous for users, and so if the normal swift CLI tools accept "swift://..." we should use that :-)

@justinsb justinsb self-assigned this Oct 27, 2017
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 28, 2017
@zengchen1024
Copy link
Contributor Author

@justinsb Thank you very much for your comments! I have added the codes in "context.go". Regarding to the url of "swift://...". as my understanding, the prefix is just used to separate it from other different cloud storages, so I use the name of "swift". Besides, the Openstack is different from other cloud platform, like aws, google etc. There are many Openstack cloud platform, but only one aws/google cloud platform. Because everyone can build his own Openstack cloud platform, but he can not build aws/google.

@edisonxiang
Copy link

It's better to refer your issue number in your comments.
Which issue this PR fixes: #

@zengchen1024
Copy link
Contributor Author

/cc @chrislovecnm @dims Could please take a look at this pr. Thanks! @chrislovecnm

return nil, fmt.Errorf("invalid openstack cloud storage path: %q", p)
}

swiftClient, err := NewSwiftClient()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future, you might want to cache this, for 2 reasons:

  1. efficiency in reusing the swift client
  2. it means we can configure the swift client specially, either for testing purposes or because we want to pass special options to it

But we can definitely wait until it is needed!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good comments! I understand and will update it!

@@ -0,0 +1,453 @@
/*
Copyright 2016 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 2017 :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. Thanks!

func (_ OpenstackConfig) filename() (string, error) {
name := os.Getenv("OPENSTACK_CREDENTIAL_FILE")
if name != "" {
return name, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a tip, you might want to (for example) glog.V(2).Infof("using openstack config from credentials found in OPENSTACK_CREDENTIAL_FILE: %s", name) etc

The idea being that if someone reports "I don't know where openstack is getting its configuration from" or "My openstack is not picking up the right credentials" we can ask them to run with --v=2 and get a hint as to why.

But just a suggestion for the future :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion! will update it!

if homeDir == "" {
return "", fmt.Errorf("can not find home directory")
}
return filepath.Join(homeDir, ".openstack", "config"), nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I would probably glog.V(2) it here also then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update it!

if !strings.HasSuffix(prefix, "/") {
prefix += "/"
}
opt := swiftobject.ListOpts{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ReadTree is supposed to be recursive (ls -R), and ReadDir is supposed to be non-recursive (ls). Does swift support that? On S3 for example, we set Delimiter for ReadDir, but not for ReadTree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, Swift support it. But it should pass different option to the method of "swiftobject.List". In my test environment, I create several objects as following
bucket: kops
a/a.txt
a/b/b1.txt
a/b/b2.txt
a/b/c/c.txt
if key=a, ReadDir will return a/a.txt; ReadTree will return all of the 4 objects.
if key=a/b, ReadDir will return a/b/b1.txt and a/b/b2.txt; ReadTree will return a/b/b1.txt, a/b/b2.txt and a/b/c/c.txt
if key=a/b/c, both ReadDir and ReadTree will return a/b/c/c.txt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's absolutely correct. But looking at the two functions (ReadDir & ReadTree) I don't see a difference - am I just missing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is a very small difference. The variable of 'prefix' is assigned to the different member of 'CreatOpts' in these two method respectively. In ReadDir, CreateOpts.Path = prefix; but in ReadTree, CreateOpts.Prefix= prefix. Sorry to cause you misunderstanding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - I see it now! Path vs Prefiix. Thank you :-)

@justinsb
Copy link
Member

Looks great - a few nits / suggestions, but the only real blocker is that ReadDir should behave differently from ReadTree.

I'm afraid I also merged preliminary ACL support, so you need to add an acl ACL argument to your CreateFile function. No need to do anything with it yet though!

Also this is still marked as WIP in the PR title here :-)

@zengchen1024
Copy link
Contributor Author

@justinsb Thank you very much for review! Your suggestions are very good! First, regarding to the method of 'ReadDir' and 'ReadTree', see my comment. Second, I see you have added a new parameter of 'acl ACL' to method of 'CreateFile', I will try to update my codes. Last, this PR is still marcked as WIP, because the dependency of 'gophercloud' should be updated first, otherwise it will be broken if using 'swiftfs'.

@justinsb
Copy link
Member

For the dependencies, if you want to try you can try adding this: https://github.com/kubernetes/kops/blob/release/docs/development/dependencies.md

If you have trouble though, just let me know and I can send a PR to add the openstack dependency.

We should probably add the same one as used in k8s 1.8 https://github.com/kubernetes/kubernetes/blob/release-1.8/Godeps/Godeps.json#L1625 , which looks like 2bf16b94fdd9b01557c4d076e567fe5cbbe5a961

@zengchen1024
Copy link
Contributor Author

@justinsb Yes, I am trying to add a PR to update 'gophercloud' to the newest version. If you have a PR, it is great and could you send me the link of your PR? There is one question why do you update it to the version of '2bf16b94fdd9b01557c4d076e567fe5cbbe5a961' but not the newest version. In my test, It can work with the newest 'gophercloud'. And I need to test to see whether it is right with your special version one.

@zengchen1024
Copy link
Contributor Author

@justinsb Sorry, I did not understand your comment about updating the dependency of 'gophercloud'. The current version of 'gophercloud' is '2bf16b94fdd9b01557c4d076e567fe5cbbe5a961'. I will add a PR to update it to the newest version. Thanks for your guidance!

@zengchen1024
Copy link
Contributor Author

/assign @zengchen1024

@k8s-github-robot
Copy link

@zengchen1024 PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2017
@zengchen1024
Copy link
Contributor Author

/hold cancel

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2017
@zengchen1024 zengchen1024 changed the title [WIP]implement vfs with openstack swift Implement vfs with openstack swift Nov 2, 2017
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 2, 2017
@zengchen1024
Copy link
Contributor Author

/cc @chrislovecnm @justinsb , Please, take a look at this PR, thanks!

@zengchen1024
Copy link
Contributor Author

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@zengchen1024: you can't request testing unless you are a kubernetes member.

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@justinsb
Copy link
Member

justinsb commented Nov 4, 2017

/ok-to-test

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 4, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2017
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@justinsb
Copy link
Member

justinsb commented Nov 4, 2017

/retest

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue.

@k8s-github-robot k8s-github-robot merged commit 2b3ac16 into kubernetes:master Nov 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement VFS with Openstack Swift
5 participants