-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Conversation
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. |
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 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. |
@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 I don't know if swift has a "default" url prefix, like s3 has |
830fef5
to
4341985
Compare
@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. |
It's better to refer your issue number in your comments. |
4341985
to
e0d03fa
Compare
/cc @chrislovecnm @dims Could please take a look at this pr. Thanks! @chrislovecnm |
util/pkg/vfs/context.go
Outdated
return nil, fmt.Errorf("invalid openstack cloud storage path: %q", p) | ||
} | ||
|
||
swiftClient, err := NewSwiftClient() |
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.
In future, you might want to cache this, for 2 reasons:
- efficiency in reusing the swift client
- 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!
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.
good comments! I understand and will update it!
util/pkg/vfs/swiftfs.go
Outdated
@@ -0,0 +1,453 @@ | |||
/* | |||
Copyright 2016 The Kubernetes Authors. |
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.
Nit: 2017 :-)
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.
got it. Thanks!
util/pkg/vfs/swiftfs.go
Outdated
func (_ OpenstackConfig) filename() (string, error) { | ||
name := os.Getenv("OPENSTACK_CREDENTIAL_FILE") | ||
if name != "" { | ||
return name, nil |
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.
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 :-)
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.
good suggestion! will update it!
util/pkg/vfs/swiftfs.go
Outdated
if homeDir == "" { | ||
return "", fmt.Errorf("can not find home directory") | ||
} | ||
return filepath.Join(homeDir, ".openstack", "config"), nil |
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.
And I would probably glog.V(2)
it here also then
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.
will update it!
if !strings.HasSuffix(prefix, "/") { | ||
prefix += "/" | ||
} | ||
opt := swiftobject.ListOpts{ |
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.
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.
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.
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
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.
That's absolutely correct. But looking at the two functions (ReadDir & ReadTree) I don't see a difference - am I just missing it?
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.
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.
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.
Oops - I see it now! Path vs Prefiix. Thank you :-)
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 Also this is still marked as WIP in the PR title here :-) |
@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'. |
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 |
@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. |
@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! |
e0d03fa
to
ce6ef6a
Compare
/assign @zengchen1024 |
ce6ef6a
to
b110557
Compare
@zengchen1024 PR needs rebase |
b110557
to
3707f87
Compare
/hold cancel |
3707f87
to
bbfd1e1
Compare
/cc @chrislovecnm @justinsb , Please, take a look at this PR, thanks! |
/ok-to-test |
@zengchen1024: you can't request testing unless you are a kubernetes member. In response to this:
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. |
/ok-to-test /lgtm |
[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 |
/test all [submit-queue is verifying that this PR is safe to merge] |
/retest |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. |
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