fix: make installer re-read partition table before formatting
This hopefully should fix errors like: ``` 2020/06/25 18:23:22 attaching loopback device 2020/06/25 18:23:22 partitioning /dev/loop2 - ESP 2020/06/25 18:23:22 partitioning /dev/loop2 - EPHEMERAL 2020/06/25 18:23:22 formatting partition "/dev/loop2p1" as "fat" with label "ESP" 2020/06/25 18:23:22 detaching loopback device 2020/06/25 18:23:22 failed to format device: exit status 1: mkfs.vfat: can't open '/dev/loop2p1': No such file or directory ``` Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
b20fcfd5d0
commit
197369bdc1
4
Makefile
4
Makefile
@ -139,13 +139,13 @@ talosctl-%:
|
||||
talosctl: $(TALOSCTL_DEFAULT_TARGET) ## Builds the talosctl binary for the local machine.
|
||||
|
||||
image-%: ## Builds the specified image. Valid options are aws, azure, digital-ocean, gcp, and vmware (e.g. image-aws)
|
||||
@docker run --rm -v /dev:/dev -v $(PWD)/$(ARTIFACTS):/out --privileged autonomy/installer:$(TAG) image --platform $*
|
||||
@docker run --rm -v /dev:/dev -v $(PWD)/$(ARTIFACTS):/out --privileged $(USERNAME)/installer:$(TAG) image --platform $*
|
||||
|
||||
images: image-aws image-azure image-digital-ocean image-gcp image-vmware ## Builds all known images (AWS, Azure, Digital Ocean, GCP, and VMware).
|
||||
|
||||
.PHONY: iso
|
||||
iso: ## Builds the ISO and outputs it to the artifact directory.
|
||||
@docker run --rm -i -v $(PWD)/$(ARTIFACTS):/out autonomy/installer:$(TAG) iso
|
||||
@docker run --rm -i -v $(PWD)/$(ARTIFACTS):/out $(USERNAME)/installer:$(TAG) iso
|
||||
|
||||
.PHONY: boot
|
||||
boot: ## Creates a compressed tarball that includes vmlinuz and initramfs.xz. Note that these files must already be present in the artifacts directory.
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/talos-systems/talos/pkg/blockdevice"
|
||||
@ -19,6 +21,7 @@ import (
|
||||
"github.com/talos-systems/talos/pkg/blockdevice/table/gpt/partition"
|
||||
"github.com/talos-systems/talos/pkg/blockdevice/util"
|
||||
"github.com/talos-systems/talos/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/retry"
|
||||
)
|
||||
|
||||
// Manifest represents the instructions for preparing all block devices
|
||||
@ -130,8 +133,28 @@ func (m *Manifest) ExecuteManifest() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if err = bd.RereadPartitionTable(); err != nil {
|
||||
log.Printf("failed to re-read partition table on %q: %s, ignoring error...", dev, err)
|
||||
}
|
||||
|
||||
for _, target := range targets {
|
||||
if err = target.Format(); err != nil {
|
||||
target := target
|
||||
|
||||
err = retry.Constant(time.Minute, retry.WithUnits(100*time.Millisecond)).Retry(func() error {
|
||||
e := target.Format()
|
||||
if e != nil {
|
||||
if strings.Contains(e.Error(), "No such file or directory") {
|
||||
// workaround problem with partition device not being visible immediately after partitioning
|
||||
return retry.ExpectedError(e)
|
||||
}
|
||||
|
||||
return retry.UnexpectedError(e)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to format device: %w", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user