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

Revert "pre-allocate swapfile while building image" #493

Merged
merged 1 commit into from
Dec 20, 2023
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
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