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

Feature: creation of sub directory into glusterfs volume #35

Closed
kladiv opened this issue Jan 14, 2018 · 11 comments
Closed

Feature: creation of sub directory into glusterfs volume #35

kladiv opened this issue Jan 14, 2018 · 11 comments

Comments

@kladiv
Copy link

kladiv commented Jan 14, 2018

@sapk
Is it ppssible add a feature (e.g. additional parameter of volume create) to allow creation of sub-directory into GlusterFS volume so we can use 1 volume for multiple containers (lots of sub folders)?

It should be better then create lots of volumes (per-container) on dense environments.

Gluster cli already allow managing of directory quotas even if folders are not yet created.

@sapk
Copy link
Owner

sapk commented Jan 15, 2018

That shouldn't be too hard to do. It maybe possible to add the subdir inside voluri and keep backward compat.

@trajano
Copy link

trajano commented Mar 26, 2018

You need to have GlusterFS 3.12 at minimum for this to work. I think you may be using an older version of GlusterFS which is causing it to fail on my set up.

@sapk
Copy link
Owner

sapk commented Mar 26, 2018

@trajano this is not implemented yet. I was just talking about a way to implement it.

@trajano
Copy link

trajano commented Mar 26, 2018

I think if you just use Gluster 3.12 or assume Gluster 3.12 is installed (I don't think you make any assumption on what is installed though because I see the volume mounted even without the glusterfs client installed by yum) then you can simply pass in

store:/myvol/subvol

@sapk
Copy link
Owner

sapk commented Mar 26, 2018

In managed plugin, glusterfs should be 3.13 https://packages.debian.org/fr/testing/glusterfs-client.

But, I use the glusterfs command and not mount (https://github.com/sapk/docker-volume-gluster/blob/master/gluster/driver/driver.go#L44).
This allow for multiple server as base and I don't know if it support that "new" format.
In the docs (https://docs.gluster.org/en/latest/release-notes/3.12.0/), they only with mount command.

@trajano
Copy link

trajano commented Mar 26, 2018

The parseVolUri needs to add --subdir-mount=SUBDIR-PATH

@trajano
Copy link

trajano commented Mar 26, 2018

I tried to make it but I don't know Go well enough here's my cut

const (
	validHostnameRegex = `(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])`
	validMountRegex = `\/?([^\/]+)(/[^\/]+)?`
)

func isValidURI(volURI string) bool {
	re := regexp.MustCompile(validHostnameRegex + ":" + validMountRegex)
	return re.MatchString(volURI)
}

func parseVolURI(volURI string) string {
	volParts := strings.Split(volURI, ":")
	volServers := strings.Split(volParts[0], ",")

	re := regexp.MustCompile(validMountRegex)
	??? := re.MatchString(volParts[1])
	volumeIdPart := ???.group(1)
	subDirectoryPart := ???.group(2)
	
	if (subDirectoryPart == nil) {
		return fmt.Sprintf("--volfile-id='%s' -s '%s'", volumeIdPart, strings.Join(volServers, "' -s '"))
	} else {
		return fmt.Sprintf("--volfile-id='%s' --subdir-mount='%s' -s '%s'", volumeIdPart, subDirectoryPart, strings.Join(volServers, "' -s '"))

	}
}


@sapk
Copy link
Owner

sapk commented Mar 26, 2018

I will have a look at it tommorrow.
If you want to contribute you can submit a PR with tests that should validate the change. https://github.com/sapk/docker-volume-gluster/blob/master/gluster/driver/tools_test.go
This would be a easy start at go. It is mostly adding new case to check to the two first functions.

@trajano trajano mentioned this issue Mar 27, 2018
@sapk sapk closed this as completed in #40 Mar 27, 2018
@kladiv
Copy link
Author

kladiv commented Mar 27, 2018

Great job guys :)

@sapk
Copy link
Owner

sapk commented Mar 27, 2018

Doing more tests but should release soon.

@moetemad
Copy link

moetemad commented Feb 11, 2019

@sapk Has this feature made it into any of the releases yet? I am still having issues with gluster 5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants