Skip to content

Commit

Permalink
Partial revert of "Toolkit: Add missing flock calls. (#10804)". (#1…
Browse files Browse the repository at this point in the history
…0917)

Reverting toolkit/imager changes in #10804. Leaving off the changes to image customizer to avoid conflicts with #10902,
  • Loading branch information
cwize1 authored Nov 1, 2024
1 parent 918bcf0 commit f52c8e6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions toolkit/tools/imagegen/diskutils/diskutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func CreatePartitions(diskDevPath string, disk configuration.Disk, rootEncryptio
return partDevPathMap, partIDToFsTypeMap, encryptedRoot, readOnlyRoot, err
}

partFsType, err := formatSinglePartition(diskDevPath, partDevPath, partition)
partFsType, err := FormatSinglePartition(partDevPath, partition)
if err != nil {
err = fmt.Errorf("failed to format partition:\n%w", err)
return partDevPathMap, partIDToFsTypeMap, encryptedRoot, readOnlyRoot, err
Expand Down Expand Up @@ -792,13 +792,12 @@ func setGptPartitionType(partition configuration.Partition, timeoutInSeconds, di
return
}

// formatSinglePartition formats the given partition to the type specified in the partition configuration
func formatSinglePartition(diskDevPath string, partDevPath string, partition configuration.Partition,
// FormatSinglePartition formats the given partition to the type specified in the partition configuration
func FormatSinglePartition(partDevPath string, partition configuration.Partition,
) (fsType string, err error) {
const (
totalAttempts = 5
retryDuration = time.Second
timeoutInSeconds = "5"
totalAttempts = 5
retryDuration = time.Second
)

fsType = partition.FsType
Expand All @@ -814,14 +813,14 @@ func formatSinglePartition(diskDevPath string, partDevPath string, partition con
fsType = "vfat"
}

mkfsArgs := []string{"--timeout", timeoutInSeconds, diskDevPath, "mkfs", "-t", fsType}
mkfsArgs := []string{"-t", fsType}
mkfsArgs = append(mkfsArgs, mkfsOptions...)
mkfsArgs = append(mkfsArgs, partDevPath)

err = retry.Run(func() error {
_, stderr, err := shell.Execute("flock", mkfsArgs...)
_, stderr, err := shell.Execute("mkfs", mkfsArgs...)
if err != nil {
logger.Log.Warnf("Failed to format partition using mkfs (and flock): %v", stderr)
logger.Log.Warnf("Failed to format partition using mkfs: %v", stderr)
return err
}

Expand Down

0 comments on commit f52c8e6

Please sign in to comment.