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

Plugin library that create a DIAG logging pipe for a container. More...

#include <EthanLogPlugin.h>

Inheritance diagram for EthanLogPlugin:
Inheritance graph
[legend]
Collaboration diagram for EthanLogPlugin:
Collaboration graph
[legend]

Public Member Functions

 EthanLogPlugin (const std::shared_ptr< IDobbyEnv > &env, const std::shared_ptr< IDobbyUtils > &utils)
 
std::string name () const final
 Boilerplate that just returns the name of the hook. More...
 
unsigned hookHints () const final
 Indicates which hook points we want and whether to run the asynchronously or synchronously with the other hooks. More...
 
bool postConstruction (const ContainerId &id, const std::shared_ptr< IDobbyStartState > &startupState, const std::string &rootfsPath, const Json::Value &jsonData) final
 We hook the postConstruction point to create a logging pipe for the container which we then given to the init process of the container. More...
 
bool preStart (const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData) final
 We hook the preStart point so we can tell the EthanLog code the base pid of the container. More...
 
- Public Member Functions inherited from PluginBase
virtual bool postStart (const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called after the container is started and the init process is now running. More...
 
virtual bool postStop (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called after the container has stopped. More...
 
virtual bool preDestruction (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called just before the rootfs is deleted, this is called even if there was an error starting the container. More...
 

Private Member Functions

unsigned parseLogLevels (const Json::Value &jsonArray) const
 Parses the supplied json array and returns a bitmask of the log levels. More...
 

Private Attributes

const std::string mName
 
const std::shared_ptr< IDobbyUtilsmUtilities
 
const std::shared_ptr< EthanLogLoopmLogLoop
 
const unsigned mDefaultLogLevelsMask
 
int mDevNullFd
 

Additional Inherited Members

- Public Types inherited from IDobbyPlugin
enum  HintFlags : unsigned {
  PostConstructionSync = (1 << 0) , PreStartSync = (1 << 1) , PostStartSync = (1 << 2) , PostStopSync = (1 << 3) ,
  PreDestructionSync = (1 << 4) , PostConstructionAsync = (1 << 16) , PreStartAsync = (1 << 17) , PostStartAsync = (1 << 18) ,
  PostStopAsync = (1 << 19) , PreDestructionAsync = (1 << 20)
}
 Bit flags that should be returned by hookHints. More...
 

Detailed Description

Plugin library that create a DIAG logging pipe for a container.

This plugin uses the IPC / DBUS fusion interface to request a new logging pipe from APP_Process (the AI AppLogger component). The write end of the pipe file descriptor is then inserted into the container and an environment variable is set with the number of the fd.

Member Function Documentation

◆ hookHints()

unsigned EthanLogPlugin::hookHints ( ) const
finalvirtual

Indicates which hook points we want and whether to run the asynchronously or synchronously with the other hooks.

For this plugin everything is done in the postConstruction and preStart hooks and synchronously with any other plugins / hooks.

Implements IDobbyPlugin.

◆ name()

std::string EthanLogPlugin::name ( ) const
finalvirtual

Boilerplate that just returns the name of the hook.

This string needs to match the name specified in the container spec json.

Implements IDobbyPlugin.

◆ parseLogLevels()

unsigned EthanLogPlugin::parseLogLevels ( const Json::Value &  jsonArray) const
private

Parses the supplied json array and returns a bitmask of the log levels.

The json object should be an array of strings which may contain any of the following strings

"default", "fatal", "error", "warning", "info", "debug", "milestone"
Parameters
[in]jsonArrayThe json array object
Returns
the bitmask of log levels, maybe 0 if the array was empty.

◆ postConstruction()

bool EthanLogPlugin::postConstruction ( const ContainerId id,
const std::shared_ptr< IDobbyStartState > &  startupState,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
finalvirtual

We hook the postConstruction point to create a logging pipe for the container which we then given to the init process of the container.

The json for the plugin data should be formatted like so

{
    "name" : "SomeApp",
    "loglevels" : [ "fatal", "milestone", "info", "debug" ],
    "rateLimit" { "rate": 1234, "burstSize": 12345 }
}
Parameters
[in]idThe id of the container
[in]startupStateThe startup state of the container (ignored)
[in]rootfsPathThe absolute path to the rootfs of the container
[in]jsonDataThe json data from the spec file (ignored)
Returns
true if the hardlink ws created, otherwise false.

Reimplemented from PluginBase.

◆ preStart()

bool EthanLogPlugin::preStart ( const ContainerId id,
pid_t  pid,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
finalvirtual

We hook the preStart point so we can tell the EthanLog code the base pid of the container.

We need this because the logging library reports it's own pid and that is relative to it's own pid namespace.

Parameters
[in]idThe id of the container
[in]pidThe pid of the init process inside the container
[in]rootfsPathThe absolute path to the rootfs of the container
[in]jsonDataThe json data from the spec file (ignored)
Returns
Always return true.

Reimplemented from PluginBase.


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