Skip to content

Commit 11aaee1

Browse files
committed
mgr/cephadm: introducing nobody/nogroup constants
Signed-off-by: Redouane Kachach <[email protected]>
1 parent a093ba7 commit 11aaee1

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

src/cephadm/cephadmlib/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@
5050
DATEFMT = '%Y-%m-%dT%H:%M:%S.%fZ'
5151
QUIET_LOG_LEVEL = 9 # DEBUG is 10, so using 9 to be lower level than DEBUG
5252
NO_DEPRECATED = False
53+
UID_NOBODY = 65534
54+
GID_NOGROUP = 65534

src/cephadm/cephadmlib/daemons/custom.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ..deployment_utils import to_deployment_container
1616
from ..file_utils import write_new, makedirs
1717
from ..net_utils import EndPoint
18+
from ..constants import UID_NOBODY, GID_NOGROUP
1819

1920

2021
logger = logging.getLogger()
@@ -43,8 +44,8 @@ def __init__(
4344

4445
# config-json options
4546
self.entrypoint = dict_get(config_json, 'entrypoint')
46-
self.uid = dict_get(config_json, 'uid', 65534) # nobody
47-
self.gid = dict_get(config_json, 'gid', 65534) # nobody
47+
self.uid = dict_get(config_json, 'uid', UID_NOBODY)
48+
self.gid = dict_get(config_json, 'gid', GID_NOGROUP)
4849
self.volume_mounts = dict_get(config_json, 'volume_mounts', {})
4950
self.args = dict_get(config_json, 'args', [])
5051
self.envs = dict_get(config_json, 'envs', [])

src/cephadm/cephadmlib/daemons/mgmt_gateway.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ..daemon_form import register as register_daemon_form
1212
from ..daemon_identity import DaemonIdentity
1313
from ..deployment_utils import to_deployment_container
14-
from ..constants import DEFAULT_NGINX_IMAGE
14+
from ..constants import DEFAULT_NGINX_IMAGE, UID_NOBODY, GID_NOGROUP
1515
from ..data_utils import dict_get, is_fsid
1616
from ..file_utils import populate_files, makedirs, recursive_chown
1717
from ..exceptions import Error
@@ -90,7 +90,7 @@ def container(self, ctx: CephadmContext) -> CephContainer:
9090
return to_deployment_container(ctx, ctr)
9191

9292
def uid_gid(self, ctx: CephadmContext) -> Tuple[int, int]:
93-
return 65534, 65534 # nobody, nobody
93+
return UID_NOBODY, GID_NOGROUP
9494

9595
def get_daemon_args(self) -> List[str]:
9696
return []

src/cephadm/cephadmlib/daemons/monitoring.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
DEFAULT_NODE_EXPORTER_IMAGE,
1111
DEFAULT_PROMETHEUS_IMAGE,
1212
DEFAULT_PROMTAIL_IMAGE,
13+
UID_NOBODY,
14+
GID_NOGROUP,
1315
)
1416
from ..container_daemon_form import ContainerDaemonForm, daemon_to_container
1517
from ..container_types import CephContainer, extract_uid_gid
@@ -170,7 +172,7 @@ def extract_uid_gid(
170172
if daemon_type == 'prometheus':
171173
uid, gid = extract_uid_gid(ctx, file_path='/etc/prometheus')
172174
elif daemon_type == 'node-exporter':
173-
uid, gid = 65534, 65534
175+
uid, gid = UID_NOBODY, GID_NOGROUP
174176
elif daemon_type == 'grafana':
175177
uid, gid = extract_uid_gid(ctx, file_path='/var/lib/grafana')
176178
elif daemon_type == 'loki':

src/cephadm/cephadmlib/daemons/tracing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ..daemon_form import register as register_daemon_form
1616
from ..daemon_identity import DaemonIdentity
1717
from ..deployment_utils import to_deployment_container
18+
from ..constants import UID_NOBODY, GID_NOGROUP
1819

1920

2021
logger = logging.getLogger()
@@ -87,7 +88,7 @@ def container(self, ctx: CephadmContext) -> CephContainer:
8788
return to_deployment_container(ctx, ctr)
8889

8990
def uid_gid(self, ctx: CephadmContext) -> Tuple[int, int]:
90-
return 65534, 65534
91+
return UID_NOBODY, GID_NOGROUP
9192

9293
def get_daemon_args(self) -> List[str]:
9394
return self.components[self.identity.daemon_type].get(

0 commit comments

Comments
 (0)