Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Merge pull request #51 in STORAGEOS/c2-cli from feature/CP-4193-cli-r…
Browse files Browse the repository at this point in the history
…emove-volume-location-hints to master

Squashed commit of the following:

commit 1af01412eebe869ee04358c007e21c7195b4f8ee
Author: Fraser Savage <fraser.savage@storageos.com>
Date:   Tue Mar 31 11:06:25 2020 +0100

    cmd: create volume remove location hint flags

    -> lengthen default command timeout
  • Loading branch information
Fraser Savage authored and domodwyer committed Mar 31, 2020
1 parent 921530a commit c08718e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 69 deletions.
17 changes: 1 addition & 16 deletions cmd/create/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"strconv"
"strings"

"github.com/alecthomas/units"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -40,8 +39,6 @@ type volumeCommand struct {
useCompression bool
useThrottle bool
withReplicas uint64
hintMaster []string
hintReplicas []string

// Core volume configuration settings
description string
Expand Down Expand Up @@ -173,16 +170,6 @@ func (c *volumeCommand) setKnownLabels(original labels.Set) {
if c.withReplicas > 0 {
original[volume.LabelReplicas] = strconv.FormatUint(c.withReplicas, 10)
}

// If master or replica hints have been provided then rejoin the specified
// hints and set the appropriate labels.
if len(c.hintMaster) > 0 {
original[volume.LabelHintMaster] = strings.Join(c.hintMaster, ",")
}

if len(c.hintReplicas) > 0 {
original[volume.LabelHintReplicas] = strings.Join(c.hintReplicas, ",")
}
}

func newVolume(w io.Writer, client Client, config ConfigProvider) *cobra.Command {
Expand All @@ -198,7 +185,7 @@ func newVolume(w io.Writer, client Client, config ConfigProvider) *cobra.Command
Example: `
$ storageos create volume --description "This volume contains the data for my app" --fs-type "ext4" --labels env=prod,rack=db-1 --size 10GiB --namespace my-namespace-name my-app
$ storageos create volume --replicas 1 --hint-master reliable-node-1,reliable-node-2 --namespace my-namespace-name my-replicated-app
$ storageos create volume --replicas 1 --namespace my-namespace-name my-replicated-app
`,

Args: argwrappers.WrapInvalidArgsError(func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -240,8 +227,6 @@ $ storageos create volume --replicas 1 --hint-master reliable-node-1,reliable-no
cobraCommand.Flags().BoolVar(&c.useCompression, "compress", true, "compress data stored by the volume at rest and during transit")
cobraCommand.Flags().StringVarP(&c.description, "description", "d", "", "a human-friendly description to give the volume")
cobraCommand.Flags().StringVarP(&c.fsType, "fs-type", "f", "ext4", "the filesystem to format the new volume with once provisioned")
cobraCommand.Flags().StringSliceVar(&c.hintMaster, "hint-master", []string{}, "an optional list of preferred nodes for placement of the volume master")
cobraCommand.Flags().StringArrayVar(&c.hintReplicas, "hint-replicas", []string{}, "an optional list of preferred nodes for placement of volume replicas")
cobraCommand.Flags().StringSliceVarP(&c.labelPairs, "labels", "l", []string{}, "an optional set of labels to assign to the new volume, provided as a comma-separated list of key=value pairs")
cobraCommand.Flags().Uint64VarP(&c.withReplicas, "replicas", "r", 0, "the number of replicated copies of the volume to maintain")
cobraCommand.Flags().StringVarP(&c.sizeStr, "size", "s", "5GiB", "the capacity to provision the volume with")
Expand Down
44 changes: 0 additions & 44 deletions cmd/create/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,50 +101,6 @@ func TestSetKnownLabels(t *testing.T) {
"storageos.com/throttle": "false",
},
},
{
name: "sets storageos.com/hint.master when given",

cmd: &volumeCommand{
hintMaster: []string{"node-a", "node-b", "node-c"},

// defaults of true
useCaching: true,
useCompression: true,
},
inputLabels: labels.Set{
"arbitrary-label": "arbitrary-value",
},

wantLabels: labels.Set{
"arbitrary-label": "arbitrary-value",
"storageos.com/nocache": "false",
"storageos.com/nocompress": "false",
"storageos.com/hint.master": "node-a,node-b,node-c",
"storageos.com/throttle": "false",
},
},
{
name: "sets storageos.com/hint.replicas when given",

cmd: &volumeCommand{
hintReplicas: []string{"node-a", "node-b", "node-c"},

// defaults of true
useCaching: true,
useCompression: true,
},
inputLabels: labels.Set{
"arbitrary-label": "arbitrary-value",
},

wantLabels: labels.Set{
"arbitrary-label": "arbitrary-value",
"storageos.com/nocache": "false",
"storageos.com/nocompress": "false",
"storageos.com/hint.replicas": "node-a,node-b,node-c",
"storageos.com/throttle": "false",
},
},
}

for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion config/defaulter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
DefaultAPIEndpoint = "http://localhost:5705"
// DefaultCommandTimeout is a sensible command timeout duration to use when
// none has been specified.
DefaultCommandTimeout = 5 * time.Second
DefaultCommandTimeout = 15 * time.Second
// DefaultUsername defines a fallback username which the CLI will
// attempt to use in the credentials presented to the StorageOS API for
// authentication.
Expand Down
8 changes: 0 additions & 8 deletions volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ const (
// LabelThrottle is a StorageOS volume label which when enabled deprioritises
// the volume's traffic by reducing disk I/O rate.
LabelThrottle = "storageos.com/throttle"
// LabelHintMaster is a StorageOS volume label holding a list of nodes. When set,
// placement of the volume master on one of the nodes present in the list is
// preferred.
LabelHintMaster = "storageos.com/hint.master"
// LabelHintReplicas is a StorageOS volume label holding a list of nodes. When
// set, placement of volume replicas on nodes present in the list is
// preferred.
LabelHintReplicas = "storageos.com/hint.replicas"
)

// FsType indicates the kind of filesystem which a volume has been given.
Expand Down

0 comments on commit c08718e

Please sign in to comment.