Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env for idle timeout #293

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sudo snap install charmed-openstack-upgrader

An alias `cou` will be automatically enabled upon successful installation.

Run `cou -h` to learn about the available commands:
Run `cou -h` to learn about the available commands:

```bash
Usage: cou [options] <command>
Expand All @@ -43,6 +43,8 @@ Commands:
- `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.

## Supported Upgrade Paths

Expand All @@ -57,4 +59,4 @@ upgrades.

# License
Charmed OpenStack Upgrader is a free software, distributed under the Apache-2.0 license. Refer to the
[LICENSE](https://github.com/canonical/snap-tempest/blob/main/LICENSE) file for details.
[LICENSE](https://github.com/canonical/snap-tempest/blob/main/LICENSE) file for details.
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(
gabrielcocenza marked this conversation as resolved.
Show resolved Hide resolved
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.
Loading