diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc728d3..bb210fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Releases are versioned in accordance with [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.2.4] "genesis" - 2023-04-14 + +### Changed + +- Default interval of progress updates changed from 5 seconds to 60 +- Updated API path used for servo endpoint of optimize solution + ## [2.2.3] "genesis" - 2023-03-31 ### Changed diff --git a/pyproject.toml b/pyproject.toml index 26212247..8f9d7758 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "servox" -version = "2.2.3" +version = "2.2.4" description = "Opsani Servo: The Next Generation" homepage = "https://opsani.com/" repository = "https://github.com/opsani/servox" diff --git a/servo/configuration.py b/servo/configuration.py index 93751901..7a1c5afc 100644 --- a/servo/configuration.py +++ b/servo/configuration.py @@ -66,7 +66,7 @@ class SidecarConnectionFile(pydantic.BaseModel): class AppdynamicsOptimizer(pydantic.BaseSettings): optimizer_id: str tenant_id: Optional[str] = None - base_url: pydantic.AnyHttpUrl = "https://optimize-ignite-test.saas.appd-test.com/" + base_url: Optional[pydantic.AnyHttpUrl] = None # static config properties client_id: Optional[str] = None client_secret: Optional[pydantic.SecretStr] = None @@ -90,14 +90,15 @@ def __init__(self, **kwargs) -> None: self.client_id is None or self.client_secret is None or self.tenant_id is None + or self.base_url is None ): raise ValueError( - f"{self.__class__.__name__} must be configured with a connection file or specify client_id, client_secret, and tenant_id" + f"{self.__class__.__name__} must be configured with a connection file or specify base_url, client_id, client_secret, and tenant_id" ) if not self.url: self.url = ( - f"{self.base_url}/rest/optimize/co/v1/optimizer/{self.optimizer_id}/" + f"{self.base_url}/rest/optimize/co/v1/optimizers/{self.optimizer_id}/" ) if not self.token_url: self.token_url = ( @@ -118,7 +119,9 @@ def load_connection_file(self) -> None: @pydantic.validator("base_url") def _rstrip_slash(cls, url: str) -> str: - return url.rstrip("/") + if url: + return url.rstrip("/") + return url @property def id(self) -> str: @@ -131,6 +134,7 @@ def name(self) -> str: class Config: case_sensitive = True extra = pydantic.Extra.forbid + validate_assignment = True fields = { "optimizer_id": {"env": "APPD_OPTIMIZER_ID"}, "tenant_id": {"env": "APPD_TENANT_ID"}, diff --git a/servo/types/core.py b/servo/types/core.py index 6026e3c1..a9735ad0 100644 --- a/servo/types/core.py +++ b/servo/types/core.py @@ -19,6 +19,7 @@ import abc import asyncio +import contextlib import datetime import enum import inspect @@ -583,11 +584,29 @@ async def watch( # NOTE: Handle the case where reporting interval < timeout (matters mostly for tests) if every is None: if self.timeout is None: - every = Duration("5s") + every = Duration("60s") else: - every = min(Duration("5s"), self.timeout) + every = min(Duration("60s"), self.timeout) - return await super().watch(notify, every) + # return await super().watch(notify, every) + async def async_notifier() -> None: + if asyncio.iscoroutinefunction(notify): + await notify(self) + else: + notify(self) + + if not self.started: + self.start() + + while True: + if self.finished: + break + + with contextlib.suppress(asyncio.TimeoutError): + await asyncio.wait_for( + self._event.wait(), timeout=every.total_seconds() + ) + await async_notifier() class Unit(str, enum.Enum): diff --git a/tests/connectors/kubernetes_test.py b/tests/connectors/kubernetes_test.py index 47006e5f..7a5003bc 100644 --- a/tests/connectors/kubernetes_test.py +++ b/tests/connectors/kubernetes_test.py @@ -1969,6 +1969,8 @@ async def test_adjust_tuning_never_ready( in str(e) ): pytest.xfail("Tuning pod shutdown took over 30 seconds") + else: + raise # Validate the correct error was raised, re-raise if not for additional debugging context try: diff --git a/tests/servo_test.py b/tests/servo_test.py index f230db0f..502c8f0c 100644 --- a/tests/servo_test.py +++ b/tests/servo_test.py @@ -880,7 +880,6 @@ async def test_aliased_connectors_produce_schema( "description": "Base class for settings, allowing values to be overridden by environment variables.\n\nThis is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose),\nHeroku and any 12 factor app design.", "properties": { "base_url": { - "default": "https://optimize-ignite-test.saas.appd-test.com/", "env": "APPD_BASE_URL", "env_names": ["APPD_BASE_URL"], "format": "uri",