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

losetup --show -f -P images/... error different of partitions than expected 1 #165

Open
thomastthai opened this issue Nov 7, 2023 · 0 comments

Comments

@thomastthai
Copy link

thomastthai commented Nov 7, 2023

Overview of the Issue

When building with packer, I sometimes get the error error different of partitions than expected 1. This would happen randomly on additional runs of the same build that was previously successful and no changes made.

==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Image type: raspberrypi
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Retrieving Image
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Trying images/rpi-k3s-base-raspios-bookworm-armhf.img.gz
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Trying images/rpi-k3s-base-raspios-bookworm-armhf.img.gz?checksum=sha256%3A893a637a3d447974255a25242818ca66e5b37b31029488017f184cdb13a5e59c
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: images/rpi-k3s-base-raspios-bookworm-armhf.img.gz?checksum=sha256%3A893a637a3d447974255a25242818ca66e5b37b31029488017f184cdb13a5e59c => /vagrant/images/rpi-k3s-base-raspios-bookworm-armhf.img.gz
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Copying source image.
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Image is a gzip file.
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   24.74 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   36.63 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   29.80 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   33.50 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   33.45 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   28.26 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   35.50 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   32.91 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   26.81 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   22.51 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   19.27 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   37.09 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   38.07 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   43.50 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   27.95 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: Speed:   27.31 MB/s
    k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: mapping images/rpi-k3s-server-raspios-bookworm-armhf.img
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: losetup --show -f -P images/rpi-k3s-server-raspios-bookworm-armhf.img
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: partitions: [/dev/loop0p1]
==> k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf: error different of partitions than expected 1
Build 'k3s-server.arm-image.rpi-k3s-server-raspios-bookworm-armhf' errored after 1 minute 49 seconds: step canceled or halted

Reproduction Steps

sudo packer build -parallel-builds=1 ./packer/server-agent

Packer version

1.9.4

Simplified Packer Template

build.pkr.hcl

build {
  name = "k3s-server"

  source "source.arm-image.raspios_bookworm_armhf" {
    name = "rpi-k3s-server-raspios-bookworm-armhf"
    output_filename = "images/${source.name}.img"
  }

  source "source.arm-image.raspios_bookworm_arm64" {
    name = "rpi-k3s-server-raspios-bookworm-arm64"
    output_filename = "images/${source.name}.img"

  }

  provisioner "shell" {
    scripts = [
      "scripts/install-k3s-server.sh"
    ]
  }

  post-processors {
    post-processor "compress" {
      output = "images/${source.name}.img.gz"
    }
    post-processor "checksum" {
      checksum_types = ["sha256"]
      output = "images/${source.name}.img.gz.sha256"
    }
  }
}

build {
  name = "k3s-agent"

  source "source.arm-image.raspios_bookworm_armhf" {
    name = "rpi-k3s-agent-raspios-bookworm-armhf"
    output_filename = "images/${source.name}.img"
  }

  source "source.arm-image.raspios_bookworm_arm64" {
    name = "rpi-k3s-agent-raspios-bookworm-arm64"
    output_filename = "images/${source.name}.img"
  }

  provisioner "shell" {
    scripts = [
      "scripts/install-k3s-agent.sh"
    ]
  }

  post-processors {
    post-processor "compress" {
      output = "images/${source.name}.img.gz"
    }
    post-processor "checksum" {
      checksum_types = ["sha256"]
      output = "images/${source.name}.img.gz.sha256"
    }
  }

}

sources.pkr.hcl

source "arm-image" "raspios_bookworm_armhf" {

  image_type      = "raspberrypi"
  iso_url         = "images/rpi-k3s-base-raspios-bookworm-armhf.img.gz"
  iso_checksum    = "file:images/rpi-k3s-base-raspios-bookworm-armhf.img.gz.sha256"
}

source "arm-image" "raspios_bookworm_arm64" {
  image_type      = "raspberrypi"
  iso_url         = "images/rpi-k3s-base-raspios-bookworm-arm64.img.gz"
  iso_checksum    = "file:images/rpi-k3s-base-raspios-bookworm-arm64.img.gz.sha256"
  qemu_binary     = "qemu-aarch64-static"
}

plugins.pkr.hcl

packer {
  required_plugins {
    arm-image = {
      version = ">= 0.2.5"
      source  = "github.com/solo-io/arm-image"
    }
  }
}

Operating system and Environment details

Host machine: Windows 11 AMD64
Host machine terminal: Mintty via Git Bash
Guest VM: via Vagrant 2.4.0, VirtualBox 7.0, Debian 12

thomasmerx added a commit to thomasmerx/packer-plugin-arm-image that referenced this issue Jun 11, 2024
This fixes issue solo-io#162 and solo-io#165. I refactored the timeout handling,
with solo-io#169 by increasing the existing timeout and removing the additional 2 sec
sleep, because the 2 sec sleep was not working in all cases.
Unfortunately, the increase alone is not sufficient, so I'm re-adding
the 2 sec sleep again.
yuval-k pushed a commit that referenced this issue Jul 25, 2024
This fixes issue #162 and #165. I refactored the timeout handling,
with #169 by increasing the existing timeout and removing the additional 2 sec
sleep, because the 2 sec sleep was not working in all cases.
Unfortunately, the increase alone is not sufficient, so I'm re-adding
the 2 sec sleep again.
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

No branches or pull requests

1 participant