-
Notifications
You must be signed in to change notification settings - Fork 82
Adding glustercli command to get options of all volumes #1406
base: master
Are you sure you want to change the base?
Conversation
db798a6
to
cd8527b
Compare
retest this please |
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.
please paste the sample output for below scenario.
- volume option for one volume
- options for all
Volume option for all volumes :
Volume option for one volume:
|
retest this please |
am i missing anything, the table you declared as the |
log.WithError(err).Error("error getting volume options") | ||
failure("Error getting volume options", err, 1) | ||
var volList []string | ||
if volname == "all" { |
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.
what happens if the user creates a volume with the name all
and want to fetch the volume option for that particular volume :D.
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 point, we need to reserve these keywords(all
, status
, volume
etc) and not allow volume create.
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.
Nice Catch, should I add this to volume-create?
For uniformity you can retain "Volume name" even in single volume output. Or follow convention similar to volume status
|
@aravindavk Made the changes, can you check if this is what you wanted? |
4a5645d
to
6f0f2ba
Compare
|
||
} | ||
} | ||
table.Render() |
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.
print one extra line after the table
@@ -42,6 +43,11 @@ func validateVolCreateReq(req *api.VolCreateReq) error { | |||
return gderrors.ErrInvalidVolName | |||
} | |||
|
|||
if gutils.IsReservedKeyword(req.Name) { | |||
errMsg := fmt.Sprintf("invalid name, volume name cannot be among GD2 reserved keywords:%v", gutils.ReservedKeywords) | |||
return errors.New(errMsg) |
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.
you can use fmt.Errorf
return fmt.Errorf("invalid name, volume name cannot be among GD2 reserved keywords:%v", gutils.ReservedKeywords)
pkg/utils/utils.go
Outdated
@@ -31,6 +31,17 @@ const ( | |||
TiB = 1024 * GiB | |||
) | |||
|
|||
var ( | |||
// ReservedKeywords are Glusterd2 reserved keywords | |||
ReservedKeywords = []string{"all", "volume", "status", "list"} |
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.
also include "cluster", "gluster", "brick"
Issue #1385 talks about showing cluster options. But this PR only includes showing options of all volumes. Cluster options are available in https://github.com/gluster/glusterd2/blob/master/glusterd2/commands/options/commands.go#L25 and the list of valid options are maintained here https://github.com/gluster/glusterd2/blob/master/glusterd2/options/cluster.go#L29 |
6f0f2ba
to
49f2c8d
Compare
|
49f2c8d
to
6dde8aa
Compare
glustercli/cmd/cluster-options.go
Outdated
} | ||
failure("Cluster option set failed", err, 1) | ||
} else { | ||
fmt.Printf("Options set successfully \n") |
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.
why can't you use fmt.Println()
?
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.
Would it make a big difference?
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.
we already have a function that provides the same functionality, what's the issue in using default function?
glustercli/cmd/cluster-options.go
Outdated
|
||
err := client.ClusterOptionSet(api.ClusterOptionReq{ | ||
Options: copt}) | ||
if err != 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.
return err
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.
I am returning err at line 75, am I missing something?
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.
what is the advantage you are getting by doing the error check here?
glustercli/cmd/cluster-options.go
Outdated
var clusterOptionGetCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: helpClusterOptionGetCmd, | ||
Args: cobra.RangeArgs(0, 1), |
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.
where you are making use of args
here?
@@ -42,6 +43,10 @@ func validateVolCreateReq(req *api.VolCreateReq) error { | |||
return gderrors.ErrInvalidVolName | |||
} | |||
|
|||
if gutils.IsReservedKeyword(req.Name) { | |||
return fmt.Errorf("invalid name, volume name cannot be among glusterd reserved keywords:%v", gutils.ReservedKeywords) |
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.
glusterd
or glusterd2
?
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 a point I want to discuss, will users be always referring the glustercli daemon as gluster daemon 2 or is it just temperory.
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.
@aravindavk ^^
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.
you can skip that word itself. "invalid name, volume name cannot be among reserved keywords"
@@ -42,6 +43,10 @@ func validateVolCreateReq(req *api.VolCreateReq) error { | |||
return gderrors.ErrInvalidVolName | |||
} | |||
|
|||
if gutils.IsReservedKeyword(req.Name) { |
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.
please add a e2e test case of this
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.
Same as mentioned for other case, please add this as well in the same issue
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.
these code changes are in this PR so that I would like to see an e2e in this PR itself.
) | ||
|
||
// GetClusterOption gets cluster level options | ||
func (c *Client) GetClusterOption() ([]api.ClusterOptionsResp, error) { |
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.
add e2e test case of this.
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.
Not a part of this PR, this PR only addresses glustercli commands, I will add e2e test cases for cluster option in separate PR, please raise an issue for it will fix that issue.
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.
why you would like to add Client library in one PR and add e2e in other PR. what the concern here?
even if you are adding a functionality for CLI, you are adding a client library.
@@ -31,6 +31,17 @@ const ( | |||
TiB = 1024 * GiB | |||
) | |||
|
|||
var ( | |||
// ReservedKeywords are Glusterd2 reserved keywords | |||
ReservedKeywords = []string{"all", "volume", "status", "list", "cluster", "gluster", "brick"} |
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.
add comment for why we are reserving these keywords
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.
Reserved key words is self explanatory
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.
I wanted to see, why we are reserving these keywords, this will help the developers who will join later.
by these comments, I don't think they will get more context why these keywords are reserved.
glustercli/cmd/cluster-options.go
Outdated
} | ||
failure("Cluster option set failed", err, 1) | ||
} else { | ||
fmt.Printf("Options set successfully \n") |
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.
we already have a function that provides the same functionality, what's the issue in using default function?
glustercli/cmd/cluster-options.go
Outdated
|
||
err := client.ClusterOptionSet(api.ClusterOptionReq{ | ||
Options: copt}) | ||
if err != 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.
what is the advantage you are getting by doing the error check here?
@@ -42,6 +43,10 @@ func validateVolCreateReq(req *api.VolCreateReq) error { | |||
return gderrors.ErrInvalidVolName | |||
} | |||
|
|||
if gutils.IsReservedKeyword(req.Name) { |
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.
these code changes are in this PR so that I would like to see an e2e in this PR itself.
@@ -42,6 +43,10 @@ func validateVolCreateReq(req *api.VolCreateReq) error { | |||
return gderrors.ErrInvalidVolName | |||
} | |||
|
|||
if gutils.IsReservedKeyword(req.Name) { | |||
return fmt.Errorf("invalid name, volume name cannot be among glusterd reserved keywords:%v", gutils.ReservedKeywords) |
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.
@aravindavk ^^
) | ||
|
||
// GetClusterOption gets cluster level options | ||
func (c *Client) GetClusterOption() ([]api.ClusterOptionsResp, error) { |
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.
why you would like to add Client library in one PR and add e2e in other PR. what the concern here?
even if you are adding a functionality for CLI, you are adding a client library.
@@ -31,6 +31,17 @@ const ( | |||
TiB = 1024 * GiB | |||
) | |||
|
|||
var ( | |||
// ReservedKeywords are Glusterd2 reserved keywords | |||
ReservedKeywords = []string{"all", "volume", "status", "list", "cluster", "gluster", "brick"} |
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.
I wanted to see, why we are reserving these keywords, this will help the developers who will join later.
by these comments, I don't think they will get more context why these keywords are reserved.
[root@localhost glusterd2]# ./build/glustercli cluster get Can we please clean up the global option tables with all the unwanted options which were defined as place holders to begin in. For eg : cluster.localtime-logging , cluster.shared-storage are not applicable. Also cluster.op-version, cluster,max-op-version values need change and it should stay with current glusterfs master. Also I'm not particularly sure about if the cli naming convention is correct here. glustercli cluster get doesn't give a proper meaning. Would like to hear thoughts from @aravindavk @kshlm on this. |
14fc355
to
95ef5aa
Compare
@atinmu Regarding cli naming convention in #1406 (comment), I tried to keep it uniform with volume options |
4ce21c4
to
af6ec95
Compare
Signed-off-by: rishubhjain <rishubhjain47@gmail.com>
af6ec95
to
7fbccba
Compare
@Madhu-1 Are we good with this PR? |
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.
need small changes or else good to go.
r.NotNil(clusterOps) | ||
} | ||
|
||
func ClusterOptionsSet(t *testing.T) { |
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.
am not able to find out where this is getting called?
log.WithError(err).Error("cluster option set failed") | ||
} | ||
failure("Cluster option set failed", err, 1) | ||
} else { |
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.
we can remove this else block, as failure does exit 1.
@@ -27,12 +27,10 @@ type validateFunc func(string, string) error | |||
|
|||
// ClusterOptMap contains list of supported cluster-wide options, default values and value types | |||
var ClusterOptMap = map[string]*ClusterOption{ | |||
"cluster.shared-storage": {"cluster.shared-storage", "off", OptionTypeBool, 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.
any specific reason for removing this option?
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.
shared-storage feature isn't a need in GD2 as of now and such feature doesn't exist yet.
@@ -233,39 +233,55 @@ var volumeDeleteCmd = &cobra.Command{ | |||
} | |||
|
|||
var volumeGetCmd = &cobra.Command{ | |||
Use: "get", | |||
Use: "get <VOLNAME|all> <key|all>", |
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.
can we rename key
to option
as we are getting option details?
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.
what ever we chose here (In GD1's CLI it's referred as key though), request it to be used consistently across.
Can we please close down this PR today? It's been hanging around for a while now :-) |
@rishubhjain please address the comments and rebase |
@aravindavk Is this a GCS 1.0 blocker? |
Fixes:#1385
Signed-off-by: rishubhjain rishubhjain47@gmail.com