Skip to content

Commit 682d4fa

Browse files
authored
🐛Dynamic schldr: deferred tasks passing invalid kwargs parameters to exceptions (#6573)
1 parent 4c5aa41 commit 682d4fa

File tree

14 files changed

+28
-33
lines changed

14 files changed

+28
-33
lines changed

.env-devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ DYNAMIC_SIDECAR_PROMETHEUS_MONITORING_NETWORKS=[]
106106
DYNAMIC_SIDECAR_PROMETHEUS_SERVICE_LABELS={}
107107
DYNAMIC_SIDECAR_API_SAVE_RESTORE_STATE_TIMEOUT=3600
108108
# DIRECTOR_V2 ----
109-
109+
DYNAMIC_SCHEDULER_LOGLEVEL=DEBUG
110110
DYNAMIC_SCHEDULER_PROFILING=1
111111
DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT=3600
112112

packages/service-library/src/servicelib/deferred_tasks/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ async def wrapper(*args, **kwargs):
3030
f"Please check code at: '{func.__module__}.{func.__name__}'"
3131
)
3232
_logger.exception(msg)
33-
raise RejectMessage(reason=msg) from e
33+
raise RejectMessage(msg) from e
3434

3535
return wrapper

packages/settings-library/tests/test_utils_logging.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ class Settings(BaseCustomSettings, MixinLoggingSettings):
2525
],
2626
)
2727

28-
APPNAME_DEBUG: bool = Field(False, description="Starts app in debug mode")
28+
APPNAME_DEBUG: bool = Field(
29+
default=False, description="Starts app in debug mode"
30+
)
2931

30-
@validator("LOG_LEVEL")
32+
@validator("LOG_LEVEL", pre=True)
3133
@classmethod
32-
def _v(cls, value) -> str:
34+
def _v(cls, value: str) -> str:
3335
return cls.validate_log_level(value)
3436

3537
# -----------------------------------------------------------

services/autoscaling/src/simcore_service_autoscaling/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
298298
def LOG_LEVEL(self): # noqa: N802
299299
return self.AUTOSCALING_LOGLEVEL
300300

301-
@validator("AUTOSCALING_LOGLEVEL")
301+
@validator("AUTOSCALING_LOGLEVEL", pre=True)
302302
@classmethod
303303
def _valid_log_level(cls, value: str) -> str:
304304
return cls.validate_log_level(value)

services/clusters-keeper/src/simcore_service_clusters_keeper/core/settings.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,9 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
311311
"(default to seconds, or see https://pydantic-docs.helpmanual.io/usage/types/#datetime-types for string formating)",
312312
)
313313

314-
CLUSTERS_KEEPER_MAX_MISSED_HEARTBEATS_BEFORE_CLUSTER_TERMINATION: NonNegativeInt = (
315-
Field(
316-
default=5,
317-
description="Max number of missed heartbeats before a cluster is terminated",
318-
)
314+
CLUSTERS_KEEPER_MAX_MISSED_HEARTBEATS_BEFORE_CLUSTER_TERMINATION: NonNegativeInt = Field(
315+
default=5,
316+
description="Max number of missed heartbeats before a cluster is terminated",
319317
)
320318

321319
CLUSTERS_KEEPER_COMPUTATIONAL_BACKEND_DOCKER_IMAGE_TAG: str = Field(
@@ -352,7 +350,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
352350
def LOG_LEVEL(self) -> LogLevel: # noqa: N802
353351
return self.CLUSTERS_KEEPER_LOGLEVEL
354352

355-
@validator("CLUSTERS_KEEPER_LOGLEVEL")
353+
@validator("CLUSTERS_KEEPER_LOGLEVEL", pre=True)
356354
@classmethod
357355
def valid_log_level(cls, value: str) -> str:
358356
return cls.validate_log_level(value)

services/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ services:
547547
REDIS_PASSWORD: ${REDIS_PASSWORD}
548548
DIRECTOR_V2_HOST: ${DIRECTOR_V2_HOST}
549549
DIRECTOR_V2_PORT: ${DIRECTOR_V2_PORT}
550+
DYNAMIC_SCHEDULER_LOGLEVEL: ${DYNAMIC_SCHEDULER_LOGLEVEL}
550551
DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT: ${DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT}
551552
DYNAMIC_SCHEDULER_PROFILING: ${DYNAMIC_SCHEDULER_PROFILING}
552553
TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT: ${TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT}

services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/core/settings.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import datetime
2-
from functools import cached_property
32

43
from pydantic import Field, parse_obj_as, validator
54
from settings_library.application import BaseApplicationSettings
@@ -23,14 +22,14 @@ class _BaseApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
2322

2423
# RUNTIME -----------------------------------------------------------
2524

26-
DYNAMIC_SCHEDULER__LOGLEVEL: LogLevel = Field(
25+
DYNAMIC_SCHEDULER_LOGLEVEL: LogLevel = Field(
2726
default=LogLevel.INFO,
28-
env=["DYNAMIC_SCHEDULER__LOGLEVEL", "LOG_LEVEL", "LOGLEVEL"],
27+
env=["DYNAMIC_SCHEDULER_LOGLEVEL", "LOG_LEVEL", "LOGLEVEL"],
2928
)
3029
DYNAMIC_SCHEDULER_LOG_FORMAT_LOCAL_DEV_ENABLED: bool = Field(
3130
default=False,
3231
env=[
33-
"DYNAMIC_SCHEDULER__LOG_FORMAT_LOCAL_DEV_ENABLED",
32+
"DYNAMIC_SCHEDULER_LOG_FORMAT_LOCAL_DEV_ENABLED",
3433
"LOG_FORMAT_LOCAL_DEV_ENABLED",
3534
],
3635
description="Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!",
@@ -44,13 +43,9 @@ class _BaseApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
4443
),
4544
)
4645

47-
@cached_property
48-
def LOG_LEVEL(self): # noqa: N802
49-
return self.DYNAMIC_SCHEDULER__LOGLEVEL
50-
51-
@validator("DYNAMIC_SCHEDULER__LOGLEVEL")
46+
@validator("DYNAMIC_SCHEDULER_LOGLEVEL", pre=True)
5247
@classmethod
53-
def valid_log_level(cls, value: str) -> str:
48+
def _validate_log_level(cls, value: str) -> str:
5449
return cls.validate_log_level(value)
5550

5651

services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
_the_settings = ApplicationSettings.create_from_envs()
1313

14-
# SEE https://github.com/ITISFoundation/osparc-simcore/issues/3148
15-
logging.basicConfig(level=_the_settings.log_level) # NOSONAR
16-
logging.root.setLevel(_the_settings.log_level)
14+
logging.basicConfig(level=_the_settings.DYNAMIC_SCHEDULER_LOGLEVEL.value)
15+
logging.root.setLevel(_the_settings.DYNAMIC_SCHEDULER_LOGLEVEL.value)
1716
config_all_loggers(
1817
log_format_local_dev_enabled=_the_settings.DYNAMIC_SCHEDULER_LOG_FORMAT_LOCAL_DEV_ENABLED
1918
)

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
165165
def are_prometheus_metrics_enabled(self) -> bool:
166166
return self.DY_SIDECAR_CALLBACKS_MAPPING.metrics is not None
167167

168-
@validator("LOG_LEVEL")
168+
@validator("LOG_LEVEL", pre=True)
169169
@classmethod
170-
def _check_log_level(cls, value):
170+
def _check_log_level(cls, value: str) -> str:
171171
return cls.validate_log_level(value)
172172

173173

services/efs-guardian/src/simcore_service_efs_guardian/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
9696
def LOG_LEVEL(self) -> LogLevel: # noqa: N802
9797
return self.EFS_GUARDIAN_LOGLEVEL
9898

99-
@validator("EFS_GUARDIAN_LOGLEVEL")
99+
@validator("EFS_GUARDIAN_LOGLEVEL", pre=True)
100100
@classmethod
101101
def valid_log_level(cls, value: str) -> str:
102102
return cls.validate_log_level(value)

0 commit comments

Comments
 (0)