From f52c8e60cbae31d70ae3ccbb3b74a2fd6099ae7e Mon Sep 17 00:00:00 2001 From: Chris Gunn Date: Fri, 1 Nov 2024 13:58:19 -0700 Subject: [PATCH] Partial revert of "Toolkit: Add missing `flock` calls. (#10804)". (#10917) Reverting toolkit/imager changes in #10804. Leaving off the changes to image customizer to avoid conflicts with #10902, --- toolkit/tools/imagegen/diskutils/diskutils.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/toolkit/tools/imagegen/diskutils/diskutils.go b/toolkit/tools/imagegen/diskutils/diskutils.go index a19fb8e2d65..289b7d6eceb 100644 --- a/toolkit/tools/imagegen/diskutils/diskutils.go +++ b/toolkit/tools/imagegen/diskutils/diskutils.go @@ -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 @@ -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 @@ -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 }