python-common: add extra_entrypoint_args to service specs

To allow users to set extra args to be passed to
the entrypoint in the podman/docker run command
built by cephadm

Signed-off-by: Adam King <adking@redhat.com>
This commit is contained in:
Adam King 2022-11-07 16:15:09 -05:00
parent c86fc2b859
commit 98f6a9379e
2 changed files with 34 additions and 8 deletions

View File

@ -154,7 +154,7 @@ class DriveGroupSpec(ServiceSpec):
"data_devices", "db_devices", "wal_devices", "journal_devices",
"data_directories", "osds_per_device", "objectstore", "osd_id_claims",
"journal_size", "unmanaged", "filter_logic", "preview_only", "extra_container_args",
"data_allocate_fraction", "method", "crush_device_class", "config",
"extra_entrypoint_args", "data_allocate_fraction", "method", "crush_device_class", "config",
]
def __init__(self,
@ -179,6 +179,7 @@ class DriveGroupSpec(ServiceSpec):
filter_logic='AND', # type: str
preview_only=False, # type: bool
extra_container_args=None, # type: Optional[List[str]]
extra_entrypoint_args: Optional[List[str]] = None,
data_allocate_fraction=None, # type: Optional[float]
method=None, # type: Optional[OSDMethod]
crush_device_class=None, # type: Optional[str]
@ -192,6 +193,7 @@ class DriveGroupSpec(ServiceSpec):
unmanaged=unmanaged,
preview_only=preview_only,
extra_container_args=extra_container_args,
extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
#: A :class:`ceph.deployment.drive_group.DeviceSelection`

View File

@ -559,6 +559,7 @@ class ServiceSpec(object):
preview_only: bool = False,
networks: Optional[List[str]] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
@ -599,6 +600,7 @@ class ServiceSpec(object):
self.config = {k.replace(' ', '_'): v for k, v in config.items()}
self.extra_container_args: Optional[List[str]] = extra_container_args
self.extra_entrypoint_args: Optional[List[str]] = extra_entrypoint_args
self.custom_configs: Optional[List[CustomConfig]] = custom_configs
@classmethod
@ -727,6 +729,8 @@ class ServiceSpec(object):
ret['networks'] = self.networks
if self.extra_container_args:
ret['extra_container_args'] = self.extra_container_args
if self.extra_entrypoint_args:
ret['extra_entrypoint_args'] = self.extra_entrypoint_args
if self.custom_configs:
ret['custom_configs'] = [c.to_json() for c in self.custom_configs]
@ -805,6 +809,7 @@ class NFSServiceSpec(ServiceSpec):
networks: Optional[List[str]] = None,
port: Optional[int] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'nfs'
@ -812,7 +817,7 @@ class NFSServiceSpec(ServiceSpec):
'nfs', service_id=service_id,
placement=placement, unmanaged=unmanaged, preview_only=preview_only,
config=config, networks=networks, extra_container_args=extra_container_args,
custom_configs=custom_configs)
extra_entrypoint_args=extra_entrypoint_args, custom_configs=custom_configs)
self.port = port
@ -873,6 +878,7 @@ class RGWSpec(ServiceSpec):
networks: Optional[List[str]] = None,
subcluster: Optional[str] = None, # legacy, only for from_json on upgrade
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
rgw_realm_token: Optional[str] = None,
update_endpoints: Optional[bool] = False,
@ -888,7 +894,8 @@ class RGWSpec(ServiceSpec):
'rgw', service_id=service_id,
placement=placement, unmanaged=unmanaged,
preview_only=preview_only, config=config, networks=networks,
extra_container_args=extra_container_args, custom_configs=custom_configs)
extra_container_args=extra_container_args, extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
#: The RGW realm associated with this service. Needs to be manually created
#: if the spec is being applied directly to cephdam. In case of rgw module
@ -956,6 +963,7 @@ class IscsiServiceSpec(ServiceSpec):
config: Optional[Dict[str, str]] = None,
networks: Optional[List[str]] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'iscsi'
@ -964,6 +972,7 @@ class IscsiServiceSpec(ServiceSpec):
preview_only=preview_only,
config=config, networks=networks,
extra_container_args=extra_container_args,
extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
#: RADOS pool where ceph-iscsi config data is stored.
@ -1031,6 +1040,7 @@ class IngressSpec(ServiceSpec):
unmanaged: bool = False,
ssl: bool = False,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'ingress'
@ -1040,6 +1050,7 @@ class IngressSpec(ServiceSpec):
placement=placement, config=config,
networks=networks,
extra_container_args=extra_container_args,
extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs
)
self.backend_service = backend_service
@ -1100,10 +1111,11 @@ class CustomContainerSpec(ServiceSpec):
preview_only: bool = False,
image: Optional[str] = None,
entrypoint: Optional[str] = None,
extra_entrypoint_args: Optional[List[str]] = None,
uid: Optional[int] = None,
gid: Optional[int] = None,
volume_mounts: Optional[Dict[str, str]] = {},
args: Optional[List[str]] = [],
args: Optional[List[str]] = [], # args for the container runtime, not entrypoint
envs: Optional[List[str]] = [],
privileged: Optional[bool] = False,
bind_mounts: Optional[List[List[str]]] = None,
@ -1119,7 +1131,7 @@ class CustomContainerSpec(ServiceSpec):
service_type, service_id,
placement=placement, unmanaged=unmanaged,
preview_only=preview_only, config=config,
networks=networks)
networks=networks, extra_entrypoint_args=extra_entrypoint_args)
self.image = image
self.entrypoint = entrypoint
@ -1167,6 +1179,7 @@ class MonitoringSpec(ServiceSpec):
preview_only: bool = False,
port: Optional[int] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type in ['grafana', 'node-exporter', 'prometheus', 'alertmanager',
@ -1177,6 +1190,7 @@ class MonitoringSpec(ServiceSpec):
placement=placement, unmanaged=unmanaged,
preview_only=preview_only, config=config,
networks=networks, extra_container_args=extra_container_args,
extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
self.service_type = service_type
@ -1213,6 +1227,7 @@ class AlertManagerSpec(MonitoringSpec):
port: Optional[int] = None,
secure: bool = False,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'alertmanager'
@ -1220,7 +1235,8 @@ class AlertManagerSpec(MonitoringSpec):
'alertmanager', service_id=service_id,
placement=placement, unmanaged=unmanaged,
preview_only=preview_only, config=config, networks=networks, port=port,
extra_container_args=extra_container_args, custom_configs=custom_configs)
extra_container_args=extra_container_args, extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
# Custom configuration.
#
@ -1266,6 +1282,7 @@ class GrafanaSpec(MonitoringSpec):
protocol: Optional[str] = 'https',
initial_admin_password: Optional[str] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'grafana'
@ -1273,7 +1290,8 @@ class GrafanaSpec(MonitoringSpec):
'grafana', service_id=service_id,
placement=placement, unmanaged=unmanaged,
preview_only=preview_only, config=config, networks=networks, port=port,
extra_container_args=extra_container_args, custom_configs=custom_configs)
extra_container_args=extra_container_args, extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
self.initial_admin_password = initial_admin_password
self.protocol = protocol
@ -1301,6 +1319,7 @@ class PrometheusSpec(MonitoringSpec):
retention_time: Optional[str] = None,
retention_size: Optional[str] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'prometheus'
@ -1308,7 +1327,8 @@ class PrometheusSpec(MonitoringSpec):
'prometheus', service_id=service_id,
placement=placement, unmanaged=unmanaged,
preview_only=preview_only, config=config, networks=networks, port=port,
extra_container_args=extra_container_args, custom_configs=custom_configs)
extra_container_args=extra_container_args, extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
self.retention_time = retention_time.strip() if retention_time else None
self.retention_size = retention_size.strip() if retention_size else None
@ -1373,6 +1393,7 @@ class SNMPGatewaySpec(ServiceSpec):
preview_only: bool = False,
port: Optional[int] = None,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'snmp-gateway'
@ -1383,6 +1404,7 @@ class SNMPGatewaySpec(ServiceSpec):
unmanaged=unmanaged,
preview_only=preview_only,
extra_container_args=extra_container_args,
extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
self.service_type = service_type
@ -1494,6 +1516,7 @@ class MDSSpec(ServiceSpec):
unmanaged: bool = False,
preview_only: bool = False,
extra_container_args: Optional[List[str]] = None,
extra_entrypoint_args: Optional[List[str]] = None,
custom_configs: Optional[List[CustomConfig]] = None,
):
assert service_type == 'mds'
@ -1503,6 +1526,7 @@ class MDSSpec(ServiceSpec):
unmanaged=unmanaged,
preview_only=preview_only,
extra_container_args=extra_container_args,
extra_entrypoint_args=extra_entrypoint_args,
custom_configs=custom_configs)
def validate(self) -> None: