From 5021ca53f136fd7b8672e4919d46d018b41889c8 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Mon, 14 Jan 2019 18:23:33 +0100 Subject: [PATCH] Set sensible directory defaults Instead of storing locks and volume private binds into the current directory we will now store them under: - /var/lib/ember-csi/locks - /var/lib/ember-csi/vols We also set the state_path to /var/lib/ember-csi to ensure a sensible default. --- Dockerfile | 5 +++-- Dockerfile-master | 1 + Dockerfile-release | 1 + Makefile | 2 +- README.md | 28 ++++++++++++++-------------- ember_csi/base.py | 2 +- ember_csi/defaults.py | 6 +++++- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index c271e79d..6e2f41ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,10 @@ LABEL maintainers="Gorka Eguileor " \ # We need to upgrade pyasn1 because the package for RDO is not new enough for # pyasn1_modules, which is used by some of the Google's libraries RUN yum -y install xfsprogs e2fsprogs btrfs-progs nmap-ncat python2-future && \ + mkdir -p /var/lib/ember-csi/{vols,locks} && \ + pip install --no-cache-dir --upgrade 'pyasn1<0.5.0,>=0.4.1' future && \ yum clean all && \ - rm -rf /var/cache/yum && \ - pip install --no-cache-dir --upgrade 'pyasn1<0.5.0,>=0.4.1' future + rm -rf /var/cache/yum # Copy Ember-csi from directory directory COPY . /csi diff --git a/Dockerfile-master b/Dockerfile-master index d162298f..faf274f6 100644 --- a/Dockerfile-master +++ b/Dockerfile-master @@ -18,6 +18,7 @@ RUN yum -y install targetcli iscsi-initiator-utils device-mapper-multipath epel- # Apply cinderlib patch cd cinder && git fetch https://git.openstack.org/openstack/cinder refs/changes/69/620669/10 && git checkout FETCH_HEAD && cd .. && \ pip install --no-cache-dir cinder/ && \ + mkdir -p /var/lib/ember-csi/{vols,locks} && \ rm -rf cinder && \ yum -y remove git python-devel gcc && \ yum clean all && \ diff --git a/Dockerfile-release b/Dockerfile-release index a9dbc17a..74a2e905 100644 --- a/Dockerfile-release +++ b/Dockerfile-release @@ -8,6 +8,7 @@ LABEL maintainers="Gorka Eguileor " \ # We need to upgrade pyasn1 because the package for RDO is not new enough for # pyasn1_modules, which is used by some of the Google's libraries RUN yum -y install xfsprogs e2fsprogs btrfs-progs python2-future && \ + mkdir -p /var/lib/ember-csi/{vols,locks} && \ yum clean all && \ rm -rf /var/cache/yum && \ pip install --no-cache-dir --upgrade --process-dependency-links 'pyasn1<0.5.0,>=0.4.1' future ember-csi diff --git a/Makefile b/Makefile index 1e735d9e..1982bb0d 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ test-all: ## run tests on every Python version with tox centos-bm-lvm: X_CSI_PERSISTENCE_CONFIG='{"storage":"memory"}' \ X_CSI_BACKEND_CONFIG='{"target_protocol":"iscsi","iscsi_ip_address":"127.0.0.1","volume_backend_name":"lvm","volume_driver":"cinder.volume.drivers.lvm.LVMVolumeDriver","volume_group":"ember-volumes","target_helper":"lioadm"}' \ - X_CSI_EMBER_CONFIG='{"project_id":"io.ember-csi","user_id":"io.ember-csi","root_helper":"sudo","disable_logs":false,"debug":true,"request_multipath":false}' \ + X_CSI_EMBER_CONFIG='{"project_id":"io.ember-csi","user_id":"io.ember-csi","root_helper":"sudo","disable_logs":false,"debug":true,"request_multipath":false,"file_locks_path":"/tmp"}' \ travis-scripts/run-bm-sanity.sh centos-lvm: diff --git a/README.md b/README.md index 3b2e8e34..b2975663 100644 --- a/README.md +++ b/README.md @@ -104,20 +104,20 @@ For RBD we'll also need a specific package: The CSI driver is configured via environmental variables, any value that doesn't have a default is a required value. -| Name | Role | Description | Default | Example | -| -------------------------- | ---------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CSI_ENDPOINT` | all | IP and port to bind the service | [::]:50051 | 192.168.1.22:50050 | -| `CSI_MODE` | all | Role the service should perform: controller, node, all | all | controller | -| `X_CSI_SPEC_VERSION` | all | CSI Spec version to run. Supported v0.2 and v1.0 | v0.2.0 | 0.2.0 -| `X_CSI_STORAGE_NW_IP` | node | IP address in the Node used to connect to the storage | IP resolved from Node's fqdn | 192.168.1.22 | -| `X_CSI_NODE_ID` | node | ID used by this node to identify itself to the controller | Node's fqdn | csi_test_node | -| `X_CSI_PERSISTENCE_CONFIG` | all | Configuration of the `cinderlib` metadata persistence plugin. | {"storage": "crd", "namespace": "default"} | {"storage": "db", "connection": "mysql+pymysql://root:stackdb@192.168.1.1/cinder?charset=utf8"} | -| `X_CSI_EMBER_CONFIG` | all | Global `cinderlib` configuration | {'project_id': 'io.ember-csi', 'user_id': 'io.ember-csi', 'root_helper': 'sudo', 'request_multipath': true, 'plugin_name': 'io.ember-csi'} | {"project_id":"k8s project","user_id":"csi driver","root_helper":"sudo",'plugin_name': 'io.ember-csi.external-ceph'} | -| `X_CSI_BACKEND_CONFIG` | controller | Driver configuration | | {"volume_backend_name": "rbd", "volume_driver": "cinder.volume.drivers.rbd.RBDDriver", "rbd_user": "cinder", "rbd_pool": "volumes", "rbd_ceph_conf": "/etc/ceph/ceph.conf", "rbd_keyring_conf": "/etc/ceph/ceph.client.cinder.keyring"} | -| `X_CSI_DEFAULT_MOUNT_FS` | node | Default mount filesystem when missing in publish calls | ext4 | btrfs | -| `X_CSI_SYSTEM_FILES` | all | All required storage driver-specific files archived in tar, tar.gz or tar.bz2 format| | /path/to/etc-ceph.tar.gz | -| `X_CSI_DEBUG_MODE` | all | Debug mode (rpdb, pdb) to use. Disabled by default. | | rpdb | -| `X_CSI_ABORT_DUPLICATES` | all | If we want to abort or queue (default) duplicated requests. | false | true | +| Name | Role | Description | Default | Example | +| -------------------------- | ---------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `CSI_ENDPOINT` | all | IP and port to bind the service | [::]:50051 | 192.168.1.22:50050 | +| `CSI_MODE` | all | Role the service should perform: controller, node, all | all | controller | +| `X_CSI_SPEC_VERSION` | all | CSI Spec version to run. Supported v0.2 and v1.0 | v0.2.0 | 0.2.0 +| `X_CSI_STORAGE_NW_IP` | node | IP address in the Node used to connect to the storage | IP resolved from Node's fqdn | 192.168.1.22 | +| `X_CSI_NODE_ID` | node | ID used by this node to identify itself to the controller | Node's fqdn | csi_test_node | +| `X_CSI_PERSISTENCE_CONFIG` | all | Configuration of the `cinderlib` metadata persistence plugin. | {"storage": "crd", "namespace": "default"} | {"storage": "db", "connection": "mysql+pymysql://root:stackdb@192.168.1.1/cinder?charset=utf8"} | +| `X_CSI_EMBER_CONFIG` | all | Global `cinderlib` configuration | {'project_id': 'io.ember-csi', 'user_id': 'io.ember-csi', 'root_helper': 'sudo', 'request_multipath': true, 'plugin_name': 'io.ember-csi', 'file_locks_path': '/var/lib/ember-csi/locks'} | {"project_id":"k8s project","user_id":"csi driver","root_helper":"sudo",'plugin_name': 'io.ember-csi.external-ceph'} | +| `X_CSI_BACKEND_CONFIG` | controller | Driver configuration | | {"volume_backend_name": "rbd", "volume_driver": "cinder.volume.drivers.rbd.RBDDriver", "rbd_user": "cinder", "rbd_pool": "volumes", "rbd_ceph_conf": "/etc/ceph/ceph.conf", "rbd_keyring_conf": "/etc/ceph/ceph.client.cinder.keyring"} | +| `X_CSI_DEFAULT_MOUNT_FS` | node | Default mount filesystem when missing in publish calls | ext4 | btrfs | +| `X_CSI_SYSTEM_FILES` | all | All required storage driver-specific files archived in tar, tar.gz or tar.bz2 format| | /path/to/etc-ceph.tar.gz | +| `X_CSI_DEBUG_MODE` | all | Debug mode (rpdb, pdb) to use. Disabled by default. | | rpdb | +| `X_CSI_ABORT_DUPLICATES` | all | If we want to abort or queue (default) duplicated requests. | false | true | The only role that has been tested at the moment is the default one, where Controller and Node servicer are executed in the same service (`CSI_MODE=all`), and other modes are expected to have issues at the moment. diff --git a/ember_csi/base.py b/ember_csi/base.py index 6cc060c3..21c2f2c7 100644 --- a/ember_csi/base.py +++ b/ember_csi/base.py @@ -513,7 +513,7 @@ def _get_mountinfo(self): return self._get_split_file('/proc/self/mountinfo') def _vol_private_location(self, volume_id): - private_bind = os.path.join(os.getcwd(), volume_id) + private_bind = os.path.join(defaults.VOL_BINDS_DIR, volume_id) return private_bind def _get_mount(self, private_bind): diff --git a/ember_csi/defaults.py b/ember_csi/defaults.py index 2d1ff0b3..75c19d45 100644 --- a/ember_csi/defaults.py +++ b/ember_csi/defaults.py @@ -18,8 +18,12 @@ MODE = 'all' PERSISTENCE_CFG = {'storage': 'crd', 'namespace': 'default'} ROOT_HELPER = 'sudo' +STATE_PATH = '/var/lib/ember-csi' +VOL_BINDS_DIR = STATE_PATH + '/vols' +LOCKS_DIR = STATE_PATH + '/locks' EMBER_CFG = {'project_id': NAME, 'user_id': NAME, 'plugin_name': NAME, - 'root_helper': ROOT_HELPER, 'request_multipath': True} + 'root_helper': ROOT_HELPER, 'request_multipath': True, + 'file_locks_path': LOCKS_DIR, 'state_path': STATE_PATH} LOG_LEVELS = ('amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,' 'suds=WARN,oslo.messaging=WARN,oslo_messaging=WARN,iso8601=WARN,'