Skip to content

Commit

Permalink
Make network interface names predictable
Browse files Browse the repository at this point in the history
Signed-off-by: Kiefer Chang <[email protected]>
  • Loading branch information
bk201 authored and guangbochen committed Sep 10, 2021
1 parent f846b0f commit 9166b6b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
2 changes: 2 additions & 0 deletions package/harvester-os/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ RUN curl -sfL https://github.com/rancher/wharfie/releases/latest/download/wharfi
COPY files/ /
RUN chmod 0600 /system/oem/*

RUN rm -f /system/oem/05_network.yaml

ARG HARVESTER_INSTALLER_VERSION

RUN echo GRUB_ENTRY_NAME="\"Harvester $HARVESTER_INSTALLER_VERSION\"" >> /etc/os-release
4 changes: 2 additions & 2 deletions package/harvester-os/files/etc/cos/bootargs.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
set console_params="console=tty1"
set kernel=/boot/vmlinuz
if [ -n "$recoverylabel" ]; then
set kernelcmd="$console_params root=live:LABEL=$recoverylabel rd.live.dir=/ rd.live.squashimg=$img panic=5"
set kernelcmd="$console_params root=live:LABEL=$recoverylabel rd.live.dir=/ rd.live.squashimg=$img panic=5 net.ifnames=1"
else
set kernelcmd="$console_params root=LABEL=$label cos-img/filename=$img panic=5"
set kernelcmd="$console_params root=LABEL=$label cos-img/filename=$img panic=5 net.ifnames=1"
fi

set initramfs=/boot/initrd
2 changes: 1 addition & 1 deletion package/harvester-os/files/system/oem/90_network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ stages:
initramfs:
- commands:
- |
for i in /sys/class/net/eth*; do
for i in /sys/class/net/{eth*,en*,ib*}; do
[ -e $i ] || continue
ip link set $(basename $i) up;
done
20 changes: 20 additions & 0 deletions package/harvester-os/iso/boot/syslinux/syslinux.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SERIAL 0
PROMPT 1
TIMEOUT 50
DEFAULT vga

SAY
SAY ##################################################################
SAY # #
SAY # Press <ENTER> to boot HarvesterOS Live or wait 5 seconds. #
SAY # #
SAY # Press <TAB> to view available boot entries or enter Syslinux #
SAY # commands directly. #
SAY # #
SAY ##################################################################
SAY

LABEL vga
LINUX /boot/kernel.xz
APPEND cdroot root=live:CDLABEL=COS_LIVE rd.live.dir=/ rd.live.squashimg=rootfs.squashfs console=tty1 console=ttyS0 rd.cos.disable net.ifnames=1
INITRD /boot/rootfs.xz
21 changes: 9 additions & 12 deletions pkg/config/cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
)

const (
cosLoginUser = "rancher"
cosLoginUser = "rancher"
manifestsDirectory = "/var/lib/rancher/rke2/server/manifests/"
canalConfig = "rke2-canal-config.yaml"
harvesterConfig = "harvester-config.yaml"
canalConfig = "rke2-canal-config.yaml"
harvesterConfig = "harvester-config.yaml"
)

var (
Expand All @@ -29,9 +29,6 @@ func ConvertToCOS(config *HarvesterConfig) (*yipSchema.YipConfig, error) {
return nil, err
}

preStage := yipSchema.Stage{}
preStage.Commands = append(preStage.Commands, "rm -f /etc/sysconfig/network/ifcfg-eth0")

initramfs := yipSchema.Stage{
SSHKeys: make(map[string][]string),
Users: make(map[string]yipSchema.User),
Expand Down Expand Up @@ -115,7 +112,7 @@ func ConvertToCOS(config *HarvesterConfig) (*yipSchema.YipConfig, error) {
return nil, err
}
initramfs.Files = append(initramfs.Files, yipSchema.File{
Path: manifestsDirectory+canalConfig,
Path: manifestsDirectory + canalConfig,
Content: canalHelmChartConfig,
Permissions: 0600,
Owner: 0,
Expand All @@ -129,19 +126,19 @@ func ConvertToCOS(config *HarvesterConfig) (*yipSchema.YipConfig, error) {
return nil, err
}
initramfs.Files = append(initramfs.Files, yipSchema.File{
Path: manifestsDirectory+harvesterConfig,
Content: harvesterHelmChartConfig,
Path: manifestsDirectory + harvesterConfig,
Content: harvesterHelmChartConfig,
Permissions: 0600,
Owner: 0,
Group: 0,
Owner: 0,
Group: 0,
})
}
}

cosConfig := &yipSchema.YipConfig{
Name: "Harvester Configuration",
Stages: map[string][]yipSchema.Stage{
"initramfs": {preStage, initramfs},
"initramfs": {initramfs},
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/console/install_panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ func addNetworkPanel(c *Console) error {
if output, err := setupNetwork(); err != nil {
return fmt.Sprintf("Configure network failed: %s", string(output)), nil
}
return "Can't get a valid IP address from DHCP server", nil
return "", nil
}
askNetworkMethodVConfirm := func(g *gocui.Gui, _ *gocui.View) error {
selected, err := askNetworkMethodV.GetData()
Expand Down

0 comments on commit 9166b6b

Please sign in to comment.