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

🐛Autoscaling: Buffer pools metrics always showing 0 #6314

Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion services/autoscaling/src/simcore_service_autoscaling/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import defaultdict
from collections.abc import Generator
from dataclasses import dataclass, field
from dataclasses import dataclass, field, fields
from typing import Any, TypeAlias

from aws_library.ec2 import EC2InstanceData, EC2InstanceType, Resources
Expand Down Expand Up @@ -212,3 +212,13 @@ class BufferPoolManager:

def __repr__(self) -> str:
return f"BufferPoolManager({dict(self.buffer_pools)})"

def flatten_buffer_pool(self) -> BufferPool:
"""returns a flattened buffer pool with all the EC2InstanceData"""
flat_pool = BufferPool()

for buffer_pool in self.buffer_pools.values():
for f in fields(BufferPool):
getattr(flat_pool, f.name).update(getattr(buffer_pool, f.name))

return flat_pool
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ def __post_init__(self) -> None:
def update_from_buffer_pool_manager(
self, buffer_pool_manager: BufferPoolManager
) -> None:
for buffer_pool in buffer_pool_manager.buffer_pools.values():
for field_name in BUFFER_POOLS_METRICS_DEFINITIONS:
tracked_gauge = getattr(self, field_name)
assert isinstance(tracked_gauge, TrackedGauge) # nosec
instances = getattr(buffer_pool, field_name)
assert isinstance(instances, set) # nosec
tracked_gauge.update_from_instances(instances)
flat_pool = buffer_pool_manager.flatten_buffer_pool()

for field_name in BUFFER_POOLS_METRICS_DEFINITIONS:
tracked_gauge = getattr(self, field_name)
assert isinstance(tracked_gauge, TrackedGauge) # nosec
instances = getattr(flat_pool, field_name)
assert isinstance(instances, set) # nosec
tracked_gauge.update_from_instances(instances)


@dataclass(slots=True, kw_only=True)
Expand Down
Loading