Skip to content

Commit

Permalink
Add env for idle timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rgildein committed Mar 12, 2024
1 parent aaa56e4 commit 95c07b7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cou/apps/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import logging
from typing import Optional

from cou.apps.base import OpenStackApplication
from cou.apps.base import LONG_IDLE_TIMEOUT, OpenStackApplication
from cou.apps.factory import AppFactory
from cou.exceptions import ApplicationError
from cou.steps import PreUpgradeStep
Expand Down Expand Up @@ -128,15 +128,15 @@ class RabbitMQServer(OpenStackAuxiliaryApplication):
RabbitMQ must wait for the entire model to be idle before declaring the upgrade complete.
"""

wait_timeout = 30 * 60 # 30 min
wait_timeout = LONG_IDLE_TIMEOUT
wait_for_model = True


@AppFactory.register_application(["ceph-mon"])
class CephMonApplication(OpenStackAuxiliaryApplication):
"""Application for Ceph Monitor charm."""

wait_timeout = 30 * 60 # 30 min
wait_timeout = LONG_IDLE_TIMEOUT
wait_for_model = True

def pre_upgrade_steps(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
Expand Down Expand Up @@ -189,7 +189,7 @@ class MysqlInnodbClusterApplication(OpenStackAuxiliaryApplication):
# NOTE(agileshaw): holding 'mysql-server-core-8.0' package prevents undesired
# mysqld processes from restarting, which lead to outages
packages_to_hold: Optional[list] = ["mysql-server-core-8.0"]
wait_timeout = 30 * 60 # 30 min
wait_timeout = LONG_IDLE_TIMEOUT


# NOTE (gabrielcocenza): Although CephOSD class is empty now, it will be
Expand Down
8 changes: 6 additions & 2 deletions cou/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from __future__ import annotations

import logging
import os
from collections import defaultdict
from dataclasses import dataclass, field
from io import StringIO
Expand Down Expand Up @@ -46,7 +47,10 @@

logger = logging.getLogger(__name__)

DEFAULT_WAITING_TIMEOUT = 5 * 60 # 5 min
STANDARD_IDLE_TIMEOUT: int = int(
os.environ.get("COU_STANDARD_IDLE_TIMEOUT", 5 * 60)
) # default of 5 min
LONG_IDLE_TIMEOUT: int = int(os.environ.get("COU_LONG_IDLE_TIMEOUT", 30 * 60)) # default of 30 min


@dataclass
Expand Down Expand Up @@ -105,7 +109,7 @@ class OpenStackApplication:
origin_setting: Optional[str] = None
units: list[ApplicationUnit] = field(default_factory=lambda: [])
packages_to_hold: Optional[list] = field(default=None, init=False)
wait_timeout: int = field(default=DEFAULT_WAITING_TIMEOUT, init=False)
wait_timeout: int = field(default=STANDARD_IDLE_TIMEOUT, init=False)
wait_for_model: bool = field(default=False, init=False) # waiting only for application itself

def __post_init__(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions cou/apps/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Core application class."""
import logging

from cou.apps.base import OpenStackApplication
from cou.apps.base import LONG_IDLE_TIMEOUT, OpenStackApplication
from cou.apps.factory import AppFactory

logger = logging.getLogger(__name__)
Expand All @@ -28,7 +28,7 @@ class Keystone(OpenStackApplication):
Keystone must wait for the entire model to be idle before declaring the upgrade complete.
"""

wait_timeout = 30 * 60 # 30 min
wait_timeout = LONG_IDLE_TIMEOUT
wait_for_model = True


Expand All @@ -39,4 +39,4 @@ class Octavia(OpenStackApplication):
Octavia required more time to settle before COU can continue.
"""

wait_timeout = 30 * 60 # 30 min
wait_timeout = LONG_IDLE_TIMEOUT
2 changes: 1 addition & 1 deletion docs/how-to/different-model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ configuration files.
.. LINKS
.. _python-libjuju: https://github.com/juju/python-libjuju
.. _Juju environment variables: https://juju.is/docs/juju/environment-variables#heading--jujudata
.. _Juju environment variables: https://juju.is/docs/juju/environment-variables
.. _JUJU_DATA: https://juju.is/docs/juju/environment-variables#heading--jujudata
2 changes: 2 additions & 0 deletions docs/reference/environment-variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ Environment Variables
* **COU_TIMEOUT** - define timeout for **COU** retry policy. Default value is 10 seconds.
* **COU_MODEL_RETRIES** - define how many times to retry the connection to Juju model before giving up. Default value is 5 times.
* **COU_MODEL_RETRY_BACKOFF** - define number of seconds to increase the wait between connection to the Juju model retry attempts. Default value is 2 seconds.
* **COU_STANDARD_IDLE_TIMEOUT** - how long COU will wait for an application to settle to active/idle and declare the upgrade complete. The default value is 300 seconds.
* **COU_LONG_IDLE_TIMEOUT** - a longer version of COU_STANDARD_IDLE_TIMEOUT for applications that are known to need more time than usual to upgrade like such as Keystone and Octavia. The default value is 1800 seconds.

0 comments on commit 95c07b7

Please sign in to comment.