Skip to content

Commit

Permalink
fix: several fixes for GPT and ZFS
Browse files Browse the repository at this point in the history
Fix ZFS probing, and skip if the device is too small to avoid printing
weird errors in probe logs.

Fix GPT allocation/size discovery to match `sfdisk`: first usable LBA
should be aligned to the partition boundary, and allocatable space
should be also aligned as well.

Fix ZFS tests to use testdata, so that we can run tests in local mode.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Aug 20, 2024
1 parent 07f736f commit 41240c1
Show file tree
Hide file tree
Showing 24 changed files with 349 additions and 97 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-07-17T17:13:05Z by kres ac94478-dirty.
# Generated on 2024-08-20T10:44:02Z by kres 7be2a05.

*
!internal
!blkid
!block
!partitioning
!go.mod
!go.sum
!.golangci.yml
10 changes: 6 additions & 4 deletions .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
- cryptsetup
- dosfstools
- e2fsprogs
- gptfdisk
- lvm2
- parted
- util-linux
Expand Down Expand Up @@ -44,19 +45,20 @@ spec:
from: fedora:39
steps:
- script:
command: dnf install -y zfs-fuse && rm -rf /var/cache/dnf
command: dnf install -y zfs-fuse zstd && rm -rf /var/cache/dnf
- script:
command: |
--security=insecure zfs-fuse & \
dd if=/dev/zero of=/tmp/zfs.img bs=16M count=4 iflag=fullblock && \
sleep 1 && \
zpool create -f -R /tmp/zfs zroot1 /tmp/zfs.img
zpool create -f -R /tmp/zfs zroot1 /tmp/zfs.img && \
zstd -19 /tmp/zfs.img -o /tmp/zfs.img.zst
- name: zfs-img
description: copies out the ZFS image
steps:
- copy:
from: zfs-img-gen
src: /tmp/zfs.img
src: /tmp/zfs.img.zst
dst: /
---
kind: golang.UnitTests
Expand All @@ -68,4 +70,4 @@ spec:
- copy:
from: zfs-img
src: /
dst: /usr/share/
dst: /src/blkid/testdata/
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-07-17T17:17:17Z by kres ac94478-dirty.
# Generated on 2024-08-20T12:11:08Z by kres 7be2a05.

ARG TOOLCHAIN

Expand All @@ -11,15 +11,16 @@ FROM scratch AS generate

# base toolchain image
FROM --platform=${BUILDPLATFORM} ${TOOLCHAIN} AS toolchain
RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev cdrkit cryptsetup dosfstools e2fsprogs lvm2 parted util-linux squashfs-tools xfsprogs
RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev cdrkit cryptsetup dosfstools e2fsprogs gptfdisk lvm2 parted util-linux squashfs-tools xfsprogs

# Creates the ZFS image
FROM fedora:39 AS zfs-img-gen
RUN dnf install -y zfs-fuse && rm -rf /var/cache/dnf
RUN dnf install -y zfs-fuse zstd && rm -rf /var/cache/dnf
RUN --security=insecure zfs-fuse & \
dd if=/dev/zero of=/tmp/zfs.img bs=16M count=4 iflag=fullblock && \
sleep 1 && \
zpool create -f -R /tmp/zfs zroot1 /tmp/zfs.img
zpool create -f -R /tmp/zfs zroot1 /tmp/zfs.img && \
zstd -19 /tmp/zfs.img -o /tmp/zfs.img.zst


# build tools
Expand All @@ -46,7 +47,7 @@ RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \

# copies out the ZFS image
FROM scratch AS zfs-img
COPY --from=zfs-img-gen /tmp/zfs.img /
COPY --from=zfs-img-gen /tmp/zfs.img.zst /

# tools and sources
FROM tools AS base
Expand All @@ -59,6 +60,7 @@ RUN --mount=type=cache,target=/go/pkg go mod verify
COPY ./internal ./internal
COPY ./blkid ./blkid
COPY ./block ./block
COPY ./partitioning ./partitioning
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null

# runs gofumpt
Expand All @@ -80,14 +82,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/g

# runs unit-tests with race detector
FROM base AS unit-tests-race
COPY --from=zfs-img / /usr/share/
COPY --from=zfs-img / /src/blkid/testdata/
WORKDIR /src
ARG TESTPKGS
RUN --security=insecure --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp CGO_ENABLED=1 go test -v -race -count 1 ${TESTPKGS}

# runs unit-tests
FROM base AS unit-tests-run
COPY --from=zfs-img / /usr/share/
COPY --from=zfs-img / /src/blkid/testdata/
WORKDIR /src
ARG TESTPKGS
RUN --security=insecure --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS}
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-07-17T17:17:17Z by kres ac94478-dirty.
# Generated on 2024-08-20T10:44:02Z by kres 7be2a05.

# common variables

Expand All @@ -18,14 +18,14 @@ REGISTRY ?= ghcr.io
USERNAME ?= siderolabs
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
PROTOBUF_GO_VERSION ?= 1.34.2
GRPC_GO_VERSION ?= 1.4.0
GRPC_GATEWAY_VERSION ?= 2.20.0
GRPC_GO_VERSION ?= 1.5.1
GRPC_GATEWAY_VERSION ?= 2.21.0
VTPROTOBUF_VERSION ?= 0.6.0
GOIMPORTS_VERSION ?= 0.23.0
GOIMPORTS_VERSION ?= 0.24.0
DEEPCOPY_VERSION ?= v0.5.6
GOLANGCILINT_VERSION ?= v1.59.1
GOLANGCILINT_VERSION ?= v1.60.1
GOFUMPT_VERSION ?= v0.6.0
GO_VERSION ?= 1.22.4
GO_VERSION ?= 1.23.0
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
Expand Down Expand Up @@ -67,7 +67,7 @@ COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)"
COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)"
COMMON_ARGS += --build-arg=GOFUMPT_VERSION="$(GOFUMPT_VERSION)"
COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)"
TOOLCHAIN ?= docker.io/golang:1.22-alpine
TOOLCHAIN ?= docker.io/golang:1.23-alpine

# help menu

Expand Down
Loading

0 comments on commit 41240c1

Please sign in to comment.