From dba3a06d65d904f7c88ccd0ab93dc9129ce97bdf Mon Sep 17 00:00:00 2001 From: Michael Meng Date: Tue, 18 Apr 2023 11:40:12 -0700 Subject: [PATCH] Create ContainerStoppedMetadata class (#521) Summary: Pull Request resolved: https://github.com/facebookresearch/fbpcp/pull/521 Added `ContainerStoppedMetadata` class in order to provide more insights to improve the debugging efficiency. For this task, we mainly focus on the metadata when a container stopped (normally or unexpectedly). `ContainerStoppedMetadata` will be an attribute of `ContainerInstance`. Reviewed By: ziqih, zhuang-93 Differential Revision: D44940312 fbshipit-source-id: 092bb315f2775b2f96e92a58eddeaf8a570dae44 --- CHANGELOG.md | 1 + fbpcp/entity/container_instance.py | 2 ++ fbpcp/entity/container_metadata.py | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 fbpcp/entity/container_metadata.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bf02f84..8e2b08d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - Integrate InsightsService with OneDockerService +- Add ContainerStoppedMetadata ### Changed ### Removed diff --git a/fbpcp/entity/container_instance.py b/fbpcp/entity/container_instance.py index 3b8ab64b..c45c655b 100644 --- a/fbpcp/entity/container_instance.py +++ b/fbpcp/entity/container_instance.py @@ -11,6 +11,7 @@ from typing import Optional from dataclasses_json import dataclass_json +from fbpcp.entity.container_metadata import ContainerStoppedMetadata from fbpcp.entity.container_permission import ContainerPermissionConfig @@ -31,3 +32,4 @@ class ContainerInstance: memory: Optional[int] = None # Memory in GB exit_code: Optional[int] = None permission: Optional[ContainerPermissionConfig] = None + stopped_metadata: Optional[ContainerStoppedMetadata] = None diff --git a/fbpcp/entity/container_metadata.py b/fbpcp/entity/container_metadata.py new file mode 100644 index 00000000..29b72b8f --- /dev/null +++ b/fbpcp/entity/container_metadata.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# pyre-strict + +from dataclasses import dataclass + + +@dataclass +class ContainerStoppedMetadata: + stopped_at: str + stop_code: str + stopped_reason: str