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

Dobby Patch Release v3.10.2 #330

Merged
merged 8 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ cmake_minimum_required( VERSION 3.7.0 )
include(GNUInstallDirs)

# Project setup
project( Dobby VERSION "3.10.1" )
project( Dobby VERSION "3.10.2" )


# Set the major and minor version numbers of dobby (also used by plugins)
set( DOBBY_MAJOR_VERSION 3 )
set( DOBBY_MINOR_VERSION 10 )
set( DOBBY_MICRO_VERSION 1 )
set( DOBBY_MICRO_VERSION 2 )

set(INSTALL_CMAKE_DIR lib/cmake/Dobby)

Expand Down
13 changes: 9 additions & 4 deletions daemon/lib/source/DobbyHibernate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ typedef enum {
typedef enum {
MEMCR_OK = 0,
MEMCR_ERROR = -1,
MEMCR_INVALID_PID = -2
MEMCR_INVALID_PID = -2,
MEMCR_SOCKET_READ_ERROR = -3
} ServerResponseCode;

typedef struct {
Expand Down Expand Up @@ -142,7 +143,6 @@ static bool SendRcvCmd(const ServerRequest* cmd, ServerResponse* resp, uint32_t
AI_LOG_FN_ENTRY();
int cd;
int ret;
struct sockaddr_in addr = { 0 };
resp->respCode = MEMCR_ERROR;

cd = Connect(serverLocator, timeoutMs);
Expand All @@ -154,15 +154,16 @@ static bool SendRcvCmd(const ServerRequest* cmd, ServerResponse* resp, uint32_t

ret = write(cd, cmd, sizeof(ServerRequest));
if (ret != sizeof(ServerRequest)) {
AI_LOG_ERROR("Socket write failed: ret %d", ret);
AI_LOG_ERROR("Socket write failed: ret %d, %m", ret);
close(cd);
AI_LOG_FN_EXIT();
return false;
}

ret = read(cd, resp, sizeof(ServerResponse));
if (ret != sizeof(ServerResponse)) {
AI_LOG_ERROR("Socket read failed: ret %d", ret);
AI_LOG_ERROR("Socket read failed: ret %d, %m", ret);
resp->respCode = MEMCR_SOCKET_READ_ERROR;
close(cd);
AI_LOG_FN_EXIT();
return false;
Expand All @@ -188,6 +189,10 @@ DobbyHibernate::Error DobbyHibernate::HibernateProcess(const pid_t pid, const ui
AI_LOG_INFO("Hibernate process PID %d success", pid);
AI_LOG_FN_EXIT();
return DobbyHibernate::Error::ErrorNone;
} else if (resp.respCode == MEMCR_SOCKET_READ_ERROR) {
AI_LOG_WARN("Error Hibernate timeout process PID %d ret %d", pid, resp.respCode);
AI_LOG_FN_EXIT();
return DobbyHibernate::Error::ErrorTimeout;
} else {
AI_LOG_WARN("Error Hibernate process PID %d ret %d", pid, resp.respCode);
AI_LOG_FN_EXIT();
Expand Down
3 changes: 2 additions & 1 deletion daemon/lib/source/DobbyHibernate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class DobbyHibernate
enum Error
{
ErrorNone = 0,
ErrorGeneral = 1
ErrorGeneral = 1,
ErrorTimeout = 2
};

enum CompressionAlg
Expand Down
31 changes: 2 additions & 29 deletions daemon/lib/source/DobbyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1566,35 +1566,7 @@ bool DobbyManager::hibernateContainer(int32_t cd, const std::string& options)
std::thread hibernateThread =
std::thread([=]()
{
//TODO: --delay support is temporary and should be removed
int delayMs = 0;
size_t delayMsPos = options.find("--delay=");
if (delayMsPos != std::string::npos)
{
delayMs = std::stoi(&options[delayMsPos + std::string("--delay=").length()], nullptr, 10);
}
DobbyHibernate::Error ret = DobbyHibernate::Error::ErrorNone;

int delayChunkMs = 100;
while (delayMs > 0)
{
int sleepTime = delayMs > delayChunkMs? delayChunkMs : delayMs;
delayMs -= sleepTime;
std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
{
std::lock_guard<std::mutex> locker(mLock);
if (mContainers.find(id) == mContainers.end() ||
mContainers[id]->descriptor != cd ||
mContainers[id]->state != DobbyContainer::State::Hibernating)
{
AI_LOG_WARN("Hibernation of: %s with descriptor %d aborted", id.c_str(), cd);
AI_LOG_FN_EXIT();
return;
}
}
}
//TODO: --delay support end

// create a stats object for the container to get list of PIDs
std::unique_lock<std::mutex> locker(mLock);
DobbyStats stats(it->first, mEnvironment, mUtilities);
Expand All @@ -1619,7 +1591,8 @@ bool DobbyManager::hibernateContainer(int32_t cd, const std::string& options)
if (ret != DobbyHibernate::Error::ErrorNone)
{
AI_LOG_WARN("Error hibernating pid: '%d'", pid);
// revert previous Hibernations and break
// try to revert current and previous Hibernations and break
DobbyHibernate::WakeupProcess(pid);
while (pidIt != jsonPids.begin())
{
--pidIt;
Expand Down
16 changes: 9 additions & 7 deletions daemon/process/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ else()
endif()
endif()

message("Using settings from ${DOBBY_SETTINGS_FILE}")

install(
FILES "${DOBBY_SETTINGS_FILE}"
RENAME dobby.json
DESTINATION /etc/ )

if ( "${DOBBY_SETTINGS_FILE}" STREQUAL "DONT_INSTALL_DEVICESETTINGSFILE" )
message("Skipping the installation of device settings file")
else()
message("Using settings from ${DOBBY_SETTINGS_FILE}")
install(
FILES "${DOBBY_SETTINGS_FILE}"
RENAME dobby.json
DESTINATION /etc/ )
endif()

if (USE_SYSTEMD)
# Install a systemd launch service config and enables it by default
Expand Down
Loading