tinkerbell / actions

Suite of Tinkerbell Actions for use in Tinkerbell Workflows
Apache License 2.0
28 stars 43 forks source link

Minor changes in partitioning and filesystem creation login #96

Closed kozl closed 1 year ago

kozl commented 1 year ago

Pass filesystem create options and mark GPT filesystem type for EFI

Rootio doesn't respect FS create options in case of vfat filesystem. It doesn't mark GPT partition type as EFI. Fixing it.

chrisdoherty4 commented 1 year ago

Hi @kozl, thanks for the contrib. The changes look good. I don't see any details about testing in the OP - could you elaborate a little on what you tested this on? Thanks.

kozl commented 1 year ago

Hi! I've tested this changes on my local setup, metal server booted with Hook and my local reduced implementation of tink server. Here is the metadata and actions I've used:

    Metadata: Metadata{
        Instance: Instance{
            Storage: Storage{
                Disks: []Disk{
                    {
                        Device: "/dev/sda",
                        Partitions: []Partition{
                            {
                                Label:  "EFI",
                                Number: 1,
                                Size:   1000000,
                            },
                            {
                                Label:  "ROOT",
                                Number: 2,
                                Size:   5000000,
                            },
                            {
                                Label:  "VAR",
                                Number: 3,
                                Size:   5000000,
                            },
                            {
                                Label:  "HOME",
                                Number: 4,
                                Size:   1000000,
                            },
                        },

                        WipeTable: true,
                    },
                },
                Filesystems: []FileSystem{
                    {
                        Mount: Mount{
                            Create: struct {
                                Options []string `json:"options"`
                            }{
                                Options: []string{"-n", "EFI"},
                            },
                            Device: "/dev/sda1",
                            Format: "vfat",
                            Point:  "/boot/efi",
                        },
                    },
                    {
                        Mount: Mount{
                            Create: struct {
                                Options []string `json:"options"`
                            }{
                                Options: []string{"-L", "ROOT"},
                            },
                            Device: "/dev/sda2",
                            Format: "ext4",
                            Point:  "/",
                        },
                    },
                    {
                        Mount: Mount{
                            Create: struct {
                                Options []string `json:"options"`
                            }{
                                Options: []string{"-L", "VAR"},
                            },
                            Device: "/dev/sda3",
                            Format: "ext4",
                            Point:  "/var",
                        },
                    },
                    {
                        Mount: Mount{
                            Create: struct {
                                Options []string `json:"options"`
                            }{
                                Options: []string{"-L", "HOME"},
                            },
                            Device: "/dev/sda4",
                            Format: "ext4",
                            Point:  "/home",
                        },
                    },
                },
            },
        },
    },
var ActionList = []*proto.WorkflowAction{
    {
        TaskName: "os-installation",
        Name:     "wipe-disk-partitions",
        Image:    "wolfwalker/rootio:1.0.0",
        Timeout:  90,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Environment: []string{
            "MIRROR_HOST=10.0.2.2",
        },
        Command: []string{
            "partition",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "create-filesystems",
        Image:    "registry.k.avito.ru/tinkerbell-actions/rootio:1.0.0-avito1",
        Timeout:  90,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Environment: []string{
            "MIRROR_HOST=10.0.2.2",
        },
        Command: []string{
            "format",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "unpack-root-tar-to-sda2",
        Image:    "wolfwalker/archive2disk:0.0",
        Timeout:  6000,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Environment: []string{
            "ARCHIVE_URL=http://ceph-com.msk.avito.ru/service-metal-api/avi-clos-test03/root.tgz",
            "ARCHIVE_TYPE=targz",
            "DEST_DISK=/dev/sda2",
            "FS_TYPE=ext4",
            "DEST_PATH=/",
            "INSECURE_NO_TARFILE_CHECKSUM_VERIFICATION=true",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "unpack-efi-tar-to-sda1",
        Image:    "wolfwalker/archive2disk:0.0",
        Timeout:  6000,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Environment: []string{
            "ARCHIVE_URL=http://ceph-com.msk.avito.ru/service-metal-api/avi-clos-test03/efi.tgz",
            "ARCHIVE_TYPE=targz",
            "DEST_DISK=/dev/sda1",
            "FS_TYPE=vfat",
            "DEST_PATH=/",
            "INSECURE_NO_TARFILE_CHECKSUM_VERIFICATION=true",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "unpack-var-tar-to-sda3",
        Image:    "wolfwalker/archive2disk:0.0",
        Timeout:  6000,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Environment: []string{
            "ARCHIVE_URL=http://ceph-com.msk.avito.ru/service-metal-api/avi-clos-test03/var.tgz",
            "ARCHIVE_TYPE=targz",
            "DEST_DISK=/dev/sda3",
            "FS_TYPE=ext4",
            "DEST_PATH=/",
            "INSECURE_NO_TARFILE_CHECKSUM_VERIFICATION=true",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "unpack-home-tar-to-sda3",
        Image:    "wolfwalker/archive2disk:0.0",
        Timeout:  6000,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Environment: []string{
            "ARCHIVE_URL=http://ceph-com.msk.avito.ru/service-metal-api/avi-clos-test03/home.tgz",
            "ARCHIVE_TYPE=targz",
            "DEST_DISK=/dev/sda4",
            "FS_TYPE=ext4",
            "DEST_PATH=/",
            "INSECURE_NO_TARFILE_CHECKSUM_VERIFICATION=true",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "grub-mkconfig",
        Image:    "quay.io/tinkerbell-actions/cexec:v1.0.0",
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes: []string{
            "/dev:/dev",
            "/proc:/proc",
            "/sys:/sys",
            "/mnt:/mnt",
            "/statedir:/statedir",
            "/etc:/etc",
            "/bin:/bin",
            "/sbin:/sbin",
            "/var:/var",
            "/usr:/usr",
            "/lib:/lib",
            "/tmp:/tmp",
            "/boot:/boot",
        },
        Timeout: 2000,
        Environment: []string{
            "BLOCK_DEVICE=/dev/sda2",
            "FS_TYPE=ext4",
            "CHROOT=y",
            "DEFAULT_INTERPRETER=/bin/sh -c",
            "CMD_LINE=grub-mkconfig -o /boot/grub/grub.cfg",
        },
    },

    {
        TaskName: "os-installation",
        Name:     "kexec",
        Image:    "quay.io/tinkerbell-actions/kexec:v1.0.0",
        Timeout:  600,
        WorkerId: "0eba0bf8-3772-4b4a-ab9f-6ebe93b90a96",
        Volumes:  Volumes,
        Pid:      "host",
        Environment: []string{
            "BLOCK_DEVICE=/dev/sda2",
            "FS_TYPE=ext4",
            "CMD_LINE=console=ttyS0 root=/dev/sda2",
        },
    },
}