Skip to content

Commit

Permalink
Merge pull request #521 from opsani/v2.2.4-upddate
Browse files Browse the repository at this point in the history
Changes for v2.2.4
  • Loading branch information
linkous8 authored Apr 17, 2023
2 parents 5885a0e + c17dc6c commit af13edd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
12 changes: 8 additions & 4 deletions servo/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = (
Expand All @@ -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:
Expand All @@ -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"},
Expand Down
25 changes: 22 additions & 3 deletions servo/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import abc
import asyncio
import contextlib
import datetime
import enum
import inspect
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions tests/connectors/kubernetes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion tests/servo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit af13edd

Please sign in to comment.