Skip to content

Commit

Permalink
Merge pull request ceph#60377 from adk3798/cephadm-share-default-images
Browse files Browse the repository at this point in the history
cephadm: use shared spot for default container image names

Reviewed-by: John Mulligan <[email protected]>
Reviewed-by: Redouane Kachach <[email protected]>
  • Loading branch information
adk3798 authored Oct 30, 2024
2 parents 944d412 + 874f124 commit 72e7e10
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 112 deletions.
3 changes: 3 additions & 0 deletions src/cephadm/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def _build(dest, src, config):
mdir.mkdir(parents=True, exist_ok=True)
(mdir / "__init__.py").touch(exist_ok=True)
versioning_vars = config.cli_args.version_vars
shutil.copytree(
"../python-common/ceph", appdir / "ceph"
)
if versioning_vars:
generate_version_file(versioning_vars, mdir / "version.py")
if dinfo:
Expand Down
18 changes: 0 additions & 18 deletions src/cephadm/cephadmlib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@
DEFAULT_IMAGE = 'quay.ceph.io/ceph-ci/ceph:main'
DEFAULT_IMAGE_IS_MAIN = True
DEFAULT_IMAGE_RELEASE = 'squid'
DEFAULT_PROMETHEUS_IMAGE = 'quay.io/prometheus/prometheus:v2.51.0'
DEFAULT_LOKI_IMAGE = 'quay.io/ceph/loki:3.0.0'
DEFAULT_PROMTAIL_IMAGE = 'quay.io/ceph/promtail:3.0.0'
DEFAULT_NODE_EXPORTER_IMAGE = 'quay.io/prometheus/node-exporter:v1.7.0'
DEFAULT_ALERT_MANAGER_IMAGE = 'quay.io/prometheus/alertmanager:v0.27.0'
DEFAULT_GRAFANA_IMAGE = 'quay.io/ceph/grafana:10.4.8'
DEFAULT_HAPROXY_IMAGE = 'quay.io/ceph/haproxy:2.3'
DEFAULT_KEEPALIVED_IMAGE = 'quay.io/ceph/keepalived:2.2.4'
DEFAULT_NVMEOF_IMAGE = 'quay.io/ceph/nvmeof:1.3.3'
DEFAULT_SNMP_GATEWAY_IMAGE = 'quay.io/ceph/snmp-notifier:v1.2.1'
DEFAULT_ELASTICSEARCH_IMAGE = 'quay.io/omrizeneva/elasticsearch:6.8.23'
DEFAULT_JAEGER_COLLECTOR_IMAGE = 'quay.io/jaegertracing/jaeger-collector:1.29'
DEFAULT_JAEGER_AGENT_IMAGE = 'quay.io/jaegertracing/jaeger-agent:1.29'
DEFAULT_JAEGER_QUERY_IMAGE = 'quay.io/jaegertracing/jaeger-query:1.29'
DEFAULT_SMB_IMAGE = 'quay.io/samba.org/samba-server:devbuilds-centos-amd64'
DEFAULT_SMBMETRICS_IMAGE = 'quay.io/samba.org/samba-metrics:latest'
DEFAULT_NGINX_IMAGE = 'quay.io/ceph/nginx:sclorg-nginx-126'
DEFAULT_OAUTH2_PROXY_IMAGE = 'quay.io/oauth2-proxy/oauth2-proxy:v7.6.0'
DEFAULT_REGISTRY = 'quay.io' # normalize unqualified digests to this
# ------------------------------------------------------------------------------

Expand Down
52 changes: 10 additions & 42 deletions src/cephadm/cephadmlib/container_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,8 @@
from typing import Dict, List, Optional, Any, Union, Tuple, Iterable, cast

from .call_wrappers import call, call_throws, CallVerbosity
from .constants import (
DEFAULT_TIMEOUT,
# default container images
DEFAULT_ALERT_MANAGER_IMAGE,
DEFAULT_GRAFANA_IMAGE,
DEFAULT_LOKI_IMAGE,
DEFAULT_NODE_EXPORTER_IMAGE,
DEFAULT_PROMETHEUS_IMAGE,
DEFAULT_PROMTAIL_IMAGE,
DEFAULT_HAPROXY_IMAGE,
DEFAULT_KEEPALIVED_IMAGE,
DEFAULT_NVMEOF_IMAGE,
DEFAULT_SNMP_GATEWAY_IMAGE,
DEFAULT_ELASTICSEARCH_IMAGE,
DEFAULT_JAEGER_COLLECTOR_IMAGE,
DEFAULT_JAEGER_AGENT_IMAGE,
DEFAULT_JAEGER_QUERY_IMAGE,
DEFAULT_SMB_IMAGE,
DEFAULT_SMBMETRICS_IMAGE,
DEFAULT_NGINX_IMAGE,
DEFAULT_OAUTH2_PROXY_IMAGE,
)
from .constants import DEFAULT_TIMEOUT
import ceph.cephadm.images as default_images
from .container_engines import Docker, Podman
from .context import CephadmContext
from .daemon_identity import DaemonIdentity, DaemonSubIdentity
Expand Down Expand Up @@ -687,24 +667,12 @@ def get_mgr_images() -> dict:
"""Return dict of default mgr images"""
mgr_prefix = 'mgr/cephadm/container_image_'
mgr_images = {}
mgr_images[mgr_prefix + 'prometheus'] = DEFAULT_PROMETHEUS_IMAGE
mgr_images[mgr_prefix + 'alertmanager'] = DEFAULT_ALERT_MANAGER_IMAGE
mgr_images[mgr_prefix + 'graphana'] = DEFAULT_GRAFANA_IMAGE
mgr_images[mgr_prefix + 'loki'] = DEFAULT_LOKI_IMAGE
mgr_images[mgr_prefix + 'promtail'] = DEFAULT_PROMTAIL_IMAGE
mgr_images[mgr_prefix + 'node_exporter'] = DEFAULT_NODE_EXPORTER_IMAGE
mgr_images[mgr_prefix + 'haproxy'] = DEFAULT_HAPROXY_IMAGE
mgr_images[mgr_prefix + 'keepalived'] = DEFAULT_KEEPALIVED_IMAGE
mgr_images[mgr_prefix + 'nvmeof'] = DEFAULT_NVMEOF_IMAGE
mgr_images[mgr_prefix + 'snmp_gateway'] = DEFAULT_SNMP_GATEWAY_IMAGE
mgr_images[mgr_prefix + 'elasticsearch'] = DEFAULT_ELASTICSEARCH_IMAGE
mgr_images[
mgr_prefix + 'jaeger_collector'
] = DEFAULT_JAEGER_COLLECTOR_IMAGE
mgr_images[mgr_prefix + 'jaeger_agent'] = DEFAULT_JAEGER_AGENT_IMAGE
mgr_images[mgr_prefix + 'jaeger_query'] = DEFAULT_JAEGER_QUERY_IMAGE
mgr_images[mgr_prefix + 'smb'] = DEFAULT_SMB_IMAGE
mgr_images[mgr_prefix + 'smbmetrics'] = DEFAULT_SMBMETRICS_IMAGE
mgr_images[mgr_prefix + 'nginx'] = DEFAULT_NGINX_IMAGE
mgr_images[mgr_prefix + 'oauth2_proxy'] = DEFAULT_OAUTH2_PROXY_IMAGE
images = vars(default_images)
for key, value in images.items():
if key.startswith('DEFAULT_') and key.endswith('_IMAGE'):
# flake8 and black disagree about spaces around ":" hence the noqa comment
suffix = key[
len('DEFAULT_') : -len('_IMAGE') # noqa: E203
].lower()
mgr_images[mgr_prefix + suffix] = value
return mgr_images
4 changes: 3 additions & 1 deletion src/cephadm/cephadmlib/daemons/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

from typing import Dict, List, Optional, Tuple, Union

from ..constants import (
from ceph.cephadm.images import (
DEFAULT_HAPROXY_IMAGE,
DEFAULT_KEEPALIVED_IMAGE,
)
from ..constants import (
DATA_DIR_MODE,
)
from ..container_daemon_form import ContainerDaemonForm, daemon_to_container
Expand Down
2 changes: 1 addition & 1 deletion src/cephadm/cephadmlib/daemons/mgmt_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ..daemon_form import register as register_daemon_form
from ..daemon_identity import DaemonIdentity
from ..deployment_utils import to_deployment_container
from ..constants import DEFAULT_NGINX_IMAGE
from ceph.cephadm.images import DEFAULT_NGINX_IMAGE
from ..data_utils import dict_get, is_fsid
from ..file_utils import populate_files, makedirs, recursive_chown
from ..exceptions import Error
Expand Down
8 changes: 5 additions & 3 deletions src/cephadm/cephadmlib/daemons/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from typing import Dict, List, Tuple

from ..call_wrappers import call, CallVerbosity
from ..constants import (
DEFAULT_ALERT_MANAGER_IMAGE,
from ceph.cephadm.images import (
DEFAULT_ALERTMANAGER_IMAGE,
DEFAULT_GRAFANA_IMAGE,
DEFAULT_LOKI_IMAGE,
DEFAULT_NODE_EXPORTER_IMAGE,
DEFAULT_PROMETHEUS_IMAGE,
DEFAULT_PROMTAIL_IMAGE,
)
from ..constants import (
UID_NOBODY,
GID_NOGROUP,
)
Expand Down Expand Up @@ -91,7 +93,7 @@ class Monitoring(ContainerDaemonForm):
],
},
'alertmanager': {
'image': DEFAULT_ALERT_MANAGER_IMAGE,
'image': DEFAULT_ALERTMANAGER_IMAGE,
'cpus': '2',
'memory': '2GB',
'args': [
Expand Down
2 changes: 1 addition & 1 deletion src/cephadm/cephadmlib/daemons/nvmeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..context_getters import fetch_configs, get_config_and_keyring
from ..daemon_form import register as register_daemon_form
from ..daemon_identity import DaemonIdentity
from ..constants import DEFAULT_NVMEOF_IMAGE
from ceph.cephadm.images import DEFAULT_NVMEOF_IMAGE
from ..context import CephadmContext
from ..data_utils import dict_get, is_fsid
from ..deployment_utils import to_deployment_container
Expand Down
3 changes: 2 additions & 1 deletion src/cephadm/cephadmlib/daemons/oauth2_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from ..daemon_form import register as register_daemon_form
from ..daemon_identity import DaemonIdentity
from ..deployment_utils import to_deployment_container
from ..constants import DEFAULT_OAUTH2_PROXY_IMAGE, UID_NOBODY, GID_NOGROUP
from ceph.cephadm.images import DEFAULT_OAUTH2_PROXY_IMAGE
from ..constants import UID_NOBODY, GID_NOGROUP
from ..data_utils import dict_get, is_fsid
from ..file_utils import populate_files, makedirs, recursive_chown
from ..exceptions import Error
Expand Down
4 changes: 2 additions & 2 deletions src/cephadm/cephadmlib/daemons/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .. import deployment_utils
from .. import file_utils
from ..call_wrappers import call, CallVerbosity
from ..constants import DEFAULT_SMB_IMAGE
from ceph.cephadm.images import DEFAULT_SAMBA_IMAGE
from ..container_daemon_form import ContainerDaemonForm, daemon_to_container
from ..container_engines import Podman
from ..container_types import (
Expand Down Expand Up @@ -418,7 +418,7 @@ class SMB(ContainerDaemonForm):

daemon_type = 'smb'
daemon_base = '/usr/sbin/smbd'
default_image = DEFAULT_SMB_IMAGE
default_image = DEFAULT_SAMBA_IMAGE

@classmethod
def for_daemon_type(cls, daemon_type: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/cephadm/cephadmlib/daemons/snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.error import HTTPError, URLError
from urllib.request import urlopen

from ..constants import DEFAULT_SNMP_GATEWAY_IMAGE
from ceph.cephadm.images import DEFAULT_SNMP_GATEWAY_IMAGE
from ..container_daemon_form import ContainerDaemonForm, daemon_to_container
from ..container_types import CephContainer
from ..context import CephadmContext
Expand Down
2 changes: 1 addition & 1 deletion src/cephadm/cephadmlib/daemons/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Dict, List, Tuple

from ..constants import (
from ceph.cephadm.images import (
DEFAULT_ELASTICSEARCH_IMAGE,
DEFAULT_JAEGER_AGENT_IMAGE,
DEFAULT_JAEGER_COLLECTOR_IMAGE,
Expand Down
10 changes: 9 additions & 1 deletion src/cephadm/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ exclude =
statistics = True
[testenv]
setenv =
PYTHONPATH = $PYTHONPATH:..:{toxinidir}/../python-common
passenv =
PYTHONPATH
skip_install=true
deps =
-rzipapp-reqs.txt
Expand All @@ -35,6 +39,10 @@ deps =
commands=pytest {posargs}
[testenv:mypy]
setenv =
MYPYPATH = {toxinidir}/..:{toxinidir}/../python-common
passenv =
MYPYPATH
deps =
mypy
types-PyYAML
Expand All @@ -50,7 +58,7 @@ deps =
commands =
flake8 --config=tox.ini {posargs:cephadm.py cephadmlib}
bash -c 'test $(git ls-files 'cephadm.py' 'cephadmlib/*.py' | sort -u | xargs grep "docker.io" | wc -l) == 1'
bash -c 'test $(git ls-files 'cephadm.py' 'cephadmlib/*.py' | sort -u | xargs grep "quay.io" | wc -l) == 25'
bash -c 'test $(git ls-files 'cephadm.py' 'cephadmlib/*.py' | sort -u | xargs grep "quay.io" | wc -l) == 7'
# Downstream distributions may choose to alter this "docker.io" number,
# to make sure no new references to docker.io are creeping in unnoticed.
Expand Down
58 changes: 19 additions & 39 deletions src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import subprocess
from prettytable import PrettyTable

import ceph.cephadm.images as default_images
from ceph.deployment import inventory
from ceph.deployment.drive_group import DriveGroupSpec
from ceph.deployment.service_spec import \
Expand Down Expand Up @@ -130,28 +131,7 @@ def os_exit_noop(status: int) -> None:

os._exit = os_exit_noop # type: ignore


# Default container images -----------------------------------------------------
DEFAULT_IMAGE = 'quay.io/ceph/ceph'
DEFAULT_PROMETHEUS_IMAGE = 'quay.io/prometheus/prometheus:v2.51.0'
DEFAULT_NODE_EXPORTER_IMAGE = 'quay.io/prometheus/node-exporter:v1.7.0'
DEFAULT_NVMEOF_IMAGE = 'quay.io/ceph/nvmeof:1.3.3'
DEFAULT_LOKI_IMAGE = 'quay.io/ceph/loki:3.0.0'
DEFAULT_PROMTAIL_IMAGE = 'quay.io/ceph/promtail:3.0.0'
DEFAULT_ALERT_MANAGER_IMAGE = 'quay.io/prometheus/alertmanager:v0.27.0'
DEFAULT_GRAFANA_IMAGE = 'quay.io/ceph/grafana:10.4.8'
DEFAULT_HAPROXY_IMAGE = 'quay.io/ceph/haproxy:2.3'
DEFAULT_KEEPALIVED_IMAGE = 'quay.io/ceph/keepalived:2.2.4'
DEFAULT_SNMP_GATEWAY_IMAGE = 'quay.io/ceph/snmp-notifier:v1.2.1'
DEFAULT_ELASTICSEARCH_IMAGE = 'quay.io/omrizeneva/elasticsearch:6.8.23'
DEFAULT_JAEGER_COLLECTOR_IMAGE = 'quay.io/jaegertracing/jaeger-collector:1.29'
DEFAULT_JAEGER_AGENT_IMAGE = 'quay.io/jaegertracing/jaeger-agent:1.29'
DEFAULT_NGINX_IMAGE = 'quay.io/ceph/nginx:sclorg-nginx-126'
DEFAULT_OAUTH2_PROXY_IMAGE = 'quay.io/oauth2-proxy/oauth2-proxy:v7.6.0'
DEFAULT_JAEGER_QUERY_IMAGE = 'quay.io/jaegertracing/jaeger-query:1.29'
DEFAULT_SAMBA_IMAGE = 'quay.io/samba.org/samba-server:devbuilds-centos-amd64'
DEFAULT_SAMBA_METRICS_IMAGE = 'quay.io/samba.org/samba-metrics:latest'
# ------------------------------------------------------------------------------


def host_exists(hostname_position: int = 1) -> Callable:
Expand Down Expand Up @@ -239,92 +219,92 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
),
Option(
'container_image_prometheus',
default=DEFAULT_PROMETHEUS_IMAGE,
default=default_images.DEFAULT_PROMETHEUS_IMAGE,
desc='Prometheus container image',
),
Option(
'container_image_nvmeof',
default=DEFAULT_NVMEOF_IMAGE,
default=default_images.DEFAULT_NVMEOF_IMAGE,
desc='Nvme-of container image',
),
Option(
'container_image_grafana',
default=DEFAULT_GRAFANA_IMAGE,
default=default_images.DEFAULT_GRAFANA_IMAGE,
desc='Prometheus container image',
),
Option(
'container_image_alertmanager',
default=DEFAULT_ALERT_MANAGER_IMAGE,
default=default_images.DEFAULT_ALERTMANAGER_IMAGE,
desc='Prometheus container image',
),
Option(
'container_image_node_exporter',
default=DEFAULT_NODE_EXPORTER_IMAGE,
default=default_images.DEFAULT_NODE_EXPORTER_IMAGE,
desc='Prometheus container image',
),
Option(
'container_image_loki',
default=DEFAULT_LOKI_IMAGE,
default=default_images.DEFAULT_LOKI_IMAGE,
desc='Loki container image',
),
Option(
'container_image_promtail',
default=DEFAULT_PROMTAIL_IMAGE,
default=default_images.DEFAULT_PROMTAIL_IMAGE,
desc='Promtail container image',
),
Option(
'container_image_haproxy',
default=DEFAULT_HAPROXY_IMAGE,
default=default_images.DEFAULT_HAPROXY_IMAGE,
desc='HAproxy container image',
),
Option(
'container_image_keepalived',
default=DEFAULT_KEEPALIVED_IMAGE,
default=default_images.DEFAULT_KEEPALIVED_IMAGE,
desc='Keepalived container image',
),
Option(
'container_image_snmp_gateway',
default=DEFAULT_SNMP_GATEWAY_IMAGE,
default=default_images.DEFAULT_SNMP_GATEWAY_IMAGE,
desc='SNMP Gateway container image',
),
Option(
'container_image_nginx',
default=DEFAULT_NGINX_IMAGE,
default=default_images.DEFAULT_NGINX_IMAGE,
desc='Nginx container image',
),
Option(
'container_image_oauth2_proxy',
default=DEFAULT_OAUTH2_PROXY_IMAGE,
default=default_images.DEFAULT_OAUTH2_PROXY_IMAGE,
desc='oauth2-proxy container image',
),
Option(
'container_image_elasticsearch',
default=DEFAULT_ELASTICSEARCH_IMAGE,
default=default_images.DEFAULT_ELASTICSEARCH_IMAGE,
desc='elasticsearch container image',
),
Option(
'container_image_jaeger_agent',
default=DEFAULT_JAEGER_AGENT_IMAGE,
default=default_images.DEFAULT_JAEGER_AGENT_IMAGE,
desc='Jaeger agent container image',
),
Option(
'container_image_jaeger_collector',
default=DEFAULT_JAEGER_COLLECTOR_IMAGE,
default=default_images.DEFAULT_JAEGER_COLLECTOR_IMAGE,
desc='Jaeger collector container image',
),
Option(
'container_image_jaeger_query',
default=DEFAULT_JAEGER_QUERY_IMAGE,
default=default_images.DEFAULT_JAEGER_QUERY_IMAGE,
desc='Jaeger query container image',
),
Option(
'container_image_samba',
default=DEFAULT_SAMBA_IMAGE,
default=default_images.DEFAULT_SAMBA_IMAGE,
desc='Samba/SMB container image',
),
Option(
'container_image_samba_metrics',
default=DEFAULT_SAMBA_METRICS_IMAGE,
default=default_images.DEFAULT_SAMBA_METRICS_IMAGE,
desc='Samba/SMB metrics exporter container image',
),
Option(
Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ commands =
flake8 --config=tox.ini {posargs} \
{posargs:{[testenv:flake8]modules}}
bash -c 'test $(git ls-files cephadm | grep ".py$" | grep -v tests | xargs grep "docker.io" | wc -l) == 3'
bash -c 'test $(git ls-files cephadm | grep ".py$" | grep -v tests | xargs grep "quay.io" | wc -l) == 26'
bash -c 'test $(git ls-files cephadm | grep ".py$" | grep -v tests | xargs grep "quay.io" | wc -l) == 8'

[testenv:jinjalint]
deps =
Expand Down
2 changes: 2 additions & 0 deletions src/python-common/ceph/cephadm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# this directory is meant for things that will be shared only between
# the cephadm binary and cephadm mgr module
Loading

0 comments on commit 72e7e10

Please sign in to comment.