Giter Club home page Giter Club logo

xfsvol's Introduction

xfsvol ๐Ÿ“‚

Docker Volume Plugin for managing local XFS-based volumes

Build Status

Quickstart

  1. Create a mountpoint at /mnt/xfs and a directory /mnt/xfs/volumes.

For testing purposes this mountpoint can be a loopback device (note: use a loopback device for testing purposes only).

sudo dd if=/dev/zero of=/xfs.1G bs=1M count=1024
sudo losetup /dev/loop0 /xfs.1G
sudo mkfs -t xfs -n ftype=1 /dev/loop0
sudo mkdir -p /mnt/xfs/volumes
sudo mount /dev/loop0 /mnt/xfs -o pquota
  1. Install the plugin
docker plugin install \
        --grant-all-permissions \
        --alias xfsvol \
        cirocosta/xfsvol

docker plugin ls
ID                  NAME                DESCRIPTION                                   ENABLED
06545b643c6a        xfsvol:latest       Docker plugin to manage XFS-mounted volumes   true
  1. Create a named volume
docker volume create \
        --driver xfsvol \
        --opt size=10M \
        myvolume1
  1. Run a container with the volume attached
docker run -it \
        -v myvolume1:/myvolume1 \
        alpine /bin/sh

dd if=/dev/zero of=/myvolume1/file bs=1M count=100
(fail!)
  1. Check the volumes list
docker volume ls
DRIVER              VOLUME NAME
xfsvol:latest       myvolume1 (1.004MB)
local               dockerdev-go-pkg-cache-gopath
local               dockerdev-go-pkg-cache-goroot-linux_amd64
local               dockerdev-go-pkg-cache-goroot-linux_amd64_netgo

and the xfsvolctl utility:

sudo /usr/bin/xfsvolctl ls --root /mnt/xfs/volumes/
NAME   QUOTA
ciro   1.004 MB

xfsvolctl

This tool is made to help inspect the project quotas created under a given root path as well as create/delete others. It's usage is documented under --help:

xfsvolctl --help
NAME:
   xfsvolctl - Controls the 'xfsvol' volume plugin

USAGE:
   xfsvolctl [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
     ls       Lists the volumes managed by 'xfsvol' plugin
     create   Creates a volume with XFS project quota enforcement
     delete   Deletes a volume managed by 'xfsvol' plugin
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Under the hood

$ sudo mkdir -p /mnt/xfs/tmp/bbb
$ sudo strace -f xfsvolctl create \
        --root /mnt/xfs/tmp/bbb \
        --name ccc \
        --size 1024 \
        --inode 1024

stat("/mnt/xfs/tmp/bbb", {st_mode=S_IFDIR|0755, st_size=6, ...}) = 0
unlinkat(AT_FDCWD, "/mnt/xfs/tmp/bbb/backingFsBlockDev", 0) = -1 ENOENT (No such file or directory)
mknodat(AT_FDCWD, "/mnt/xfs/tmp/bbb/backingFsBlockDev", S_IFBLK|0600, makedev(7, 0)) = 0
quotactl(Q_XSETQLIM|PRJQUOTA, "/mnt/xfs/tmp/bbb/backingFsBlockDev", 1, {version=1, flags=XFS_PROJ_QUOTA, fieldmask=0xc, id=1, blk_hardlimit=0, blk_softlimit=0, ino_hardlimit=0, ino_softlimit=0, bcount=0, icount=0, ...}) = 0
...
mkdirat(AT_FDCWD, "/mnt/xfs/tmp/bbb/ccc", 0755) = 0
open("/mnt/xfs/tmp/bbb/ccc", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=6, ...}) = 0
ioctl(3, FS_IOC_FSGETXATTR, 0xc4201a95e4) = 0
ioctl(3, FS_IOC_FSSETXATTR, 0xc4201a95e4) = 0

quotactl(Q_XSETQLIM|PRJQUOTA, "/mnt/xfs/tmp/bbb/backingFsBlockDev", 2, {version=1, flags=XFS_PROJ_QUOTA, fieldmask=0xc, id=2, blk_hardlimit=2, blk_softlimit=2, ino_hardlimit=1024, ino_softlimit=1024, bcount=0, icount=0, ...}) = 0
[pid  6833] ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0


// retrieving (ls)

[pid  8609] quotactl(Q_XGETQUOTA|PRJQUOTA, "/mnt/xfs/tmp/ddd/backingFsBlockDev", 2, {version=1, flags=XFS_PROJ_QUOTA, fieldmask=0, id=2, blk_hardlimit=8, blk_softlimit=8, ino_hardlimit=0, ino_softlimit=0, bcount=8, icount=104, ...}) = 0


xfsvol's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xfsvol's Issues

Add quota-enabled check

Hey,

we can use a strategy similar to mesos (see http://mail-archives.apache.org/mod_mbox/mesos-commits/201703.mbox/%[email protected]%3E)

Try<bool> isQuotaEnabled(const string& path)
{
  Try<string> devname = getDeviceForPath(path);
  if (devname.isError()) {
    return Error(devname.error());
  }

  struct fs_quota_statv statv = {FS_QSTATV_VERSION1};

  // The quota `type` argument to QCMD() doesn't apply to QCMD_XGETQSTATV
  // since it is for quota subsystem information that can include all
  // types of quotas. Equally, the quotactl() `id` argument doesn't apply
  // because we are getting global information rather than information for
  // a specific identity (eg. a projectId).
  if (::quotactl(QCMD(Q_XGETQSTATV, 0),
                 devname.get().c_str(),
                 0, // id
                 reinterpret_cast<caddr_t>(&statv)) == -1) {
    // ENOSYS means that quotas are not enabled at all.
    if (errno == ENOSYS) {
      return false;
    }

    return ErrnoError();
  }

  return statv.qs_flags & (FS_QUOTA_PDQ_ACCT | FS_QUOTA_PDQ_ENFD);
}

Error installing/enabling plugin

I failed to install plugin for docker 18.06

docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 1
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.0-7-amd64
Operating System: Debian GNU/Linux 9 (stretch)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 996.4MiB
Name: debian
ID: YZHL:COUU:IYXR:S3GC:Q6EX:FBSW:FWO4:JQVQ:4OJN:QRWU:WULN:FV4B
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Installation log

docker plugin install \
>         --grant-all-permissions \
>         --alias xfsvol \
>         cirocosta/xfsvol
latest: Pulling from cirocosta/xfsvol
1cf1bef5bc37: Download complete 
Digest: sha256:a09004ca95496005b8ba85ca39f18588b9a8ae14eaa0859aee48e56f130741d5
Status: Downloaded newer image for cirocosta/xfsvol:latest
Error response from daemon: dial unix /run/docker/plugins/3b567aacc1a2153fc8ba734a0a938d5eab7f47660c941db89d0389251326e4b1/xfsvol.sock: connect: no such file or directory

Make use of `clang-tidy`

Hey,

We could introduce clang-tidy to perform some static analysis on the C code that's shipped in this repository.

thx

Volume create command hangs

Docker version: 18.06.1-ce
Plugin version: latest or 41c1dd1eb9c0332a96da67a41899db6d04856d62392baa4acdc62f1174ad2013

Error from AWS ECS while creating

Post http://%2Frun%2Fdocker%2Fplugins%2F41c1dd1eb9c0332a96da67a41899db6d04856d62392baa4acdc62f1174ad2013%2Fxfsvol.sock/VolumeDriver.Create: context deadline exceeded

When i try to create manually docker command just hangs.

Couldn't set quota for volume name=myvolume1 size=10000000 inode=0

Hi,
i have a debian 9.5, i have followed your quickstart but in docker volume create i get

docker volume create \

    --driver xfsvol \
    --opt size=10M \
    myvolume1

Error response from daemon: create myvolume1: VolumeDriver.Create: manager failed to create volume myvolume1: Couldn't set quota for volume name=myvolume1 size=10000000 inode=0: couldn't set project id to path /mnt/xfs/volumes/myvolume1: failed to set project-id 1 to directory /mnt/xfs/volumes/myvolume1: operation not supported

Make Control stateless

Hey,

Right now, Control keeps a quotas map that maps path --> project-id.

Although such map acts more like a cache, Control could be simplified by not having it.

Document plugin environment variables

Hey,

Right now we are able to configure some details of the plugin via environment variables, but these are not documented in the README.

It'd be a good idea to have them described there.

thx!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.