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

K8s container annotations #260

Merged
merged 6 commits into from
Aug 22, 2024
Merged
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
11 changes: 9 additions & 2 deletions granulate_utils/containers/cri.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

import json
from contextlib import contextmanager, suppress
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import Any, List, Optional, Type, TypeVar
from typing import Any, Dict, List, Optional, Type, TypeVar

import grpc # type: ignore # no types-grpc sadly
import psutil
Expand Down Expand Up @@ -122,14 +123,15 @@ def _create_container(
with suppress(psutil.NoSuchProcess):
process = psutil.Process(pid)

return Container(
return K8sContainer(
runtime=self.runtime_name,
name=self._reconstruct_name(container),
id=container.id,
labels=container.labels,
running=container.state == self.api.api_pb2.CONTAINER_RUNNING,
process=process,
time_info=time_info,
annotations=container.annotations,
)


Expand Down Expand Up @@ -182,3 +184,8 @@ def get_container(self, container_id: str, all_info: bool) -> Container:

def get_runtimes(self) -> List[str]:
return [client.runtime_name for client in self._clients]


@dataclass
class K8sContainer(Container):
annotations: Dict[str, str] = field(default_factory=dict)
Loading