Skip to content

Commit

Permalink
Revert "pre-allocate swapfile while building image"
Browse files Browse the repository at this point in the history
This reverts commit 069318b.

Related with #491, we need to reduce snapshot size of the rootfs, we
should not pre-allocate swapfile while building image.
  • Loading branch information
syuu1228 authored and yaronkaikov committed Dec 20, 2023
1 parent d980383 commit 26b93d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 10 additions & 3 deletions common/scylla_image_setup
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ from lib.scylla_cloud import get_cloud_instance, is_gce, is_azure, is_redhat_var
from subprocess import run

if __name__ == '__main__':
if is_azure() and not Path('/mnt/swapfile').exists():
Path('/etc/systemd/system/mnt-swapfile.swap').unlink(missing_ok=True)
run('/opt/scylladb/scripts/scylla_swap_setup --swap-directory /mnt', shell=True, check=True)
if is_azure():
swap_directory = Path('/mnt')
swap_unit = Path('/etc/systemd/system/mnt-swapfile.swap')
else:
swap_directory = Path('/')
swap_unit = Path('/etc/systemd/system/swapfile.swap')
swapfile = swap_directory / 'swapfile'
if not swapfile.exists():
swap_unit.unlink(missing_ok=True)
run(f'/opt/scylladb/scripts/scylla_swap_setup --swap-directory {swap_directory}', shell=True, check=True)
machine_image_configured = Path('/etc/scylla/machine_image_configured')
if not machine_image_configured.exists():
# On Ubuntu, we configure CPU scaling while AMI building time
Expand Down
6 changes: 0 additions & 6 deletions packer/scylla_install_image
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def deb_arch():
darch={'x86_64': 'amd64', 'aarch64': 'arm64'}
return darch[arch()]

def half_of_diskfree():
disk = os.statvfs('/')
return int((disk.f_bavail * disk.f_frsize) / 2)

if __name__ == '__main__':
if os.getuid() > 0:
print('Requires root permission.')
Expand Down Expand Up @@ -144,8 +140,6 @@ if __name__ == '__main__':
run('/opt/scylladb/scripts/scylla_cpuscaling_setup --force', shell=True, check=True)

run(f'/opt/scylladb/scripts/scylla_sysconfig_setup --set-clocksource', shell=True, check=True)
if args.target_cloud == 'aws' or args.target_cloud == 'gce':
run(f'/opt/scylladb/scripts/scylla_swap_setup --swap-size-bytes {half_of_diskfree()} --swap-directory /', shell=True, check=True)
run('/opt/scylladb/scripts/scylla_coredump_setup', shell=True, check=True)
dot_mount = '''
[Unit]
Expand Down

0 comments on commit 26b93d5

Please sign in to comment.