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

rpm2img,release: conditionally create data fs based on part layout #2879

Merged
merged 2 commits into from
Mar 10, 2023

Conversation

etungsten
Copy link
Contributor

@etungsten etungsten commented Mar 10, 2023

Issue number:
N/A

Description of changes:

    rpm2img,release: conditionally create data fs based on part layout
    
    DATA-A partition in the "split" layout is too small to create an
    initial filesystem with desirable filesystem parameters. So we defer the
    filesystem creation to later at runtime with 'prepare-local-fs' after
    the partition gets resized to fill the disk/volume. This only needs to
    happen when DATA-B on the separate disk/volume is unavailable and we
    have additional space on the root disk/volume for DATA-A to grow.
    
    For "unified" layout, DATA-B does not exist since we only anticipate the
    root disk/volume and no other storage device. Therefore we can skip
    creating a filesystem for DATA-B.

    os: fix dependency ordering in 'has-boot-ever-succeeded'
    
    Fixes typos for the units in Before=

Testing done:

Normal storage device configuration for "split" layouts (2 GB root, 20 GB data)

Host comes up fine. prepare-local-fs doesn't run because the data part filesystem already exists:

bash-5.1# systemctl status label-data-a label-data-b prepare-local-fs local.mount repart-local
● label-data-a.service - Label data partition A
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/label-data-a.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:15:49 UTC; 3min 41s ago
   Main PID: 850 (code=killed, signal=ABRT)

Mar 10 21:15:48 localhost systemd[1]: Starting Label data partition A...
Mar 10 21:15:49 localhost systemd-repart[850]: Assertion 'amount <= total' failed at src/partition/repart.c:533, function charge_size(). Aborting.
Mar 10 21:15:49 localhost systemd[1]: Finished Label data partition A.

● label-data-b.service - Label data partition B
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/label-data-b.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:15:49 UTC; 3min 41s ago
   Main PID: 861 (code=exited, status=0/SUCCESS)

Mar 10 21:15:48 localhost systemd[1]: Starting Label data partition B...
Mar 10 21:15:49 localhost systemd-repart[861]: Applying changes.
Mar 10 21:15:49 localhost systemd-repart[861]: Storage does not support discard, not discarding gap at beginning of disk.
Mar 10 21:15:49 localhost systemd-repart[861]: Growing existing partition 0.
Mar 10 21:15:49 localhost systemd-repart[861]: Setting partition label of existing partition 0.
Mar 10 21:15:49 localhost systemd-repart[861]: Writing new partition table.
Mar 10 21:15:49 localhost systemd-repart[861]: Telling kernel to reread partition table.
Mar 10 21:15:49 localhost systemd-repart[861]: All done.
Mar 10 21:15:49 localhost systemd[1]: Finished Label data partition B.

● prepare-local-fs.service - Prepare Local Filesystem (/local)
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/prepare-local-fs.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:15:49 UTC; 3min 41s ago
   Main PID: 882 (code=exited, status=0/SUCCESS)

Mar 10 21:15:49 localhost systemd[1]: Starting Prepare Local Filesystem (/local)...
Mar 10 21:15:49 localhost systemd-makefs[882]: '/dev/disk/by-partlabel/BOTTLEROCKET-DATA' is not empty (contains file system of type ext4), exiting.
Mar 10 21:15:49 localhost systemd[1]: Finished Prepare Local Filesystem (/local).

● local.mount - Local Directory (/local)
     Loaded: loaded (/proc/self/mountinfo; enabled; vendor preset: enabled)
     Active: active (mounted) since Fri 2023-03-10 21:15:49 UTC; 3min 41s ago
      Until: Fri 2023-03-10 21:15:49 UTC; 3min 41s ago
      Where: /local
       What: /dev/nvme1n1p1
      Tasks: 0 (limit: 9265)
     Memory: 28.0K
     CGroup: /system.slice/local.mount

Mar 10 21:15:49 localhost systemd[1]: Mounting Local Directory (/local)...
Mar 10 21:15:49 localhost systemd[1]: Mounted Local Directory (/local).

● repart-local.service - Resize Data Partition
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/repart-local.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:15:49 UTC; 3min 41s ago
   Main PID: 890 (code=exited, status=0/SUCCESS)

Mar 10 21:15:49 localhost systemd[1]: Starting Resize Data Partition...
Mar 10 21:15:49 localhost systemd-repart[887]: No changes.
Mar 10 21:15:49 localhost systemd-growfs[890]: Successfully resized "/local" to 19.9G bytes.
Mar 10 21:15:49 localhost systemd[1]: Finished Resize Data Partition.

Data part filesystem parameters look normal:

bash-5.1# tune2fs -l /dev/nvme1n1p1                                                   
tune2fs 1.47.0 (5-Feb-2023)                                                           
Filesystem volume name:   <none>
Last mounted on:          /var                                                        
Filesystem UUID:          519a6a21-1dff-4641-96a9-a98b0760331b                                                                                                              
Filesystem magic number:  0xEF53                                                      
Filesystem revision #:    1 (dynamic)                                                 
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum                                                                          
Filesystem flags:         unsigned_directory_hash                                                                                                                           
Default mount options:    user_xattr acl                                              
Filesystem state:         clean
Errors behavior:          Continue      
Filesystem OS type:       Linux                                                       
Inode count:              1308160                                                     
Block count:              5242368                                                     
Reserved block count:     0
Overhead clusters:        87595
Free blocks:              5154767
Free inodes:              1308149
First block:              0           
Block size:               4096
Fragment size:            4096                                                        
Group descriptor size:    64                                                          
Reserved GDT blocks:      125
Blocks per group:         32768                                                       
Fragments per group:      32768                                                                                                                                             
Inodes per group:         8176                                                        
Inode blocks per group:   511                                                         
Flex block group size:    16
Filesystem created:       Fri Mar 10 21:14:05 2023                     
Last mount time:          Fri Mar 10 21:15:49 2023        
Last write time:          Fri Mar 10 21:15:49 2023                                                                                                                          
Mount count:              1                                                           
Maximum mount count:      -1            
Last checked:             Fri Mar 10 21:14:05 2023
Check interval:           0 (<none>)    
Lifetime writes:          533 kB                                                      
Reserved blocks uid:      0 (user root)                                               
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256    
Required extra isize:     32               
Desired extra isize:      32        
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      0b70b56f-1125-4bd4-b2dc-8c8c90d44993
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x5cc11926

Single 22 GB root EBS volume with "split" partition layout (data partition missing)

Host comes up fine. label-data-a runs and resizes/labels the data partition on the root volume as expected. prepare-local-fs creates the filesystem successfully:

bash-5.1# systemctl status label-data-a label-data-b prepare-local-fs local.mout repart-local
Unit local.mout.service could not be found.
● label-data-a.service - Label data partition A
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/label-data-a.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:17:52 UTC; 2min 44s ago
   Main PID: 821 (code=exited, status=0/SUCCESS)

Mar 10 21:17:52 localhost systemd[1]: Starting Label data partition A...
Mar 10 21:17:52 localhost systemd-repart[821]: Applying changes.
Mar 10 21:17:52 localhost systemd-repart[821]: Storage does not support discard, not discarding gap at beginning of disk.
Mar 10 21:17:52 localhost systemd-repart[821]: Growing existing partition 12.
Mar 10 21:17:52 localhost systemd-repart[821]: Setting partition label of existing partition 12.
Mar 10 21:17:52 localhost systemd-repart[821]: Writing new partition table.
Mar 10 21:17:52 localhost systemd-repart[821]: Telling kernel to reread partition table.
Mar 10 21:17:52 localhost systemd-repart[821]: All done.
Mar 10 21:17:52 localhost systemd[1]: Finished Label data partition A.

○ label-data-b.service - Label data partition B
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/label-data-b.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
  Condition: start condition failed at Fri 2023-03-10 21:19:22 UTC; 1min 14s ago
             └─ ConditionPathIsSymbolicLink=!/dev/disk/by-partlabel/BOTTLEROCKET-DATA was not met

Mar 10 21:19:22 ip-192-168-15-70.us-west-2.compute.internal systemd[1]: Label data partition B was skipped because of a failed condition check (ConditionPathIsSymbolicLink=!/dev/disk/by-partlabel/BOTTLEROCKET-DATA).

● prepare-local-fs.service - Prepare Local Filesystem (/local)
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/prepare-local-fs.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:17:52 UTC; 2min 43s ago
   Main PID: 851 (code=exited, status=0/SUCCESS)

Mar 10 21:17:52 localhost systemd[1]: Starting Prepare Local Filesystem (/local)...
Mar 10 21:17:52 localhost systemd-makefs[851]: /dev/disk/by-partlabel/BOTTLEROCKET-DATA successfully formatted as ext4 (label "BOTTLEROCKET-DAT", uuid 51562f76-61e1-4b6a-8907-b36cba11362e)
Mar 10 21:17:52 localhost systemd[1]: Finished Prepare Local Filesystem (/local).

● repart-local.service - Resize Data Partition
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/repart-local.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:17:53 UTC; 2min 43s ago
   Main PID: 894 (code=exited, status=0/SUCCESS)

Mar 10 21:17:53 localhost systemd[1]: Starting Resize Data Partition...
Mar 10 21:17:53 localhost systemd-repart[875]: No changes.
Mar 10 21:17:53 localhost systemd-growfs[894]: Successfully resized "/local" to 20.0G bytes.
Mar 10 21:17:53 localhost systemd[1]: Finished Resize Data Partition.

Filesystem parameters look normal and is mostly the same as DATA-B:

bash-5.1# tune2fs -l /dev/nvme0n1p13
tune2fs 1.47.0 (5-Feb-2023)
Filesystem volume name:   BOTTLEROCKET-DAT
Last mounted on:          /var
Filesystem UUID:          51562f76-61e1-4b6a-8907-b36cba11362e
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index orphan_file filetype needs_recovery extent 64bit flex_bg metadata_csum_seed sparse_super large_file huge_file dir_nlink extra_isize metadata_csum orphan_present
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              1313280
Block count:              5242880
Reserved block count:     0
Overhead clusters:        126476
Free blocks:              5115886
Free inodes:              1313268
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8208
Inode blocks per group:   513
Flex block group size:    16
Filesystem created:       Fri Mar 10 21:17:52 2023
Last mount time:          Fri Mar 10 21:17:53 2023
Last write time:          Fri Mar 10 21:17:53 2023
Mount count:              1
Maximum mount count:      -1
Last checked:             Fri Mar 10 21:17:52 2023
Check interval:           0 (<none>)
Lifetime writes:          6210 kB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      210a295e-3161-4d7a-9329-d988f82e80a4
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x76e08afd
Checksum seed:            0x2a877858
Orphan file inode:        12

"Unified" image layout

Host comes up fine. label-data-a runs and resizes/labels the data partition on the root volume as expected. prepare-local-fs creates the filesystem successfully:

bash-5.1# systemctl status label-data-a label-data-b prepare-local-fs local.mount repart-local
● label-data-a.service - Label data partition A
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/label-data-a.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:22:29 UTC; 3min 22s ago
   Main PID: 797 (code=exited, status=0/SUCCESS)

Mar 10 21:22:29 localhost systemd[1]: Starting Label data partition A...
Mar 10 21:22:29 localhost systemd-repart[797]: Applying changes.
Mar 10 21:22:29 localhost systemd-repart[797]: Storage does not support discard, not discarding gap at beginning of disk.
Mar 10 21:22:29 localhost systemd-repart[797]: Growing existing partition 12.
Mar 10 21:22:29 localhost systemd-repart[797]: Setting partition label of existing partition 12.
Mar 10 21:22:29 localhost systemd-repart[797]: Writing new partition table.
Mar 10 21:22:29 localhost systemd-repart[797]: Telling kernel to reread partition table.
Mar 10 21:22:29 localhost systemd-repart[797]: All done.
Mar 10 21:22:29 localhost systemd[1]: Finished Label data partition A.

○ label-data-b.service - Label data partition B
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/label-data-b.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
  Condition: start condition failed at Fri 2023-03-10 21:23:58 UTC; 1min 53s ago
             └─ ConditionPathIsSymbolicLink=!/dev/disk/by-partlabel/BOTTLEROCKET-DATA was not met

Mar 10 21:23:58 ip-192-168-29-170.us-west-2.compute.internal systemd[1]: Label data partition B was skipped because of a failed condition check (ConditionPathIsSymbolicLink=!/dev/disk/by-partlabel/BOTTLEROCKET-DATA).

● prepare-local-fs.service - Prepare Local Filesystem (/local)
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/prepare-local-fs.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:22:29 UTC; 3min 22s ago
   Main PID: 850 (code=exited, status=0/SUCCESS)

Mar 10 21:22:29 localhost systemd[1]: Starting Prepare Local Filesystem (/local)...
Mar 10 21:22:29 localhost systemd-makefs[850]: '/dev/disk/by-partlabel/BOTTLEROCKET-DATA' is not empty (contains file system of type ext4), exiting.
Mar 10 21:22:29 localhost systemd[1]: Finished Prepare Local Filesystem (/local).

● local.mount - Local Directory (/local)
     Loaded: loaded (/proc/self/mountinfo; enabled; vendor preset: enabled)
     Active: active (mounted) since Fri 2023-03-10 21:22:29 UTC; 3min 22s ago
      Until: Fri 2023-03-10 21:22:29 UTC; 3min 22s ago
      Where: /local
       What: /dev/nvme0n1p13
      Tasks: 0 (limit: 9265)
     Memory: 28.0K
     CGroup: /system.slice/local.mount

Mar 10 21:22:29 localhost systemd[1]: Mounting Local Directory (/local)...
Mar 10 21:22:29 localhost systemd[1]: Mounted Local Directory (/local).

● repart-local.service - Resize Data Partition
     Loaded: loaded (/x86_64-bottlerocket-linux-gnu/sys-root/usr/lib/systemd/system/repart-local.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2023-03-10 21:22:29 UTC; 3min 22s ago
   Main PID: 886 (code=exited, status=0/SUCCESS)

Mar 10 21:22:29 localhost systemd[1]: Starting Resize Data Partition...
Mar 10 21:22:29 localhost systemd-repart[867]: No changes.
Mar 10 21:22:29 localhost systemd[1]: Finished Resize Data Partition.

Filesystem parameters look normal:

bash-5.1# tune2fs -l /dev/nvme0n1p13
tune2fs 1.47.0 (5-Feb-2023)
Filesystem volume name:   <none>
Last mounted on:          /var
Filesystem UUID:          c6a2a24e-be4a-421a-a6ed-1b6a68ca1492
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         unsigned_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              1310720
Block count:              5242880
Reserved block count:     0
Overhead clusters:        91851
Free blocks:              5151023
Free inodes:              1310709
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      125
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Fri Mar 10 21:18:43 2023
Last mount time:          Fri Mar 10 21:22:29 2023
Last write time:          Fri Mar 10 21:22:29 2023
Mount count:              1
Maximum mount count:      -1
Last checked:             Fri Mar 10 21:18:43 2023
Check interval:           0 (<none>)
Lifetime writes:          533 kB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      f2a7253f-ae75-4cb6-994a-9f8cfd55ecd1
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x8b4541be

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Fixes typos for the units in Before=
@etungsten etungsten requested a review from bcressey March 10, 2023 19:49
@etungsten etungsten marked this pull request as draft March 10, 2023 20:03
@etungsten etungsten force-pushed the iunnode branch 2 times, most recently from bd73ed3 to 5df9a30 Compare March 10, 2023 20:37
packages/release/prepare-local-fs.service Outdated Show resolved Hide resolved
packages/release/prepare-local-fs.service Outdated Show resolved Hide resolved
packages/release/prepare-local-fs.service Outdated Show resolved Hide resolved
tools/rpm2img Outdated Show resolved Hide resolved
tools/rpm2img Outdated Show resolved Hide resolved
tools/rpm2img Outdated Show resolved Hide resolved
@etungsten etungsten changed the title rpm2img,release: move fs creation for DATA-A to at runtime + other misc rpm2img,release: move fs creation for DATA-A to at runtime Mar 10, 2023
DATA-A partition in the "split" layout is too small to create an
initial filesystem with desirable filesystem parameters. So we defer the
filesystem creation to later at runtime with 'prepare-local-fs' after
the partition gets resized to fill the disk/volume. This only needs to
happen when DATA-B on the separate disk/volume is unavailable and we
have additional space on the root disk/volume for DATA-A to grow.

For "unified" layout, DATA-B does not exist since we only anticipate the
root disk/volume and no other storage device. Therefore we can skip
creating a filesystem for DATA-B.
@etungsten etungsten changed the title rpm2img,release: move fs creation for DATA-A to at runtime rpm2img,release: conditionally create data fs based on part layout Mar 10, 2023
@etungsten etungsten marked this pull request as ready for review March 10, 2023 21:26
@etungsten
Copy link
Contributor Author

Push above addresses @bcressey 's comments. Tested changes and update PR description with results.

@etungsten etungsten merged commit 8b08f1b into bottlerocket-os:develop Mar 10, 2023
@etungsten etungsten deleted the iunnode branch March 10, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants