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

Adds the functionality of unmounting storage using the mounted path. #492

Merged
merged 1 commit into from Jun 11, 2018

Conversation

mik-dass
Copy link
Contributor

@mik-dass mik-dass commented May 31, 2018

Issue : #493
Signed-off-by: mdas mrinald7@gmail.com

@surajnarwade
Copy link
Contributor

@mik-dass , code looks good. Please check whether you can add tests or not

cmd/storage.go Outdated
fmt.Printf("Storage %v does not exist in component %v\n", storageName, componentName)
os.Exit(1)
storageName := ""
if string(args[0][0]) == "/" {
Copy link
Member

Choose a reason for hiding this comment

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

It might be nice to have command explaining what we are doing here.

@cdrage
Copy link
Member

cdrage commented Jun 4, 2018

What would happen if we pass in: ./ or something that is not valid (or does not exist)? Shouldn't we error out to the user?

@mik-dass
Copy link
Contributor Author

mik-dass commented Jun 5, 2018

@cdrage You mean at the start of the path?

@cdrage
Copy link
Member

cdrage commented Jun 5, 2018

@mik-dass Yes

@mik-dass
Copy link
Contributor Author

mik-dass commented Jun 6, 2018

@cdrage I think it might be complicated as there are many combinations which are possible

@kadel
Copy link
Member

kadel commented Jun 7, 2018

What would happen if we pass in: ./ or something that is not valid (or does not exist)? Shouldn't we error out to the user?

This should be treated as a storage name, and it should fail because no such storage exits.

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

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

Use for unmount command needs to be updated.

Use:   "unmount [storage name]",

Also, Long description should explain that this command can be called with a path and that path needs to be absolute.

cmd/storage.go Outdated
Use: "unmount [storage name]",
Short: "Unmount storage from the current component",
Long: `Unmount storage from the current component.
Use: "unmount [storage/path name]",
Copy link
Member

Choose a reason for hiding this comment

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

we can update this based on #516
"PATH | STORAGE_NAME"

cmd/storage.go Outdated
Long: `Unmount storage from the current component.
Use: "unmount [storage/path name]",
Short: "Unmount storage or storage with the given path, from the current component",
Long: `Unmount storage or storage with the given path, from the current component.
Copy link
Member

Choose a reason for hiding this comment

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

How about this:
Unmount storage from the given path or unmount storage identified by its name.

@mik-dass
Copy link
Contributor Author

mik-dass commented Jun 7, 2018

@kadel Done

cmd/storage.go Outdated
Use: "unmount [storage name]",
Short: "Unmount storage from the current component",
Long: `Unmount storage from the current component.
Use: "unmount [PATH | STORAGE_NAME]",
Copy link
Member

Choose a reason for hiding this comment

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

this should be lowercase, other sources (such as create.go) use lowercase.

unmount <path | storage_name> maybe better?

Copy link
Member

@kadel kadel Jun 8, 2018

Choose a reason for hiding this comment

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

@cdrage see #516

there are two options, either uppercase or lowercase in <>

Copy link
Member

Choose a reason for hiding this comment

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

@mik-dass it can't be in [] as it means that it is optional. Please check rules in #516

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kadel So between <>?

Copy link
Member

Choose a reason for hiding this comment

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

As described in docopts docs (link in #516)

either just capital letters

unmount PATH | STORAGE_NAME

or in <>

unmount <path> | <storage_name>

I would use the capital letters, it seems to be more widly used (heroku and could foundry).
We should pick one and stick with it across all commands in OpenShift-Do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kadel OK I will changed to the Upper case approach

cmd/storage.go Outdated
if !exists {
fmt.Printf("Storage %v does not exist in component %v\n", storageName, componentName)
os.Exit(1)
storageName := ""
Copy link
Member

Choose a reason for hiding this comment

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

if this starts as blank, I think var storageName string is more go-esque

cmd/storage.go Outdated
if string(args[0][0]) == "/" {
path := args[0]
storageName, err = storage.GetStorageNameFromMountPath(client, path, componentName, applicationName)
checkError(err, "")
Copy link
Member

Choose a reason for hiding this comment

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

instead of "" maybe add explanation (Unable to get storage name from mount path) or something similar?

cmd/storage.go Outdated
} else {
storageName = args[0]
exists, err := storage.IsMounted(client, storageName, componentName, applicationName)
checkError(err, "")
Copy link
Member

Choose a reason for hiding this comment

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

same here, maybe add own explanation?

func GetStorageNameFromMountPath(client *occlient.Client, path string, componentName string, applicationName string) (string, error) {
storages, err := List(client, componentName, applicationName)
if err != nil {
return "", errors.Wrap(err, "unable to list storages")
Copy link
Member

Choose a reason for hiding this comment

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

storage not storages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cdrage But we refer to one PVC as storage

Copy link
Member

@cdrage cdrage Jun 8, 2018

Choose a reason for hiding this comment

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

@mik-dass Storage is an uncountable plural, we just use "storage" not "storages". https://en.wiktionary.org/wiki/storage

Copy link
Contributor Author

@mik-dass mik-dass Jun 11, 2018

Choose a reason for hiding this comment

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

@cdrage I know about the plural form but here a single PVC is called storage and all of them together is also called storage. It seemed confusing. So I added the 's' to distinguish. Anyways updating it.

@mik-dass mik-dass force-pushed the unmount_path branch 2 times, most recently from baa2fb7 to 722b9e1 Compare June 11, 2018 09:49
@cdrage
Copy link
Member

cdrage commented Jun 11, 2018

LGTM

…A function GetStorageNameFromMountPath is added which returns the storageName mounted to the given path in the given component and application or returns the error.

Signed-off-by: mdas <mrinald7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants