Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

gd2 plugin: added a plugin for block volume management #1357

Merged
merged 7 commits into from
Jan 7, 2019

Conversation

oshankkumar
Copy link

  • added APIs for creation,deleting and listing block volumes.
  • added pluggable interface for block volume providers.

Refer Design Doc: #1319

Signed-off-by: Oshank Kumar [email protected]

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@ghost ghost assigned oshankkumar Nov 30, 2018
@ghost ghost added the in progress label Nov 30, 2018
@Madhu-1
Copy link
Member

Madhu-1 commented Nov 30, 2018

add to whitelist

@Madhu-1
Copy link
Member

Madhu-1 commented Dec 5, 2018

retest this please

@ghost ghost assigned Madhu-1 Dec 5, 2018
@Madhu-1
Copy link
Member

Madhu-1 commented Dec 5, 2018

CI failure

20:58:20 Building glusterd2 v6.0-dev.54.gita525bc5
20:58:21 plugins/blockvolume/blockprovider/gluster-block/glusterblock.go:10:2: cannot find package "github.com/gluster/gluster-block-restapi/client" in any of:
20:58:21 	/root/go/src/github.com/gluster/glusterd2/vendor/github.com/gluster/gluster-block-restapi/client (vendor tree)
20:58:21 	/usr/local/go/src/github.com/gluster/gluster-block-restapi/client (from $GOROOT)
20:58:21 	/root/go/src/github.com/gluster/gluster-block-restapi/client (from $GOPATH)
20:58:21 plugins/blockvolume/blockprovider/gluster-block/glusterblock.go:11:2: cannot find package "github.com/gluster/gluster-block-restapi/pkg/api" in any of:
20:58:21 	/root/go/src/github.com/gluster/glusterd2/vendor/github.com/gluster/gluster-block-restapi/pkg/api (vendor tree)
20:58:21 	/usr/local/go/src/github.com/gluster/gluster-block-restapi/pkg/api (from $GOROOT)
20:58:21 	/root/go/src/github.com/gluster/gluster-block-restapi/pkg/api (from $GOPATH)

@nigelbabu
Copy link

retest this please

@@ -0,0 +1,166 @@
package size
Copy link
Member

Choose a reason for hiding this comment

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

looks like 'package size' can get into code just like that. It can be used by other services too.

Hosts: hosts,
}

resp, err := g.client.CreateBlockVolume(volInfo.Name, name, req)
Copy link
Member

Choose a reason for hiding this comment

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

We need to make sure we have the BlockHostingVolume is up and running. Because, if it is not present, then this will fail for sure. If it is already taken care by the events above, then all good.

Copy link
Member

Choose a reason for hiding this comment

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

Line 149 is checking that Hosting Volume is in Started State

@aravindavk
Copy link
Member

I don't see Gopkg.toml changes which mentions the new dependency

@oshankkumar
Copy link
Author

I don't see Gopkg.toml changes which mentions the new dependency

I am getting error like this while updating the dependencies using dep ensure

Solving failure: No versions of github.com/gluster/gluster-block-restapi met constraints:
	v0.2: Could not introduce github.com/gluster/[email protected], as it has a dependency on github.com/sirupsen/logrus with constraint ^1.2.0, which has no overlap with existing constraint ~1.0.3 from (root)

@aravindavk @Madhu-1 can you please suggest how to resolve this

@Madhu-1
Copy link
Member

Madhu-1 commented Dec 12, 2018

@oshankkumar update github.com/sirupsen/logrus version to "~1.2.0" in toml file to fix this issue

Copy link
Member

@aravindavk aravindavk left a comment

Choose a reason for hiding this comment

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

Did a initial review. Mostly looks good, a few comments. I will test the PR once.


for _, blockVol := range availableBlockVolumes {
if blockVol.Name() == name {
blockVolume = blockVol
Copy link
Member

Choose a reason for hiding this comment

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

break?

Copy link
Author

Choose a reason for hiding this comment

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

added

}

// StartBlockHostingVolume starts a gluster volume
func StartBlockHostingVolume(name string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Is this different from regular Volume start. If not can we reuse the code

Copy link
Author

Choose a reason for hiding this comment

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

done

return nil, err
}

vInfo.Metadata["_block-hosting-volume-auto-created"] = "yes"
Copy link
Member

Choose a reason for hiding this comment

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

Using _ prefix will make it impossible to manually create block hosting volume and use that for block file creation.(Since Metadata keys starts with _ are restricted for API users). We can skip using prefix or we can expose BlockHosting=Yes/No flag in Volume Edit API


// Include default Volume Options profile
Copy link
Member

Choose a reason for hiding this comment

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

this new change is lost in Rebase?

return
}

if containsReservedGroupProfile(req.Options) {
Copy link
Member

Choose a reason for hiding this comment

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

this check also lost

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

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

i would like to do one more round of review

// BlockVolumeInfo represents block volume info
type BlockVolumeInfo struct {
// HostingVolume name is optional
HostingVolume string `json:"hosting_volume"`
Copy link
Member

Choose a reason for hiding this comment

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

don't use underscore in json name

Copy link
Member

Choose a reason for hiding this comment

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

can this be omitempty?

Copy link
Member

Choose a reason for hiding this comment

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

am i missing anything, dont we need to consider size for blockhosting volume.


// BlockVolumeCreateResp represents resp body for a Block Vol Create req
type BlockVolumeCreateResp struct {
*BlockVolumeInfo
Copy link
Member

Choose a reason for hiding this comment

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

as you are using BlockVolumeInfo size cannot be omitempty for this volume response

Copy link
Author

Choose a reason for hiding this comment

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

Since we are getting only list of blockvolume name from gluster-block list command.
So for a blockvolume list response, we are only showing blockvolume name and hosting volume name, so if I remove omitempty then size will be displayed as 0 in response.

Copy link
Author

Choose a reason for hiding this comment

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

for a BlockVolumeList response size is not a mandatory field

type BlockVolumeGetResp struct {
*BlockVolumeInfo
Hosts []string `json:"hosts"`
Password string `json:"password,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

dont we need username here?

Copy link
Author

Choose a reason for hiding this comment

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

we don't get username details from gluster-block info command


// RegisterBlockProvider will register a block provider
func RegisterBlockProvider(name string, f ProviderFunc) {
providersMutex.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

can you explain whats the advantage of taking lock here and in below functions.

Copy link
Author

Choose a reason for hiding this comment

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

just to make sure providerFactory map is not accessed parallelly by some other goroutine

@oshankkumar oshankkumar force-pushed the gluster-block branch 4 times, most recently from 9b02076 to cc4c519 Compare December 17, 2018 10:38
@poornimag
Copy link

As discussed, could you please move the block host volume management to block provider instead of gluster-block, so that the block host volume management code can be reused by all providers?

@oshankkumar
Copy link
Author

As discussed, could you please move the block host volume management to block provider instead of gluster-block, so that the block host volume management code can be reused by all providers?

moved the common code to a utils package

@aravindavk
Copy link
Member

aravindavk commented Dec 18, 2018

Block provider details can be handled in URL to support different providers. POST /v1/subvolumes/{provider}. (Note: Name "subvolumes" here may add confusion wrt subvol in gluster. Any suggestions for the name?)

Create

POST /subvolumes/gluster-block         To provide block volumes using gluster-block
POST /subvolumes/loop-block             To provide block volumes using loop devices
POST /subvolumes/dir                         To provide volumes using subdir approach

Similarly for other URLS

Same ReST handler receives all the requests and host volume management part will remain same. Instead of calling g.client.CreateBlockVolume(volInfo.Name, name, req) in Line 164(https://github.com/gluster/glusterd2/pull/1357/files#diff-3a743ffc1638946e95edba8bc6e26c50R164) it will call provider.CreateBlockVolume(args...)

In handler,

providerName := mux.Vars(r)["provider"]
provider := getProvider(providerName)  // This gets the interface implementation of respective provider

@oshankkumar @poornimag @Madhu-1 @amarts thoughts?

@atinmu
Copy link
Contributor

atinmu commented Dec 24, 2018

@aravindavk @Madhu-1 can you folks take a look at the latest version? I believe all comments are being incorporated now?

@oshankkumar
Copy link
Author

oshankkumar commented Dec 24, 2018

@aravindavk @Madhu-1 can you folks take a look at the latest version? I believe all comments are being incorporated now?

yes, all review comments has been addressed.

@amarts
Copy link
Member

amarts commented Dec 28, 2018

what more is pending on this ?

@oshankkumar oshankkumar force-pushed the gluster-block branch 2 times, most recently from c08a0ee to bd64a95 Compare December 31, 2018 11:07
#[gluster-block-hosting-vol-options]
block-hosting-volume-size = 20971520
auto-create-block-hosting-volumes = true
block-hosting-volume-replica-count = 1
Copy link
Member

Choose a reason for hiding this comment

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

Change this to 3

block-hosting-volume-size = 20971520
auto-create-block-hosting-volumes = true
block-hosting-volume-replica-count = 1
#block-hosting-volume-type = "Distribute"
Copy link
Member

Choose a reason for hiding this comment

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

Change this to Replicate

@Madhu-1
Copy link
Member

Madhu-1 commented Jan 3, 2019

@oshankkumar please resolve merge conflicts

@@ -3,3 +3,15 @@ peeraddress = ":24008"
clientaddress = ":24007"
#restauth enables/disables REST authentication in glusterd2
#restauth = true

#[gluster-block-hosting-vol-options]
block-hosting-volume-size = 20971520
Copy link
Member

Choose a reason for hiding this comment

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

add a comment what is this size in Gib for more readability

gluster-block-hostaddr = "192.168.122.16:8081"
#gluster-block-cacert = "/path/to/ca.crt"
#gluster-block-user = "username_for_rest_authentication"
#gluster-block-secret = "secret_for_rest_authentication"
Copy link
Member

Choose a reason for hiding this comment

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

add a new line

@@ -0,0 +1,187 @@
package size
Copy link
Member

Choose a reason for hiding this comment

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

but glusterd2 doeent make a call to the gluster block cli, even the input request and the response recevied from the block rest server is interger, but am not sure how useful it is? it will be only useful if we use gluster block cli with gd2 directly

@Madhu-1
Copy link
Member

Madhu-1 commented Jan 3, 2019

@oshankkumar regenerate endpoints.md file

}
defer clusterLocks.UnLock(context.Background())

volInfo, err := volume.GetVolume(hostVolume)
Copy link
Member

@Madhu-1 Madhu-1 Jan 3, 2019

Choose a reason for hiding this comment

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

can we move this logic to some other function, so this can be reused for checking block hosting volume by other providers?

Copy link
Author

@oshankkumar oshankkumar Jan 3, 2019

Choose a reason for hiding this comment

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

moved updating available hosting volume size to a common function,

@oshankkumar oshankkumar force-pushed the gluster-block branch 4 times, most recently from 7b02a7e to 56f9240 Compare January 3, 2019 12:35
block-hosting-volume-size = 5368709120 #5GiB
auto-create-block-hosting-volumes = true
block-hosting-volume-replica-count = 3
#block-hosting-volume-type = "Replicate"
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be commented?

@Madhu-1
Copy link
Member

Madhu-1 commented Jan 3, 2019

@aravindavk PTAL.

Oshank Kumar added 7 commits January 4, 2019 20:52
 - added APIs for creation,deleting and listing block volumes.
 - added pluggable interface for block volume providers.

Refer Design Doc: gluster#1319

Signed-off-by: Oshank Kumar <[email protected]>
 - added block volume provider name in path parameter of url
 - block provider will not be responsible for managing host volumes.

Signed-off-by: Oshank Kumar <[email protected]>
…volume size

 - moved hosts parameter from mandatory to optional field in  CreateBlockVolume
   method of BlockProvider interface,since hosts field may not required for
   other block providers like loopback.

 - a common function for updating available hosting volume size will prevent
   from duplicate code

Signed-off-by: Oshank Kumar <[email protected]>
@aravindavk aravindavk merged commit 8ef2e18 into gluster:master Jan 7, 2019
@ghost ghost removed the in progress label Jan 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants