Azure / Azure/WALinuxAgent

[BUG] swapfile size is incorrect if value is not integer multiple of 64M in ext4 filesystem

Open
#2,286 2 comments 0 reactions 1 assignee Claimed by @anhvoms View on GitHub
provisioning triaged
Dominant language
Python
Stars
581
Forks
397
Avg merge
2d 15h
Merged PRs (30d)
9

Description

**Describe the bug: A clear and concise description of what the bug is.**
In ext4 filesystem, if set the swapfile size as non-integer multiple of 64M(e.g. 1025), the actual swapfile size is 1024. The remaining sizes are not added.

**Distro and WALinuxAgent details (please complete the following information):**
- Distro and Version: RHEL-8
- WALinuxAgent version:
WALinuxAgent-2.3.0.2 running on redhat 8.5
Python: 3.6.8
Goal state agent: 2.3.0.2

**Additional context**
The log is:
```
2021-06-29T07:24:18.819616Z INFO Daemon Daemon Create swap file
2021-06-29T07:24:18.820073Z VERBOSE Daemon Daemon Command: [umask 0077 && dd if=/dev/zero bs=67108864 count=16 conv=notrunc of='/mnt/resource/swapfile']
2021-06-29T07:24:20.011228Z VERBOSE Daemon Daemon Command: [umask 0077 && dd if=/dev/zero bs=1048576 count=1 conv=notrunc of='/mnt/resource/swapfile']
```
If run these 2 commands manually, the second command cannot append the remain size to the swapfile.
```
[root@walaautowaf1 resource]# umask 0077 && dd if=/dev/zero bs=67108864 count=16 conv=notrunc of='/mnt/resource/swapfile1'
16+0 records in
16+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.04277 s, 1.0 GB/s
[root@walaautowaf1 resource]# ll swapfile1
-rw-------. 1 root root 1073741824 Jun 29 15:42 swapfile1
[root@walaautowaf1 resource]# umask 0077 && dd if=/dev/zero bs=1048576 count=1 conv=notrunc of='/mnt/resource/swapfile1'
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.000946101 s, 1.1 GB/s
[root@walaautowaf1 resource]# ll swapfile1
-rw-------. 1 root root 1073741824 Jun 29 15:42 swapfile1
```
https://github.com/Azure/WALinuxAgent/blob/aaa0b6fd7a034484f18e0cfb43488750a5fab694/azurelinuxagent/daemon/resourcedisk/default.py#L378

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.