pkg/extend fix panic for empty partition tables (#4101)

Signed-off-by: Chris Irrgang <chris.irrgang@gmx.de>
This commit is contained in:
Chris Irrgang 2025-01-30 14:55:14 +01:00 committed by GitHub
parent 66ca00915a
commit 7ac34a6aec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 4 deletions

View File

@ -82,6 +82,11 @@ func extend(d, fsType string) error {
return fmt.Errorf("Unable to unmarshal partition table from sfdisk: %v", err) return fmt.Errorf("Unable to unmarshal partition table from sfdisk: %v", err)
} }
if len(f.PartitionTable.Partitions) == 0 {
log.Printf("Disk %s has no partitions. Skipping", d)
return nil
}
if len(f.PartitionTable.Partitions) > 1 { if len(f.PartitionTable.Partitions) > 1 {
log.Printf("Disk %s has more than 1 partition. Skipping", d) log.Printf("Disk %s has more than 1 partition. Skipping", d)
return nil return nil

View File

@ -6,7 +6,7 @@ init:
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab - linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
onboot: onboot:
- name: extend - name: extend
image: linuxkit/extend:9fa90cc4ba8c261b8eb5adacda71feb2f60d75e3 image: linuxkit/extend:4fe799316df0f29a6930a5363841057d7c55484b
- name: mount - name: mount
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5 image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
command: ["/usr/bin/mountie", "/var/lib/docker"] command: ["/usr/bin/mountie", "/var/lib/docker"]

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/modprobe:fad39ef443853ef02520052cdbf6acbeb4ec7799 image: linuxkit/modprobe:fad39ef443853ef02520052cdbf6acbeb4ec7799
command: ["modprobe", "btrfs"] command: ["modprobe", "btrfs"]
- name: extend - name: extend
image: linuxkit/extend:9fa90cc4ba8c261b8eb5adacda71feb2f60d75e3 image: linuxkit/extend:4fe799316df0f29a6930a5363841057d7c55484b
command: ["/usr/bin/extend", "-type", "btrfs"] command: ["/usr/bin/extend", "-type", "btrfs"]
- name: mount - name: mount
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5 image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5

View File

@ -6,7 +6,7 @@ init:
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab - linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
onboot: onboot:
- name: extend - name: extend
image: linuxkit/extend:9fa90cc4ba8c261b8eb5adacda71feb2f60d75e3 image: linuxkit/extend:4fe799316df0f29a6930a5363841057d7c55484b
command: ["/usr/bin/extend", "-type", "xfs"] command: ["/usr/bin/extend", "-type", "xfs"]
- name: mount - name: mount
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5 image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5

View File

@ -6,7 +6,7 @@ init:
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab - linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
onboot: onboot:
- name: extend - name: extend
image: linuxkit/extend:9fa90cc4ba8c261b8eb5adacda71feb2f60d75e3 image: linuxkit/extend:4fe799316df0f29a6930a5363841057d7c55484b
- name: mount - name: mount
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5 image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
command: ["/usr/bin/mountie", "/var/lib/docker"] command: ["/usr/bin/mountie", "/var/lib/docker"]