Skip to content

Commit

Permalink
setup: replace OS-provided conmon tool (fix podman issue)
Browse files Browse the repository at this point in the history
"conmon" is a binary started withing podman containers.
The version provided with bullseye has a serious issue sometimes
causing the output of "podman [run|exec]" to be truncated.
containers/podman#9096

We replace this binary with a more up-to-date version statically
compiled using the nix method.
https://github.com/containers/conmon#nix
(note: nix compilation is very long.)
  • Loading branch information
eduble committed Jul 5, 2022
1 parent c82ebde commit 3389860
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions server/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ include walt/server/processes/main/images/walt-*
include walt/server/processes/main/network/walt-*.kpxe
include walt/server/processes/main/vpn-proxy-setup.sh
include walt/server/setup/*.service
include walt/server/setup/conmon.gz
include walt/server/processes/blocking/snmp/mibs/*.mib
Binary file added server/walt/server/setup/conmon.gz
Binary file not shown.
29 changes: 28 additions & 1 deletion server/walt/server/setup/ossetup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import shlex, datetime, requests, subprocess, json, sys
import shlex, datetime, requests, subprocess, json, sys, gzip
from pathlib import Path
from pkg_resources import resource_filename
from walt.common.version import __version__ as WALT_VERSION
from walt.server.setup.pip import install_pip, pip
from walt.server.setup.apt import fix_dpkg_options, package_is_installed, get_debconf_selection, \
Expand Down Expand Up @@ -203,3 +204,29 @@ def install_os_on_image():
fix_docker_keyring()
fix_dpkg_options()
fix_packets(upgrade_packets = True) # have up-to-date packets on image

def has_diversion(path):
diversion = subprocess.run(f'dpkg-divert --list {path}'.split(),
stdout=subprocess.PIPE).stdout.strip()
return len(diversion) > 0

def divert(path, diverted_path):
subprocess.run(f'dpkg-divert --divert {diverted_path} --rename {path}'.split(),
check=True, stdout=subprocess.PIPE)

# 'conmon' binary distributed in bullseye has a serious issue
# causing possibly truncated stdout in podman [run|exec]).
# we replace it with a more up-to-date binary statically compiled
# using the nix-based method.
def fix_conmon():
if not has_diversion('/usr/bin/conmon'):
print('Fixing issue with conmon tool... ', end=''); sys.stdout.flush()
divert('/usr/bin/conmon', '/usr/bin/conmon.distrib')
conmon_gz_path = resource_filename(__name__, 'conmon.gz')
conmon_gz_content = Path(conmon_gz_path).read_bytes()
conmon_content = gzip.decompress(conmon_gz_content)
conmon_fixed_path = Path('/usr/bin/conmon.fixed')
conmon_fixed_path.write_bytes(conmon_content)
conmon_fixed_path.chmod(0o755)
print('done')
Path('/usr/bin/conmon').symlink_to('/usr/bin/conmon.fixed')
13 changes: 8 additions & 5 deletions server/walt/server/setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from walt.common import systemd
from walt.common.setup import WaltGenericSetup
from walt.common.tools import verify_root_login_shell
from walt.server.setup.ossetup import get_os_codename, upgrade_os, install_os, fix_os, install_os_on_image
from walt.server.setup.ossetup import get_os_codename, upgrade_os, install_os, fix_os, fix_conmon, install_os_on_image
from walt.server.setup.conf import fix_other_conf_files, setup_default_server_conf, ask_server_conf

WALT_SERVICES = [
Expand All @@ -29,18 +29,18 @@

OS_ACTIONS = {
'image-install': {
'bullseye': ('install_os_on_image', 'disable_os_services', 'setup_walt_services',
'bullseye': ('install_os_on_image', 'fix_conmon', 'disable_os_services', 'setup_walt_services',
'fix_other_conf_files', 'setup_default_server_conf', 'update_completion'),
},
'install': {
'bullseye': ('install_os', 'disable_os_services', 'setup_walt_services',
'bullseye': ('install_os', 'fix_conmon', 'disable_os_services', 'setup_walt_services',
'fix_other_conf_files', 'ask_server_conf', 'systemd_reload',
'start_walt_services', 'update_completion', 'msg_ready'),
},
'upgrade': {
'buster': ('stop_services', 'upgrade_os', 'disable_os_services', 'setup_walt_services',
'buster': ('stop_services', 'upgrade_os', 'fix_conmon', 'disable_os_services', 'setup_walt_services',
'fix_other_conf_files', 'update_completion', 'msg_reboot'),
'bullseye': ('stop_services', 'fix_os', 'disable_os_services', 'setup_walt_services',
'bullseye': ('stop_services', 'fix_os', 'fix_conmon', 'disable_os_services', 'setup_walt_services',
'fix_other_conf_files', 'may_ask_server_conf', 'systemd_reload', 'start_walt_services',
'update_completion', 'msg_ready'),
}
Expand Down Expand Up @@ -135,6 +135,9 @@ def install_os(self):
def fix_os(self):
fix_os()

def fix_conmon(self):
fix_conmon()

def install_os_on_image(self):
install_os_on_image()

Expand Down

0 comments on commit 3389860

Please sign in to comment.