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

fix: ensure machine-id, initiatorname.iscsi and host{id,nqn} are unique (backport #190) #191

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ ARG NERDCTL_VERSION=1.2.1
RUN curl -o ./nerdctl-bin.tar.gz -sfL "https://github.com/containerd/nerdctl/releases/download/v${NERDCTL_VERSION}/nerdctl-${NERDCTL_VERSION}-linux-${ARCH}.tar.gz"
RUN tar -zxvf nerdctl-bin.tar.gz && mv nerdctl /usr/bin/
RUN rm -f nerdctl-bin.tar.gz containerd-rootless-setuptool.sh containerd-rootless.sh

# Remove files that need to be unique on each host.
# These will be generated automatically at runtime.
# See https://github.com/harvester/harvester/issues/6911 for details
RUN rm -f /etc/machine-id /etc/iscsi/initiatorname.iscsi /etc/nvme/hostid /etc/nvme/hostnqn
21 changes: 21 additions & 0 deletions files/system/oem/00_rootfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ stages:
/etc/rancher
/etc/ssh
/etc/iscsi
/etc/nvme
/etc/cni
/etc/pki/trust/anchors
/home
Expand Down Expand Up @@ -51,3 +52,23 @@ stages:
mkdir -p /usr/local/etc
cp /etc/machine-id /usr/local/etc
fi
- if: '[ ! -f "/run/cos/recovery_mode" -a -d "/etc/iscsi" ]'
name: "Generate /etc/iscsi/initiatorname.iscsi"
commands:
- |
if [ ! -f /etc/iscsi/initiatorname.iscsi ] ; then
/usr/bin/echo "Generating /etc/iscsi/initiatorname.iscsi"
/sbin/iscsi-gen-initiatorname
fi
- if: '[ ! -f "/run/cos/recovery_mode" -a -d "/etc/nvme" ]'
name: "Generate /etc/nvme/hostnqn and /etc/nvme/hostid"
commands:
- |
if [ ! -s /etc/nvme/hostnqn ]; then
/usr/bin/echo "Generating /etc/nvme/hostnqn"
/usr/sbin/nvme gen-hostnqn > /etc/nvme/hostnqn
fi
if [ ! -s /etc/nvme/hostid ]; then
/usr/bin/echo "Generating /etc/nvme/hostid"
sed -nr 's/.*:uuid:(.*?)$/\1/p' /etc/nvme/hostnqn > /etc/nvme/hostid
fi