Compare commits

...

12 Commits

Author SHA1 Message Date
lunardunno b8b3949f13 Increasing readability 2025-04-30 19:18:01 +04:00
lunardunno 5df579ae11 Merge branch 'dev' into exception-podman-docker 2025-04-23 22:02:04 +04:00
lunardunno 7169480999 feature: error handling for cgroup (#1486)
* Error for cgroup mountpoint

Added handling of message: cgroup mountpoint does not exist.

* Case for error cgroup

Added case and case description for: Cgroup Mountpoint Does Not Exist

* Case for Runc

Added error handling for Runc, which does not work in cgroup v2.
Changed numbering of new errors.

* stdErr handling fot run_container

Enabling stdErr handling fot run_container.sh

* change for stdErr handling

* Another place to handle the error 211

Another place to handle the error: ServerRuncNotWorkOnCgroupsV2

* test_1

* test 2

* test 3

* Moving error handling

Moving error handling to the right place in the controller.

* Polishing

* Еext correction

Сorrection of description text.
2025-04-23 12:12:23 +07:00
Mikhail Kiselev c44ce0d77c fix: add missing include (#1541) 2025-04-19 23:21:10 +07:00
lunardunno 5c494fa743 Checking docker status
Checking Docker activity.
Checking and changing locale.
Changing "command not found" handling for sh compatibility.
2025-04-07 14:16:07 +04:00
lunardunno 8331b9ea52 Fix error description
Fix error description for podman-docker.
Checking the docker version via sudo, for correct detection of podman-docker.
2025-04-07 07:26:17 +04:00
lunardunno ed1d67fcdf Exceptions for podman-docker
Exception: if podman-docker is already installed.
Skip update: if podman-docker might be installed during the update.
2025-04-07 07:04:41 +04:00
lunardunno ef39d66d46 Extended description of error
Added extended description for Error: ServerDockerNotSupported.
2025-04-07 05:29:52 +04:00
lunardunno 3ecb3a9f73 Extended description of error
Added extended description for Error: ServerDockerNotSupported.
2025-04-07 05:25:52 +04:00
lunardunno 79eeb36a97 Add error ServerDockerNotSupported 2025-04-07 05:10:21 +04:00
lunardunno 5dd644fd58 Added handling to serverController
Added "Docker is not supported" handling to serverController
2025-04-07 05:08:15 +04:00
lunardunno e2ca10d339 Exception: if installing is Podman.
Added a step to check the containerization package being installed.
2025-04-07 04:59:06 +04:00
5 changed files with 51 additions and 18 deletions
+17 -6
View File
@@ -409,7 +409,11 @@ ErrorCode ServerController::installDockerWorker(const ServerCredentials &credent
qDebug().noquote() << "ServerController::installDockerWorker" << stdOut;
if (stdOut.contains("lock"))
return ErrorCode::ServerPacketManagerError;
if (stdOut.contains("command not found"))
if (stdOut.contains("Podman is not supported"))
return ErrorCode::ServerPodmanIsNotSupported;
if (stdOut.contains("Status Docker is not active"))
return ErrorCode::ServerDockerStatusIsNotActive;
if (stdOut.contains("sudo:") && stdOut.contains("not found"))
return ErrorCode::ServerDockerFailedError;
return error;
@@ -439,15 +443,22 @@ ErrorCode ServerController::buildContainerWorker(const ServerCredentials &creden
stdOut += data + "\n";
return ErrorCode::NoError;
};
auto cbReadStdErr = [&](const QString &data, libssh::Client &) {
stdOut += data + "\n";
return ErrorCode::NoError;
};
errorCode =
ErrorCode error =
runScript(credentials,
replaceVars(amnezia::scriptData(SharedScriptType::build_container), genVarsForScript(credentials, container, config)),
cbReadStdOut);
if (errorCode)
return errorCode;
cbReadStdOut, cbReadStdErr);
if (stdOut.contains("doesn't work on cgroups v2"))
return ErrorCode::ServerDockerOnCgroupsV2;
if (stdOut.contains("cgroup mountpoint does not exist"))
return ErrorCode::ServerCgroupMountpoint;
return errorCode;
return error;
}
ErrorCode ServerController::runContainerWorker(const ServerCredentials &credentials, DockerContainer container, QJsonObject &config)
+4
View File
@@ -58,6 +58,10 @@ namespace amnezia
ServerUserDirectoryNotAccessible = 208,
ServerUserNotAllowedInSudoers = 209,
ServerUserPasswordRequired = 210,
ServerDockerOnCgroupsV2 = 211,
ServerCgroupMountpoint = 212,
ServerPodmanIsNotSupported = 213,
ServerDockerStatusIsNotActive = 214,
// Ssh connection errors
SshRequestDeniedError = 300,
+4
View File
@@ -26,6 +26,10 @@ QString errorString(ErrorCode code) {
case(ErrorCode::ServerUserDirectoryNotAccessible): errorMessage = QObject::tr("The server user's home directory is not accessible"); break;
case(ErrorCode::ServerUserNotAllowedInSudoers): errorMessage = QObject::tr("Action not allowed in sudoers"); break;
case(ErrorCode::ServerUserPasswordRequired): errorMessage = QObject::tr("The user's password is required"); break;
case(ErrorCode::ServerDockerOnCgroupsV2): errorMessage = QObject::tr("Docker error: runc doesn't work on cgroups v2"); break;
case(ErrorCode::ServerCgroupMountpoint): errorMessage = QObject::tr("Server error: cgroup mountpoint does not exist"); break;
case(ErrorCode::ServerPodmanIsNotSupported): errorMessage = QObject::tr("Server error: podman-docker is not supported"); break;
case(ErrorCode::ServerDockerStatusIsNotActive): errorMessage = QObject::tr("Server error: Docker status is not active"); break;
// Libssh errors
case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break;
+1
View File
@@ -6,6 +6,7 @@
#define INTERFACECONFIG_H
#include <QList>
#include <QMap>
#include <QString>
#include "ipaddress.h"
+25 -12
View File
@@ -1,23 +1,36 @@
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); silent_inst="-yq install"; check_pkgs="-yq update"; docker_pkg="docker.io"; dist="debian";\
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); silent_inst="-yq install"; check_pkgs="-yq check-update"; docker_pkg="docker"; dist="fedora";\
elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q install"; check_pkgs="-y -q check-update"; docker_pkg="docker"; dist="centos";\
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="-Sup"; docker_pkg="docker"; dist="archlinux";\
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); silent_inst="-yq install"; check_pkgs="-yq update"; what_pkg="-s install"; docker_pkg="docker.io"; dist="debian";\
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); silent_inst="-yq install"; check_pkgs="-yq check-update"; what_pkg="--assumeno install --setopt=tsflags=test"; docker_pkg="docker"; dist="fedora";\
elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q install"; check_pkgs="-y -q check-update"; what_pkg="--assumeno install --setopt=tsflags=test"; docker_pkg="docker"; dist="centos";\
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="-Sup"; what_pkg="-Sp"; docker_pkg="docker"; dist="archlinux";\
else echo "Packet manager not found"; exit 1; fi;\
echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, Docker pkg: $docker_pkg";\
echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, What pkg command: $what_pkg, Docker pkg: $docker_pkg";\
echo $LANG | grep -qE '^(en_US.UTF-8|C.UTF-8|C)$' || export LC_ALL=C;\
if [ "$dist" = "debian" ]; then export DEBIAN_FRONTEND=noninteractive; fi;\
if ! command -v sudo > /dev/null 2>&1; then $pm $check_pkgs; $pm $silent_inst sudo; fi;\
if ! command -v fuser > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst psmisc; fi;\
if ! command -v lsof > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst lsof; fi;\
if ! command -v docker > /dev/null 2>&1; then \
sudo $pm $check_pkgs; sudo $pm $silent_inst $docker_pkg;\
sudo $pm $check_pkgs;\
if [ -z "$(sudo $pm $what_pkg $docker_pkg 2>/dev/null | grep podman)" ]; then \
sudo $pm $silent_inst $docker_pkg;\
else echo "Podman is not supported"; exit 1;\
fi;\
sleep 5; sudo systemctl enable --now docker; sleep 5;\
fi;\
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = "Y" ]; then \
if ! command -v apparmor_parser > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst apparmor; fi;\
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = "Y" ] && ! command -v apparmor_parser > /dev/null 2>&1; then \
sudo $pm $check_pkgs; sudo $pm $silent_inst apparmor;\
fi;\
if [ "$(systemctl is-active docker)" != "active" ]; then \
sudo $pm $check_pkgs; sudo $pm $silent_inst $docker_pkg;\
sleep 5; sudo systemctl start docker; sleep 5;\
if [ -z "$(sudo docker --version 2>/dev/null | grep podman)" ]; then \
sudo $pm $check_pkgs;\
if [ -z "$(sudo $pm $what_pkg $docker_pkg 2>/dev/null | grep podman)" ]; then \
sudo $pm $silent_inst $docker_pkg;\
fi;\
sleep 5; sudo systemctl start docker; sleep 5;\
if [ "$(systemctl is-active docker)" != "active" ]; then \
echo "Status Docker is not active";\
fi;\
else echo "Podman is not supported";\
fi;\
fi;\
if ! command -v sudo > /dev/null 2>&1; then echo "Failed to install sudo, command not found"; exit 1; fi;\
docker --version
sudo docker --version