Commit cb7c0198 authored by Iustin Pop's avatar Iustin Pop

Implement disabling of file-based storage

Rationale: the file-based storage backend can add/remove files under a
certain directory. However, the master node is also controlling the
setting of the file-based root directory, so basically it means we can't
prevent arbitrary modifications by the master of the node's filesystem.

In order to mitigate this for setups where the file-based storage is not
used, we introduce a new setting at ./configure time, that controls the
enable/disable of file-based storage. Since this is not modifiable by
the master (over RPC), it is now possible in this case to prevent
unintended modifications of the node's filesystem from the master.

The new setting is used in bdev.py to not expose the file-based storage
at all, and in cmdlib.py to prevent attempts at creation of such
instances.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e02b9114
......@@ -452,6 +452,7 @@ lib/_autoconf.py: Makefile stamp-directories
echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
echo "XEN_INITRD = '$(XEN_INITRD)'"; \
echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
echo "KVM_PATH = '$(KVM_PATH)'"; \
echo "SOCAT_PATH = '$(SOCAT)'"; \
......
......@@ -104,9 +104,16 @@ AC_ARG_WITH([file-storage-dir],
[directory to store files for file-based backend]
[ (default is /srv/ganeti/file-storage)]
)],
[file_storage_dir="$withval"],
[file_storage_dir="/srv/ganeti/file-storage"])
[[file_storage_dir="$withval";
if test "$withval" != no; then
enable_file_storage=True
else
enable_file_storage=False
fi
]],
[[file_storage_dir="/srv/ganeti/file-storage"; enable_file_storage="True"]])
AC_SUBST(FILE_STORAGE_DIR, $file_storage_dir)
AC_SUBST(ENABLE_FILE_STORAGE, $enable_file_storage)
# --with-kvm-path=...
AC_ARG_WITH([kvm-path],
......
......@@ -2255,6 +2255,8 @@ def _TransformFileStorageDir(file_storage_dir):
@return: the normalized path if valid, None otherwise
"""
if not constants.ENABLE_FILE_STORAGE:
_Fail("File storage disabled at configure time")
cfg = _GetConfig()
file_storage_dir = os.path.normpath(file_storage_dir)
base_file_storage_dir = cfg.GetFileStorageDir()
......
......@@ -1907,9 +1907,11 @@ class FileStorage(BlockDev):
DEV_MAP = {
constants.LD_LV: LogicalVolume,
constants.LD_DRBD8: DRBD8,
constants.LD_FILE: FileStorage,
}
if constants.ENABLE_FILE_STORAGE:
DEV_MAP[constants.LD_FILE] = FileStorage
def FindDevice(dev_type, unique_id, children, size):
"""Search for an existing, assembled device.
......
......@@ -5658,6 +5658,10 @@ class LUCreateInstance(LogicalUnit):
# TODO: make the ip check more flexible and not depend on the name check
raise errors.OpPrereqError("Cannot do ip checks without a name check",
errors.ECODE_INVAL)
if (self.op.disk_template == constants.DT_FILE and
not constants.ENABLE_FILE_STORAGE):
raise errors.OpPrereqError("File storage disabled at configure time",
errors.ECODE_INVAL)
def ExpandNames(self):
"""ExpandNames for CreateInstance.
......
......@@ -109,6 +109,7 @@ QUEUE_DIR = DATA_DIR + "/queue"
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
ETC_HOSTS = "/etc/hosts"
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
SYSCONFDIR = _autoconf.SYSCONFDIR
TOOLSDIR = _autoconf.TOOLSDIR
CONF_DIR = SYSCONFDIR + "/ganeti"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment