Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
DobbyContainer Class Reference

Wrapper object used to store container resources. More...

#include <DobbyContainer.h>

Public Types

enum class  State {
  Starting , Running , Stopping , Paused ,
  Hibernating , Hibernated , Awakening , Unknown
}
 

Public Member Functions

 DobbyContainer (DobbyContainer &)=delete
 
 DobbyContainer (DobbyContainer &&)=delete
 
void setRestartOnCrash (const std::list< int > &files)
 
void clearRestartOnCrash ()
 
bool shouldRestart (int statusCode)
 
const std::list< int > & files () const
 

Public Attributes

const int32_t descriptor
 
const std::shared_ptr< const DobbyBundlebundle
 
const std::shared_ptr< const DobbyConfigconfig
 
const std::shared_ptr< const DobbyRootfsrootfs
 
const std::shared_ptr< const DobbyRdkPluginManagerrdkPluginManager
 
pid_t containerPid
 
bool hasCurseOfDeath
 
enum DobbyContainer::State state
 
std::string customConfigFilePath
 

Private Member Functions

 DobbyContainer (const std::shared_ptr< const DobbyBundle > &_bundle, const std::shared_ptr< const DobbyConfig > &_config, const std::shared_ptr< const DobbyRootfs > &_rootfs)
 
 DobbyContainer (const std::shared_ptr< const DobbyBundle > &_bundle, const std::shared_ptr< const DobbyConfig > &_config, const std::shared_ptr< const DobbyRootfs > &_rootfs, const std::shared_ptr< const DobbyRdkPluginManager > &_rdkPluginManager)
 

Static Private Member Functions

static int32_t allocDescriptor ()
 Alloc a unique descriptor from the pool. More...
 
static void freeDescriptor (int32_t cd)
 Frees a descriptor created with allocDescriptor. More...
 

Private Attributes

bool mRestartOnCrash
 
std::list< int > mFiles
 
unsigned mRestartCount
 
std::chrono::time_point< std::chrono::steady_clock > mLastRestartAttempt
 

Static Private Attributes

static std::mutex mIdsLock
 
static std::bitset< 1024 > mUsedIds
 

Friends

class DobbyManager
 

Detailed Description

Wrapper object used to store container resources.

This class stores the state of the container, along with it's config, bundle directory, rootfs and console resources.

In addition it stores the pid of the controller runc process managing the container, we need this to detect when the container has finially shutdown.

Lastly we also store a unique descriptor for the container, this is used alongside the container id string to identify events from a container.

See also
DobbyManager

Member Function Documentation

◆ allocDescriptor()

int32_t DobbyContainer::allocDescriptor ( )
staticprivate

Alloc a unique descriptor from the pool.

The descriptor will be a number between 1 and 1024, it will be unique in the sense that no existing Container object will have the same descriptor.

The descriptors themselves are created in a pseudo random repeating sequence, which should hopefully avoid getting the same descriptor number close together.

Returns
a unique descriptor number between 1 and 1024

◆ freeDescriptor()

void DobbyContainer::freeDescriptor ( int32_t  cd)
staticprivate

Frees a descriptor created with allocDescriptor.

This puts the given descriptor back in the pool for use again.

Parameters
[in]cdthe descriptor to release.

The documentation for this class was generated from the following files: