Skip to content

Commit

Permalink
bugfix: change volume metadata struct
Browse files Browse the repository at this point in the history
change volume metadata struct for remote storage manager.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
  • Loading branch information
rudyfly committed May 10, 2018
1 parent 5ce1e4d commit 4b8be27
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
12 changes: 6 additions & 6 deletions storage/volume/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

// Config represents volume config struct.
type Config struct {
ControlAddress string
Timeout time.Duration // operation timeout.
RemoveVolume bool
DefaultBackend string `json:"volume-default-driver"`
VolumeMetaPath string `json:"volume-meta-dir"`
DriverAlias string `json:"volume-driver-alias"`
ControlServerAddress string `json:"control-server-address"` // control server address in csi.
Timeout time.Duration `json:"volume-timeout"` // operation timeout.
RemoveVolume bool `json:"remove-volume"` // remove volume add data or volume's metadata when remove pouch volume.
DefaultBackend string `json:"volume-default-driver"` // default volume backend.
VolumeMetaPath string `json:"volume-meta-dir"` // volume metadata store path.
DriverAlias string `json:"volume-driver-alias"` // driver alias configure.
}
4 changes: 2 additions & 2 deletions storage/volume/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ type Core struct {
// NewCore returns Core struct instance with volume config.
func NewCore(cfg Config) (*Core, error) {
c := &Core{Config: cfg}
if cfg.ControlAddress != "" {
if cfg.ControlServerAddress != "" {
c.EnableControl = true
c.BaseURL = cfg.ControlAddress
c.BaseURL = cfg.ControlServerAddress
} else {
c.EnableControl = false
}
Expand Down
6 changes: 3 additions & 3 deletions storage/volume/modules/ceph/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *Ceph) Options() map[string]types.Option {
func (c *Ceph) Format(ctx driver.Context, v *types.Volume, s *types.Storage) error {
ctx.Log.Debugf("Ceph format volume: %s", v.Name)

device, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Key)
device, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Keyring)
if err != nil {
ctx.Log.Errorf("Ceph map volume: %s failed: %v", v.Name, err)
return err
Expand Down Expand Up @@ -159,7 +159,7 @@ func (c *Ceph) Attach(ctx driver.Context, v *types.Volume, s *types.Storage) err
volumePath := v.Path()

// Map rbd device
devName, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Key)
devName, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Keyring)
if err != nil {
ctx.Log.Errorf("Ceph volume: %s map error: %v", v.Name, err)
return err
Expand Down Expand Up @@ -257,7 +257,7 @@ func (c *Ceph) Report(ctx driver.Context) ([]*types.Storage, error) {
}
keyring := fmt.Sprintf("%s:%s", "admin", key.Value())
encoded := base64.StdEncoding.EncodeToString([]byte(keyring))
s.Spec.Key = encoded
s.Spec.Keyring = encoded

// get ceph quorum status
cmd := NewCephCommand("ceph", conf)
Expand Down
14 changes: 7 additions & 7 deletions storage/volume/types/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (

// StorageSpec represents storage spec.
type StorageSpec struct {
Type string `json:"type"` // storage type
ID string `json:"id,omitempty"` // storage uid or unique name
Name string `json:"name,omitempty"` // storage cluster name
Key string `json:"key,omitempty"` // storage access key
API string `json:"api"` // gateway address
Address string `json:"address"` // for ceph it's monitor ip:port,ip:port, pangu2's river master
PoolSpec map[string]PoolSpec `json:"poolspec"` // storage pool spec
Type string `json:"type"` // storage type
ID string `json:"id,omitempty"` // storage uid or unique name
Address string `json:"address"` // storage address, such as ceph it's monitor ip:port,ip:port
PoolSpec map[string]PoolSpec `json:"poolspec"` // storage pool spec

ClusterName string `json:"clustername,omitempty"` // storage cluster name
Keyring string `json:"keyring,omitempty"` // storage access key, such as ceph's keyring user:secret
}

// PoolSpec represents storage pool spec.
Expand Down
1 change: 1 addition & 0 deletions storage/volume/types/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type VolumeSpec struct {
Selector Selector `json:"selector"`
Operable bool `json:"operable"`
Backend string `json:"backend,omitempty"`
MountMode string `json:"mountMode,omitempty"`
*VolumeConfig `json:"config,inline"`
Extra map[string]string `json:"extra"`
}
Expand Down

0 comments on commit 4b8be27

Please sign in to comment.