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
DobbyLogger Class Reference

Public Member Functions

 DobbyLogger (const std::shared_ptr< const IDobbySettings > &settings)
 
bool StartContainerLogging (std::string containerId, pid_t runtimePid, pid_t containerPid, std::shared_ptr< IDobbyRdkLoggingPlugin > loggingPlugin)
 Public method that should be called once a container has been created to match the container PID with the runtime PID to start running the logging thread based on whichever logging plugin is loaded. More...
 
bool DumpBuffer (int bufferMemFd, pid_t containerPid, std::shared_ptr< IDobbyRdkLoggingPlugin > loggingPlugin)
 Blocking method that writes the contents of a buffer at a given memFd to the logger specified in the container config. More...
 

Private Member Functions

int createDgramSocket (const std::string &path)
 
int createUnixSocket (const std::string path)
 Create a new UNIX domain socket that the OCI runtime can connect to and send the fd of the ptty used for the container. More...
 
int receiveFdFromSocket (const int connectionFd)
 Once a connection to the socket has been made, wait to receive a message that contains a file descriptor. More...
 
void connectionMonitorThread (const int socketFd)
 Runs for the lifetime of the daemon, waiting for new connections to the socket. Once a connection is received, add to the map. More...
 
void closeAndDeleteSocket (const int fd, const std::string &path)
 Closes and deletes a socket at a given fd/path.
 

Private Attributes

std::mutex mLock
 
int mSocketFd
 
const std::string mSocketPath
 
const std::string mSyslogSocketPath
 
const std::string mJournaldSocketPath
 
std::map< pid_t, int > mTempFds
 
std::shared_ptr< AICommon::PollLoopmPollLoop
 
std::shared_ptr< DobbyLogRelaymSyslogRelay
 
std::shared_ptr< DobbyLogRelaymJournaldRelay
 

Member Function Documentation

◆ connectionMonitorThread()

void DobbyLogger::connectionMonitorThread ( const int  socketFd)
private

Runs for the lifetime of the daemon, waiting for new connections to the socket. Once a connection is received, add to the map.

Parameters
[in]socketFdFD of the socket passed to the runtime –console-socket param

◆ createUnixSocket()

int DobbyLogger::createUnixSocket ( const std::string  path)
private

Create a new UNIX domain socket that the OCI runtime can connect to and send the fd of the ptty used for the container.

Parameters
[in]pathWhere to create the socket

◆ DumpBuffer()

bool DobbyLogger::DumpBuffer ( int  bufferMemFd,
pid_t  containerPid,
std::shared_ptr< IDobbyRdkLoggingPlugin loggingPlugin 
)

Blocking method that writes the contents of a buffer at a given memFd to the logger specified in the container config.

Mainly used for writing the contents of the OCI hooks stdout/err to the container logfile

Parameters
[in]bufferMemFdfd of the buffer
[in]containerPidPID of the container the logs belong to
[in]loggingPluingThe logging plugin the contents of the buffer should be sent to

◆ receiveFdFromSocket()

int DobbyLogger::receiveFdFromSocket ( const int  connectionFd)
private

Once a connection to the socket has been made, wait to receive a message that contains a file descriptor.

Parameters
[in]connectionFdfd of the connection to the Dobby logging socket

◆ StartContainerLogging()

bool DobbyLogger::StartContainerLogging ( std::string  containerId,
pid_t  runtimePid,
pid_t  containerPid,
std::shared_ptr< IDobbyRdkLoggingPlugin loggingPlugin 
)

Public method that should be called once a container has been created to match the container PID with the runtime PID to start running the logging thread based on whichever logging plugin is loaded.

Parameters
[in]containerIdName of the container
[in]runtimePidPID of the OCI runtime that connected to the socket
[in]containerPidPID of the running container
[in]loggingPluginPlugin that will process the container logs
Returns
True if thread started successfully

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