mirror of
https://github.com/ceph/ceph
synced 2025-03-30 07:19:14 +00:00
Merge pull request #44905 from mgfritch/cephadm-prom-chown
cephadm: chown the prometheus data dir during redeploy Reviewed-by: Adam King <adking@redhat.com> Reviewed-by: Patrick Seidensal <pseidensal@suse.com>
This commit is contained in:
commit
a3ed8ddb4f
@ -2098,6 +2098,13 @@ def move_files(ctx, src, dst, uid=None, gid=None):
|
||||
os.chown(dst_file, uid, gid)
|
||||
|
||||
|
||||
def recursive_chown(path: str, uid: int, gid: int) -> None:
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
os.chown(dirpath, uid, gid)
|
||||
for filename in filenames:
|
||||
os.chown(os.path.join(dirpath, filename), uid, gid)
|
||||
|
||||
|
||||
# copied from distutils
|
||||
def find_executable(executable: str, path: Optional[str] = None) -> Optional[str]:
|
||||
"""Tries to find 'executable' in the directories listed in 'path'.
|
||||
@ -2403,6 +2410,8 @@ def create_daemon_dirs(ctx, fsid, daemon_type, daemon_id, uid, gid,
|
||||
makedirs(os.path.join(data_dir_root, config_dir), uid, gid, 0o755)
|
||||
makedirs(os.path.join(data_dir_root, config_dir, 'alerting'), uid, gid, 0o755)
|
||||
makedirs(os.path.join(data_dir_root, 'data'), uid, gid, 0o755)
|
||||
recursive_chown(os.path.join(data_dir_root, 'etc'), uid, gid)
|
||||
recursive_chown(os.path.join(data_dir_root, 'data'), uid, gid)
|
||||
elif daemon_type == 'grafana':
|
||||
data_dir_root = get_data_dir(fsid, ctx.data_dir,
|
||||
daemon_type, daemon_id)
|
||||
|
@ -812,6 +812,22 @@ class TestMonitoring(object):
|
||||
with open(file) as f:
|
||||
assert f.read() == content
|
||||
|
||||
# assert uid/gid after redeploy
|
||||
new_uid = uid+1
|
||||
new_gid = gid+1
|
||||
cd.create_daemon_dirs(ctx,
|
||||
fsid,
|
||||
daemon_type,
|
||||
daemon_id,
|
||||
new_uid,
|
||||
new_gid,
|
||||
config=None,
|
||||
keyring=None)
|
||||
for file,content in expected.items():
|
||||
file = os.path.join(prefix, file)
|
||||
assert os.stat(file).st_uid == new_uid
|
||||
assert os.stat(file).st_gid == new_gid
|
||||
|
||||
|
||||
class TestBootstrap(object):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user