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

bugfix: change volume metadata struct #1271

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

ControlServerAddress or ControlMasterAddress or MasterAddress?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it means control server address in csi. I change it to ControlServerAddress

Timeout time.Duration // operation timeout.
RemoveVolume bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if we could add some annotations for this field RemoveVolume ?

I wish that when code readers reader the struct itself, he could catch the exact meaning of it clearly, rather than trying hard to guess its meaning.

If we make it, I think the lifetime of the code would be much longer to be alive.

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