Skip to content

Commit

Permalink
Support for s3-large-x86 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Apr 15, 2021
1 parent 023b0cf commit a127b2e
Show file tree
Hide file tree
Showing 28 changed files with 206 additions and 416 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
- uses: google-github-actions/setup-gcloud@master
with:
version: '278.0.0'
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Build image
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
- uses: google-github-actions/setup-gcloud@master
with:
version: '278.0.0'
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Build image
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
- uses: google-github-actions/setup-gcloud@master
with:
version: '278.0.0'
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Get release
id: get_release
uses: bruceadams/[email protected].1
uses: bruceadams/[email protected].2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update \
hdparm \
ipmitool \
liblz4-tool \
mdadm \
net-tools \
nvme-cli \
pciutils \
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ ramdisk:
-files="/sbin/mkswap:sbin/mkswap" \
-files="/sbin/mkfs.fat:sbin/mkfs.fat" \
-files="/usr/sbin/nvme:sbin/nvme" \
-files="/sbin/mdadm:sbin/mdadm" \
-files="/sbin/mdmon:sbin/mdmon" \
-files="/sbin/sgdisk:sbin/sgdisk" \
-files="/etc/ssl/certs/ca-certificates.crt:etc/ssl/certs/ca-certificates.crt" \
-files="/usr/lib/x86_64-linux-gnu/libnss_files.so:lib/libnss_files.so.2" \
Expand All @@ -74,7 +76,7 @@ vagrant-destroy:
vagrant destroy -f

vagrant-up: vagrant-destroy
vagrant up && virsh console metal-hammer_pxeclient
vagrant up && virsh console metal-hammerpxeclient

# TODO make this work as with vagrant as a lightweight alternative.
# networking is not working atm.
Expand All @@ -93,5 +95,5 @@ qemu-up:
IMAGE_URL=http://192.168.121.1:4711/images/ubuntu/19.04/img.tar.lz4 \
DEBUG=1 \
BGP=1" \
-kernel metal-hammer-kernel \
-kernel metal-kernel \
-initrd metal-hammer-initrd.img.lz4
3 changes: 3 additions & 0 deletions README.ice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Intel 100GB driver

[Intel Driver Download](https://www.intel.com/content/www/us/en/search.html?ws=text#q=e810&t=Downloads&layout=table)
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vi: set ft=ruby :

current_file_path = File.dirname(__FILE__)
kernel_path = File.join(current_file_path, "metal-hammer-kernel")
kernel_path = File.join(current_file_path, "metal-kernel")
initrd_path = File.join(current_file_path, "metal-hammer-initrd.img.lz4")

Vagrant.configure("2") do |config|
Expand Down Expand Up @@ -37,7 +37,7 @@ Vagrant.configure("2") do |config|
"METAL_CORE_ADDRESS=192.168.121.1:4712 " \
"IMAGE_ID=default " \
"SIZE_ID=v1-small-x86 " \
"IMAGE_URL=http://192.168.121.1:4711/images/ubuntu/19.04/img.tar.lz4 " \
"IMAGE_URL=http://192.168.121.1:4711/images/ubuntu/20.04/img.tar.lz4 " \
"DEBUG=1 " \
"BGP=1"
domain.loader = "/usr/share/OVMF/OVMF_CODE.fd"
Expand Down
2 changes: 2 additions & 0 deletions cmd/event/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestNewEventEmitter(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.args.machineID, tt.want.machineID, "check machine ID")
})
Expand Down Expand Up @@ -65,6 +66,7 @@ func TestEventEmitter_Emit(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
tt.e.Emit(tt.args.eventType, tt.args.message)
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/network/ethtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (e *Ethtool) disableFirmwareLLDP(ifi string) {
}
}

var buggyIntelNicDriverNames = []string{"i40e", "ice"}
var buggyIntelNicDriverNames = []string{"i40e"}

// stopFirmwareLLDP stop Firmeware LLDP not persistent over reboots, only during runtime.
// mount -t debugfs none /sys/kernel/debug
Expand All @@ -98,7 +98,7 @@ var buggyIntelNicDriverNames = []string{"i40e", "ice"}
// or a loop over all directories in /sys/kernel/debug/i40e/*/command
func (e *Ethtool) stopFirmwareLLDP() {
for _, driver := range buggyIntelNicDriverNames {
log.Info("ethtool", "stopFirmwareLLDP", "driver", driver)
log.Info("ethtool", "stopFirmwareLLDP for driver", driver)
debugFSPath := path.Join("/sys/kernel/debug", driver)
err := filepath.Walk(debugFSPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/network/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/metal-stack/go-lldpd/pkg/lldp"
"github.com/metal-stack/metal-hammer/metal-core/models"
"github.com/metal-stack/metal-hammer/pkg/lldp"
"github.com/metal-stack/v"

log "github.com/inconshreveable/log15"
Expand Down
2 changes: 2 additions & 0 deletions cmd/register/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func Test_readHardwareDetails(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
r := &Register{
Client: tt.fields.Client,
Expand Down Expand Up @@ -121,6 +122,7 @@ func TestHammer_readIPMIDetails(t *testing.T) {
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := readIPMIDetails("00:00:00:00:00:01", nil)
if (err != nil) != tt.wantErr {
Expand Down
14 changes: 7 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ func Run(spec *Specification, hal hal.InBand) (*event.EventEmitter, error) {

hammer.Spec.ConsolePassword = password.Generate(16)

grpcClient, err := NewGrpcClient(certsClient, eventEmitter)
if err != nil {
log.Error("failed to fetch GRPC certificates", "error", err)
return eventEmitter, err
}
hammer.GrpcClient = grpcClient

err = hammer.createBmcSuperuser()
if err != nil {
log.Error("failed to update bmc superuser password", "error", err)
Expand Down Expand Up @@ -115,13 +122,6 @@ func Run(spec *Specification, hal hal.InBand) (*event.EventEmitter, error) {
return eventEmitter, errors.Wrap(err, "register")
}

grpcClient, err := NewGrpcClient(certsClient, eventEmitter)
if err != nil {
log.Error("failed to fetch GRPC certificates", "error", err)
return eventEmitter, err
}
hammer.GrpcClient = grpcClient

m, err := hammer.fetchMachine(spec.MachineUUID)
if err == nil && m != nil && m.Allocation != nil && m.Allocation.Reinstall != nil && *m.Allocation.Reinstall {
primaryDiskWiped := false
Expand Down
43 changes: 43 additions & 0 deletions cmd/storage/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ const (
EXT4 = FSType("ext4")
// SWAP is for the swap partition
SWAP = FSType("swap")
// None
NONE = FSType("none")

// GPTBoot EFI Boot Partition
GPTBoot = GPTType("ef00")
// GPTLinux Linux Partition
GPTLinux = GPTType("8300")
// GPTLinux Linux Partition
GPTLinuxLVM = GPTType("8e00")
// EFISystemPartition see https://en.wikipedia.org/wiki/EFI_system_partition
EFISystemPartition = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
// GIB bytes of a Gigabyte
Expand Down Expand Up @@ -138,6 +142,39 @@ var (
},
},
}
s3LargeDisk = Disk{
Partitions: []*Partition{
{
Label: "efi",
Number: 1,
MountPoint: "/boot/efi",
Filesystem: VFAT,
GPTType: GPTBoot,
GPTGuid: EFISystemPartition,
Size: 300,
Properties: make(map[string]string),
},
{
Label: "root",
Number: 2,
MountPoint: "/",
Filesystem: EXT4,
GPTType: GPTLinux,
Size: 50000,
Properties: make(map[string]string),
},
// Keep room for a additional Partition to be used by LVM
{
Label: "vgroot",
Number: 3,
MountPoint: "",
Filesystem: NONE,
GPTType: GPTLinuxLVM,
Size: -1,
Properties: make(map[string]string),
},
},
}
)

// String for a Partition
Expand All @@ -155,6 +192,8 @@ func primaryDeviceBySize(sizeID string, disks []*models.ModelsV1MachineBlockDevi
return PrimaryDevice{DeviceName: "/dev/nvme0n1", PartitionPrefix: "p"}
case "y1-medium-x86":
return PrimaryDevice{DeviceName: "/dev/nvme0n1", PartitionPrefix: "p"}
case "s3-large-x86":
return PrimaryDevice{DeviceName: "/dev/sda", PartitionPrefix: ""}
default:
log.Info("getdisk", "sizeID unknown, try to guess disk", sizeID)
deviceName := guessDisk(disks)
Expand Down Expand Up @@ -210,6 +249,10 @@ func guessDisk(disks []*models.ModelsV1MachineBlockDevice) string {
func GetDisk(imageID string, size *models.ModelsV1SizeResponse, disks []*models.ModelsV1MachineBlockDevice) Disk {
log.Info("getdisk", "imageID", imageID)
disk := diskByImage(imageID)
// TODO hack, must be moved to metal-api as all other code here as well
if *size.ID == "s3-large-x86" {
disk = s3LargeDisk
}

primaryDevice := primaryDeviceBySize(*size.ID, disks)
disk.Device = primaryDevice.DeviceName
Expand Down
1 change: 1 addition & 0 deletions cmd/storage/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestGuessDisk(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if got := guessDisk(tt.disks); !reflect.DeepEqual(got, tt.want) {
t.Errorf("guessDisk() = %v, want %v", got, tt.want)
Expand Down
2 changes: 2 additions & 0 deletions cmd/storage/mkfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func assembleMKFSCommand(p *Partition) (string, []string, error) {
if p.Label != "" {
args = append(args, "-L", p.Label)
}
case NONE:
// noop
default:
return "", nil, errors.Errorf("unsupported filesystem format: %q", p.Filesystem)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/storage/mkfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func Test_assembleMKFSCommand(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
mkfs, mkfsargs, err := assembleMKFSCommand(tt.partition.p)
if (err != nil) != tt.wantErr {
Expand Down
3 changes: 3 additions & 0 deletions cmd/storage/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (disk Disk) MountPartitions(prefix string) error {
partitions := disk.SortByMountPoint()

for _, p := range partitions {
if p.Filesystem == NONE {
continue
}
err := p.Mount(prefix, false)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions cmd/storage/sgdisk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Test_assembleSGDiskCommand(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if got := assembleSGDiskCommand(tt.disk.disk); !reflect.DeepEqual(got, tt.want) {
t.Errorf("assembleSGDiskCommand() = %v, want %v", got, tt.want)
Expand Down
Loading

0 comments on commit a127b2e

Please sign in to comment.