spec,
curr_deps=deps,
last_deps=last_deps,
+ daemon=dd,
)
if _step.action is not _scheduled_action:
self.log.info(
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
scheduled_action, daemon_type, spec, curr_deps, last_deps
)
action = step.action
+ # keepalived is not systemd-enabled; when stopped, redeploy rewrites
+ # the unit and container so the serve loop can start the daemon again.
+ if (
+ daemon_type == 'keepalived'
+ and action is utils.Action.RECONFIG
+ and daemon is not None
+ and daemon.status == DaemonDescriptionStatus.stopped
+ ):
+ logger.debug(
+ 'Redeploy wanted %s: keepalived deps changed (daemon stopped)',
+ spec.service_name() if spec else daemon_type,
+ )
+ return utils.NextDaemonStep(utils.Action.REDEPLOY)
+
if (
action is not utils.Action.REDEPLOY
and daemon_type == 'haproxy'
from typing import List, cast, Optional, TYPE_CHECKING
from cephadm.services.cephadmservice import CephadmService, CephadmDaemonDeploySpec
from ceph.deployment.service_spec import TracingSpec, ServiceSpec
+from orchestrator import DaemonDescription
from .service_registry import register_cephadm_service
from mgr_util import build_url
from cephadm import utils
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
spec: Optional[ServiceSpec],
curr_deps: List[str],
last_deps: List[str],
+ daemon: Optional[DaemonDescription] = None,
) -> utils.NextDaemonStep:
"""Given the scheduled_action, service spec, daemon_type, and
current and previous dependency lists return the next action that
from ceph.utils import datetime_now
from orchestrator._interface import DaemonDescription, DaemonDescriptionStatus
from orchestrator import HostSpec
+from cephadm import utils
from cephadm.services.ingress import IngressService
assert "Bind_addr = 10.10.2.20" in ganesha_conf
+def test_keepalived_choose_next_action_redeploy_on_deps_change_when_stopped():
+ mgr = MagicMock()
+ svc = IngressService(mgr)
+ spec = IngressSpec(
+ service_id='test',
+ backend_service='nfs.foo',
+ frontend_port=2049,
+ monitor_port=9049,
+ virtual_ip='192.168.122.100/24',
+ placement=PlacementSpec(hosts=['host1']),
+ )
+ daemon = DaemonDescription(
+ daemon_type='keepalived',
+ daemon_id='test',
+ hostname='host1',
+ service_name='ingress.test',
+ status=DaemonDescriptionStatus.stopped,
+ )
+ next_step = svc.choose_next_action(
+ utils.Action.NO_ACTION,
+ 'keepalived',
+ spec,
+ curr_deps=['haproxy.test'],
+ last_deps=['haproxy.old'],
+ daemon=daemon,
+ )
+ assert next_step.action is utils.Action.REDEPLOY
+
+
+def test_keepalived_choose_next_action_reconfig_when_running():
+ mgr = MagicMock()
+ svc = IngressService(mgr)
+ spec = IngressSpec(
+ service_id='test',
+ backend_service='nfs.foo',
+ frontend_port=2049,
+ monitor_port=9049,
+ virtual_ip='192.168.122.100/24',
+ placement=PlacementSpec(hosts=['host1']),
+ )
+ daemon = DaemonDescription(
+ daemon_type='keepalived',
+ daemon_id='test',
+ hostname='host1',
+ service_name='ingress.test',
+ status=DaemonDescriptionStatus.running,
+ )
+ next_step = svc.choose_next_action(
+ utils.Action.NO_ACTION,
+ 'keepalived',
+ spec,
+ curr_deps=['haproxy.test'],
+ last_deps=['haproxy.old'],
+ daemon=daemon,
+ )
+ assert next_step.action is utils.Action.RECONFIG
+
+
+def test_keepalived_choose_next_action_scheduled_when_deps_unchanged():
+ mgr = MagicMock()
+ svc = IngressService(mgr)
+ spec = IngressSpec(
+ service_id='test',
+ backend_service='nfs.foo',
+ frontend_port=2049,
+ monitor_port=9049,
+ virtual_ip='192.168.122.100/24',
+ placement=PlacementSpec(hosts=['host1']),
+ )
+ deps = ['haproxy.test']
+ next_step = svc.choose_next_action(
+ utils.Action.NO_ACTION,
+ 'keepalived',
+ spec,
+ curr_deps=deps,
+ last_deps=deps,
+ )
+ assert next_step.action is utils.Action.NO_ACTION
+
+
def test_keepalived_should_auto_start_colocated_haproxy():
mgr = MagicMock()
mgr.cache.get_schedulable_hosts.return_value = [HostSpec('host-a')]